Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using UnityEngine.AI;
- using UnityEngine.EventSystems;
- public class PlayerController : MonoBehaviour
- {
- #region Private Members
- public Animator _animator;
- public CharacterController _characterController;
- public float Gravity = 14.5f;
- public Vector3 _moveDirection = Vector3.zero;
- private int startHealth;
- private int startFood;
- #endregion
- #region Public Members
- public float Speed = 5.0f;
- public float RotationSpeed = 240.0f;
- public GameObject Hand;
- public float JumpSpeed = 5.00f;
- public float verticalVelocity;
- public int myIndex;
- #endregion
- // Use this for initialization
- public Transform AttachPoint;
- public Transform CharacterAttach;
- public CharacterState currentState { get; set; }
- public CharacterState previusState { get; set; }
- public IdleState Idle { get; protected set; }
- public WalkState WalkState { get; protected set; }
- public JumpState JumpState { get; protected set; }
- public MagicCombatState MagicCombatState { get; protected set; }
- public string currentAnim { get; set; }
- public bool projectileSent { get; set; }
- public string effectName { get; set; }
- public NavMeshAgent navAgent;
- public Transform Destination;
- public Skill skill { get; set; }
- void Start()
- {
- navAgent = GetComponent<NavMeshAgent>();
- GameManager.instance.playerList[myIndex].AddComponent<RFX4_EffectEvent>();
- _animator = GetComponent<Animator>();
- _characterController = GetComponent<CharacterController>();
- Idle = gameObject.AddComponent<IdleState>();
- WalkState = gameObject.AddComponent<WalkState>();
- JumpState = gameObject.AddComponent<JumpState>();
- MagicCombatState = gameObject.AddComponent<MagicCombatState>();
- currentState = Idle;
- currentState.enabled = true;
- }
- #region Inventory
- private int Attack_1_Hash = Animator.StringToHash("Base Layer.Attack_1");
- public bool IsAttacking
- {
- get
- {
- AnimatorStateInfo stateInfo = _animator.GetCurrentAnimatorStateInfo(0);
- if (stateInfo.fullPathHash == Attack_1_Hash)
- {
- return true;
- }
- return false;
- }
- }
- #endregion
- #region Health & Hunger
- [Tooltip("Amount of health")]
- public int Health = 100;
- [Tooltip("Amount of food")]
- public int Food = 100;
- [Tooltip("Rate in seconds in which the hunger increases")]
- public float HungerRate = 0.5f;
- public void IncreaseHunger()
- {
- Food--;
- if (Food < 0)
- Food = 0;
- if (IsDead)
- {
- CancelInvoke();
- _animator.SetTrigger("death");
- }
- }
- public bool IsDead
- {
- get
- {
- return Health == 0 || Food == 0;
- }
- }
- public bool IsArmed
- {
- get
- {
- return false;
- }
- }
- public void Eat(int amount)
- {
- }
- public void Rehab(int amount)
- {
- }
- public void TakeDamage(int amount)
- {
- }
- #endregion
- void FixedUpdate()
- {
- if (!IsDead)
- {
- }
- }
- private bool mIsControlEnabled = true;
- public void EnableControl()
- {
- mIsControlEnabled = true;
- }
- public void DisableControl()
- {
- mIsControlEnabled = false;
- }
- // Update is called once per frame
- private void InitPoitns()
- {
- Transform[] obj = GetComponentsInChildren<Transform>(true);
- foreach (var ob in obj.Where(ob => (ob != transform)))
- {
- if (ob.name == "RightForeArmTwist")
- {
- AttachPoint = ob;
- }
- if (ob.name == "RightShoulder")
- {
- CharacterAttach = ob;
- }
- Debug.Log(ob.name);
- }
- GameManager.instance.playerList[myIndex].GetComponent<RFX4_EffectEvent>().AttachPoint = AttachPoint;
- GameManager.instance.playerList[myIndex].GetComponent<RFX4_EffectEvent>().CharacterAttachPoint = CharacterAttach;
- GameManager.instance.playerList[myIndex].GetComponent<RFX4_EffectEvent>().Effect = Resources.Load("Effect1") as GameObject;
- }
- void Update()
- {
- if(AttachPoint == null)
- {
- InitPoitns();
- }
- if (_animator == null)
- {
- _animator = GetComponent<Animator>();
- _animator.applyRootMotion = true;
- }
- currentState.UpdateState();
- currentState.ProcessInput();
- currentState.MovementMotor();
- if (!IsDead && mIsControlEnabled)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement