Ejemplo n.º 1
0
        private void Update()
        {
            //Player input
            moveInputHorizontal = Input.GetAxisRaw("Horizontal");
            moveInputVertical   = Input.GetAxisRaw("Vertical");

            //Next Spell activate
            if (Input.GetKeyDown(KeyCode.Q))
            {
                //Event Invoke => CharacterStats (SetNextAbilityListener)
                if (changeMePls != null)
                {
                    changeMePls.Invoke(true);
                }

                //Check for new Spell
                heroAttack = stats.GetCurrentSkill().itemDefinition.attackDefinition1;
            }

            //Calculating attack Rate Test
            float timeSinceLastAttack = Time.time - timeOfHeroLastAttack;
            bool  attackOnCooldown    = timeSinceLastAttack < heroAttack.Cooldown;

            //Do attack
            if (!attackOnCooldown && Input.GetKeyDown(KeyCode.Space))
            {
                agent.isStopped      = true;
                timeOfHeroLastAttack = Time.time;

                //Call the attack animation
                anim.SetTrigger("isAttack");
            }
        }
Ejemplo n.º 2
0
 public void IhearAboutIt(bool isSkillChanged)
 {
     if (isSkillChanged)
     {
         heroAttack = stats.GetCurrentSkill().itemDefinition.attackDefinition1;
     }
 }
Ejemplo n.º 3
0
        private void Start()
        {
            //Get ref
            stats = GetComponent <CharacterStats>();
            agent = GetComponent <NavMeshAgent>();
            rbody = GetComponent <Rigidbody>();
            anim  = GetComponent <Animator>();

            //Initialize Spell slot with current Spell in CharacterStats_SO
            heroAttack = stats.GetCurrentSkill().itemDefinition.attackDefinition1;

            //Add listener to ChangeMePls Event (SetNextAbilityListener)
            changeMePls.AddListener(stats.SetNextAbilityListener);
            stats.characterDefinition.skillIsChangedByPickUpItem.AddListener(IhearAboutIt);

            //agent.updateRotation = false;
            timeOfHeroLastAttack = float.MinValue;
        }