示例#1
0
        private bool UpdateSkillUsing(float distance)
        {
            if (skillCD > 0)
            {
                return(false);
            }
            if (distance > mWeapon.optimalDistance)
            {
                return(false);
            }
            if (m_Skills && m_CurrentSkills != null)
            {
                if (m_CurrentSkills.Count > 0)
                {
                    //int slot = m_SlotsWithSkills.AnyElement();
                    int skill = m_CurrentSkills.AnyElement();
                    int slot  = m_Skills.GetSlotBySkillId(skill);

                    if (slot >= 0)
                    {
                        var skillObj = m_Skills.GetSkillById(skill);
                        if (skillObj != null)
                        {
                            if (skillObj.ready && skillObj.energyOk)
                            {
                                if (m_Skills.UseSkill(slot, mTarget.targetObject))
                                {
                                    skillCD = skillObj.data.Cooldown;
                                    //log.InfoFormat("NPC used skill = {0}".Color(LogColor.orange), skillObj.data.Id.ToString("X8"));
                                    //log.InfoFormat("npc successfully used skill  at slot = {0}, energy = {1}".Color(LogColor.orange), slot, GetComponent<ShipEnergyBlock>().currentEnergy);
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }