示例#1
0
文件: Actor.cs 项目: ShiJbey/RaidAI
 /// <summary>
 /// Decrements the timer for all active cooldowns on this
 /// actor.
 /// </summary>
 /// <param name="deltaTime"></param>
 public void DecrementSkillCooldowns(float deltaTime)
 {
     // Increment the timers
     for (int i = 0; i < m_skills.Length; i++)
     {
         ActorSkill skill = m_skills[i];
         if (skill.m_cooldown.Active)
         {
             skill.m_cooldown.DecrementCooldown(deltaTime);
         }
     }
 }
示例#2
0
        public override void AgentAction(float[] vectorAction, string textAction)
        {
            // Actions, size = 2
            MoveActor(vectorAction[1]);
            RotateActor(vectorAction[0]);

            if (vectorAction[2] != 0f)
            {
                // if vectorAction[2] == 0 then we dont want to attack
                // so attacks are mapped to the interval [1,infinity)
                int actionIndex = Mathf.RoundToInt(vectorAction[2]) - 1;

                // Check that the skill exists
                if (actionIndex < 0 || actionIndex >= m_skills.Length)
                {
                    // Punish for trying to use a move that doesnt exist
                    AddReward(-0.5f);
                    return;
                }

                ActorSkill skill = m_skills[actionIndex];

                // Check if this action has an active cooldown
                if (skill.m_cooldown.Active)
                {
                    // Punish for trying to use a move that is in cooldown
                    AddReward(-0.3f);
                    return;
                }

                // Perform a boxcast with the hitbox for this skill
                RaycastHit hit;
                bool       hitDetect = Physics.BoxCast(transform.position + skill.m_hitbox.m_centerOffset,
                                                       skill.m_hitbox.m_halfExt, transform.forward, out hit, transform.rotation,
                                                       skill.m_hitbox.m_maxDistance, skill.m_hitbox.GetLayerMask());

                // Create a new hitbox gizmo
                m_activeHitboxes.Add(new HitboxGizmo(hit, skill.m_hitbox));


                if (hitDetect)
                {
                    if (hit.collider.tag == "Boss")
                    {
                        Debug.Log("Attacking boss");
                        hit.collider.GetComponent <BossAgent>().m_health.ApplyDamage(-m_attack.Value);
                        hit.collider.GetComponent <BossAgent>().Aggro = transform;
                        SetReward(1.0f);
                        return;
                    }
                }
            }

            // Rewards
            float distanceToTarget = Vector3.Distance(transform.position,
                                                      m_boss.position);

            // Reached target
            if (distanceToTarget < 2.7f)
            {
                SetReward(1.0f);
                Done();
                return;
            }

            // Fell off platform
            if (transform.position.y < -1f)
            {
                SetReward(-1.0f);
                Done();
                return;
            }

            SetReward(-1.0f);

            // Check if the actor is dead
            if (m_health.Value <= 0.0f)
            {
                SetReward(-1.0f);
                Done();
                return;
            }
        }
示例#3
0
文件: Actor.cs 项目: ShiJbey/RaidAI
 /// <summary>
 /// Activates one of this actor's skills
 /// </summary>
 /// <param name="skill"></param>
 /// <param name="target"></param>
 public void UseSkill(ActorSkill skill, Actor target)
 {
     skill.Activate(this, target);
 }
示例#4
0
文件: Actor.cs 项目: ShiJbey/RaidAI
 /// <summary>
 /// Can this Actor use the given skill
 /// </summary>
 /// <param name="skill"></param>
 /// <returns></returns>
 public bool CanUseSkill(ActorSkill skill)
 {
     return(m_energy.Value >= skill.m_energyCost.Value &&
            m_mana.Value >= skill.m_manaCost.Value);
 }