Added 3D player model, added better cam movement
This commit is contained in:
8
Assets/Scripts/Behaviours.meta
Normal file
8
Assets/Scripts/Behaviours.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4dfc35c7ffd320abab655688058b1f1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Scripts/Behaviours/ChoppingBehaviour.cs
Normal file
36
Assets/Scripts/Behaviours/ChoppingBehaviour.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChoppingBehaviour : StateMachineBehaviour
|
||||
{
|
||||
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
|
||||
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Debug.Log("Started animation " + stateInfo.ToString());
|
||||
}
|
||||
|
||||
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
|
||||
//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
|
||||
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Debug.Log("Stopped animation " + stateInfo.ToString());
|
||||
}
|
||||
|
||||
// OnStateMove is called right after Animator.OnAnimatorMove()
|
||||
//override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
//{
|
||||
// // Implement code that processes and affects root motion
|
||||
//}
|
||||
|
||||
// OnStateIK is called right after Animator.OnAnimatorIK()
|
||||
//override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
//{
|
||||
// // Implement code that sets up animation IK (inverse kinematics)
|
||||
//}
|
||||
}
|
||||
11
Assets/Scripts/Behaviours/ChoppingBehaviour.cs.meta
Normal file
11
Assets/Scripts/Behaviours/ChoppingBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdc7b2ad2df51bc288ed7c296042518f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Assets.Scripts.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Classes
|
||||
{
|
||||
@@ -15,6 +16,9 @@ namespace Assets.Scripts.Classes
|
||||
protected int strengthBonus;
|
||||
protected int healthBonus;
|
||||
protected int secondaryBonus;
|
||||
protected string leftHandName;
|
||||
protected string rightHandName;
|
||||
|
||||
|
||||
public BasicClass()
|
||||
{
|
||||
@@ -24,11 +28,30 @@ namespace Assets.Scripts.Classes
|
||||
strengthBonus = 0;
|
||||
healthBonus = 0;
|
||||
secondaryBonus = 0;
|
||||
rightHandName = "";
|
||||
leftHandName = "";
|
||||
}
|
||||
|
||||
public void applyBonus(PlayerObject player)
|
||||
{
|
||||
player.changeStats(strengthBonus, healthBonus, dexterityBonus, intelligenceBonus, secondaryBonus);
|
||||
}
|
||||
|
||||
public void loadHandObjects()
|
||||
{
|
||||
GameObject leftHandPrefab = Resources.Load<GameObject>("Prefabs/"+leftHandName);
|
||||
GameObject rightHandPrefab = Resources.Load<GameObject>("Prefabs/"+rightHandName);
|
||||
|
||||
GameObject leftHandParent = GameObject.Find("leftHand");
|
||||
GameObject rightHandParent = GameObject.Find("rightHand");
|
||||
|
||||
if(leftHandPrefab != null){
|
||||
GameObject leftHand = GameObject.Instantiate(leftHandPrefab, leftHandParent.transform);
|
||||
}
|
||||
|
||||
if(rightHandPrefab != null){
|
||||
GameObject rightHand = GameObject.Instantiate(rightHandPrefab, rightHandParent.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Classes
|
||||
{
|
||||
@@ -16,6 +17,8 @@ namespace Assets.Scripts.Classes
|
||||
strengthBonus = -2;
|
||||
healthBonus = -10;
|
||||
secondaryBonus = 10;
|
||||
leftHandName = "orb";
|
||||
rightHandName = "wand";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Assets.Scripts.Classes
|
||||
strengthBonus = -1;
|
||||
healthBonus = 0;
|
||||
secondaryBonus = 0;
|
||||
leftHandName = "smallShield";
|
||||
rightHandName = "dagger";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Assets.Scripts.Classes
|
||||
strengthBonus = 2;
|
||||
healthBonus = 10;
|
||||
secondaryBonus = -10;
|
||||
leftHandName = "shield";
|
||||
rightHandName = "sword";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,4 +241,23 @@ public class Controls : MonoBehaviour
|
||||
fight.GetComponent<Fight>().playerAction(6);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDisarm()
|
||||
{
|
||||
if (player.GetComponent<PlayerGameObject>().isArmed)
|
||||
{
|
||||
player.GetComponent<Animator>().SetTrigger("WeaponHandling");
|
||||
player.GetComponent<Animator>().SetBool("isArmed", true);
|
||||
player.GetComponent<PlayerGameObject>().isArmed = false;
|
||||
player.GetComponent<Animator>().SetInteger("objectCategory", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.GetComponent<Animator>().SetTrigger("WeaponHandling");
|
||||
player.GetComponent<Animator>().SetBool("isArmed", false);
|
||||
player.GetComponent<PlayerGameObject>().isArmed = true;
|
||||
player.GetComponent<Animator>().SetInteger("objectCategory", 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Assets.Scripts.InteractableObjects
|
||||
bool gotItem = false;
|
||||
|
||||
public override void handleInteraction(GameObject player){
|
||||
keepAlive = true;
|
||||
if (gotItem)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("alreadyLooted"));
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Assets.Scripts.InteractableObjects
|
||||
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
keepAlive = true;
|
||||
if (hasInteracted)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("triedHouse"));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
@@ -26,8 +27,9 @@ namespace Assets.Scripts.InteractableObjects
|
||||
|
||||
public void OnInteraction(GameObject player)
|
||||
{
|
||||
StartCoroutine(playParticle(player));
|
||||
StartCoroutine(playAnimation(player));
|
||||
//StartCoroutine(playParticle(player));
|
||||
|
||||
//StartCoroutine(playAnimation(player));
|
||||
handleInteraction(player);
|
||||
}
|
||||
|
||||
@@ -53,8 +55,30 @@ namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
if (clip != null)
|
||||
{
|
||||
Animator animator = player.GetComponent<Animator>();
|
||||
AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
|
||||
float length = 0;
|
||||
foreach (AnimationClip clip in clips)
|
||||
{
|
||||
if (clip.name.ToLower() == "disarming")
|
||||
{
|
||||
length = clip.length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (player.GetComponent<PlayerGameObject>().isArmed)
|
||||
{
|
||||
player.GetComponent<Animator>().Play("Disarming");
|
||||
yield return new WaitForSeconds(length);
|
||||
}
|
||||
player.GetComponent<Animator>().Play(clip.name);
|
||||
yield return new WaitForSeconds(clip.length);
|
||||
if (player.GetComponent<PlayerGameObject>().isArmed)
|
||||
{
|
||||
player.GetComponent<Animator>().Play("Arming");
|
||||
yield return new WaitForSeconds(length);
|
||||
}
|
||||
|
||||
}
|
||||
animationPlayed = true;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
player.GetComponent<Animator>().SetInteger("objectCategory", 2);
|
||||
player.GetComponent<Animator>().SetTrigger("Interaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
player.GetComponent<Animator>().SetInteger("objectCategory", 2);
|
||||
player.GetComponent<Animator>().SetTrigger("Interaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
player.GetComponent<Animator>().SetInteger("objectCategory", 1);
|
||||
player.GetComponent<Animator>().SetTrigger("Interaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
UIHandler uihandler;
|
||||
GameObject interact;
|
||||
public float mouseSpeed = 100; //the sensibility
|
||||
public float controllerSpeed = 0.01f; //the sensibility
|
||||
public float mouseSpeed = 10f; //the sensibility
|
||||
public float controllerSpeed = 1f; //the sensibility
|
||||
float xMaxLimit = 45.0f;
|
||||
float xMinLimit = -45.0f;
|
||||
Vector2 rotation = Vector2.zero;
|
||||
@@ -27,7 +27,7 @@ namespace Assets.Scripts.Player
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.position = new Vector3(transform.parent.transform.position.x, transform.position.y, transform.parent.transform.position.z);
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -50,17 +50,27 @@ namespace Assets.Scripts.Player
|
||||
|
||||
public void lookAround(Vector2 view, bool isController)
|
||||
{
|
||||
rotation.y += view.x;
|
||||
rotation.x += -view.y;
|
||||
rotation.x = Mathf.Clamp(rotation.x, xMinLimit, xMaxLimit);
|
||||
GameObject target = GameObject.Find("targetLooking");
|
||||
if (isController)
|
||||
{
|
||||
transform.eulerAngles = rotation * (controllerSpeed * Time.deltaTime);
|
||||
target.transform.localPosition = target.transform.localPosition + new Vector3(view.x,view.y,0) * controllerSpeed * Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.eulerAngles = rotation * mouseSpeed;
|
||||
//TODO: Look at camera movement -> Not rly smooth. Weird drag
|
||||
target.transform.localPosition = target.transform.localPosition + new Vector3(view.x,view.y,0) * Mathf.Pow(mouseSpeed,2) * Time.deltaTime;
|
||||
}
|
||||
|
||||
if(target.transform.localPosition.x >= 3){
|
||||
target.transform.localPosition = new Vector3(3f,target.transform.localPosition.y,target.transform.localPosition.z);
|
||||
}
|
||||
if(target.transform.localPosition.x <= -3){
|
||||
target.transform.localPosition = new Vector3(-3f,target.transform.localPosition.y,target.transform.localPosition.z);
|
||||
}
|
||||
if(target.transform.localPosition.y >= 2){
|
||||
target.transform.localPosition = new Vector3(target.transform.localPosition.x,2f,target.transform.localPosition.z);
|
||||
}
|
||||
if(target.transform.localPosition.y <= -1){
|
||||
target.transform.localPosition = new Vector3(target.transform.localPosition.x,-1f,target.transform.localPosition.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
public class PlayerGameObject : MonoBehaviour
|
||||
{
|
||||
public float speed = 5f;
|
||||
public GameObject[] leftHands;
|
||||
public GameObject[] rightHands;
|
||||
|
||||
UIHandler uihandler;
|
||||
AudioHandler audioHandler;
|
||||
WorldGenerator worldGenerator;
|
||||
@@ -22,10 +26,11 @@ namespace Assets.Scripts.Player
|
||||
int difficulty = 0;
|
||||
bool finishedGame = false;
|
||||
PlayerObject player;
|
||||
public float speed = 5f;
|
||||
DateTime now;
|
||||
int bobbingDirection = -1;
|
||||
|
||||
public bool isArmed;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
@@ -46,12 +51,15 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
|
||||
}
|
||||
generatePlayer();
|
||||
isArmed = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(player == null){
|
||||
return;
|
||||
}
|
||||
if (player.getStat("Killcount").getAmount() == -1)
|
||||
{
|
||||
return;
|
||||
@@ -137,8 +145,11 @@ namespace Assets.Scripts.Player
|
||||
string playername = PlayerPrefs.GetString("playername");
|
||||
difficulty = PlayerPrefs.GetInt("difficulty");
|
||||
player = new PlayerObject(playername, race, role, difficulty);
|
||||
player.getClass().loadHandObjects();
|
||||
GetComponent<Animator>().SetBool("isArmed", true);
|
||||
}
|
||||
|
||||
//Generating player instance for stat preview during creation
|
||||
public void generatePlayer(BasicRace playerRace, BasicClass playerClass, string name, int difficulty)
|
||||
{
|
||||
player = new PlayerObject(name, playerRace, playerClass, difficulty);
|
||||
@@ -164,20 +175,6 @@ namespace Assets.Scripts.Player
|
||||
movement = camera.transform.TransformDirection(movement);
|
||||
movement.y = 0;
|
||||
gameObject.transform.Translate(movement * speed * Time.deltaTime);
|
||||
|
||||
if (input.z != 0)
|
||||
{
|
||||
if (camera.transform.localPosition.y >= 0.5)
|
||||
{
|
||||
bobbingDirection = -1;
|
||||
}
|
||||
else if (camera.transform.localPosition.y <= 0.3)
|
||||
{
|
||||
bobbingDirection = 1;
|
||||
}
|
||||
|
||||
camera.transform.Translate(new Vector3(0, bobbingDirection, 0) * Time.deltaTime / 2);
|
||||
}
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1);
|
||||
}
|
||||
|
||||
@@ -324,6 +321,8 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
player = new PlayerObject();
|
||||
player.loadPlayer(json);
|
||||
player.getClass().loadHandObjects();
|
||||
GetComponent<Animator>().SetBool("isArmed", true);
|
||||
}
|
||||
|
||||
public PlayerObject getPlayer()
|
||||
|
||||
Reference in New Issue
Block a user