Beispiel #1
0
        // Start is called before the first frame update
        void Start()
        {
            QualitySettings.vSyncCount  = 0;
            Application.targetFrameRate = 60;

            m_CalculatedPath = new NavMeshPath();

            m_Agent    = GetComponent <NavMeshAgent>();
            m_Animator = GetComponentInChildren <Animator>();

            Speed                = 0f;
            m_Agent.speed        = Speed;
            m_Agent.angularSpeed = 360.0f;

            m_LastRaycastResult = transform.position;

            m_SpeedParamID   = Animator.StringToHash("Speed");
            m_AttackParamID  = Animator.StringToHash("Attack");
            m_HitParamID     = Animator.StringToHash("Hit");
            m_FaintParamID   = Animator.StringToHash("Faint");
            m_RespawnParamID = Animator.StringToHash("Respawn");

            m_CharacterData = GetComponent <CharacterData>();

            m_CharacterData.Equipment.OnEquiped += item =>
            {
                if (item.Slot == (EquipmentItem.EquipmentSlot) 666)
                {
                    var obj = Instantiate(item.WorldObjectPrefab, WeaponLocator, false);
                    Helpers.RecursiveLayerChange(obj.transform, LayerMask.NameToLayer("PlayerEquipment"));
                }
            };

            m_CharacterData.Equipment.OnUnequip += item =>
            {
                if (item.Slot == (EquipmentItem.EquipmentSlot) 666)
                {
                    foreach (Transform t in WeaponLocator)
                    {
                        Destroy(t.gameObject);
                    }
                }
            };

            m_CharacterData.Init();

            m_InteractableLayer = 1 << LayerMask.NameToLayer("Interactable");
            m_LevelLayer        = 1 << LayerMask.NameToLayer("Level");
            m_TargetLayer       = 1 << LayerMask.NameToLayer("Target");

            m_CurrentState = State.DEFAULT;

            m_CharacterAudio = GetComponent <CharacterAudio>();

            m_CharacterData.OnDamage += () =>
            {
                m_Animator.SetTrigger(m_HitParamID);
                m_CharacterAudio.Hit(transform.position);
            };
        }
Beispiel #2
0
        // Start is called before the first frame update
        void Start()
        {
            m_Animator = GetComponentInChildren <Animator>();
            m_Agent    = GetComponent <NavMeshAgent>();

            m_SpeedAnimHash  = Animator.StringToHash("Speed");
            m_AttackAnimHash = Animator.StringToHash("Attack");
            m_DeathAnimHash  = Animator.StringToHash("Death");
            m_HitAnimHash    = Animator.StringToHash("Hit");

            m_CharacterData = GetComponent <CharacterData>();
            m_CharacterData.Init();

            m_CharacterAudio = GetComponentInChildren <CharacterAudio>();

            m_CharacterData.OnDamage += () =>
            {
                m_Animator.SetTrigger(m_HitAnimHash);
                m_CharacterAudio.Hit(transform.position);
            };

            m_Agent.speed    = Speed;
            m_LootSpawner    = GetComponent <LootSpawner>();
            m_StartingAnchor = transform.position;
        }