private bool SkillNeedMoveToFirst(CmdSkill skillCmd, Skill skill)
        {
            float num = -1f;

            if (skill.needTarget)
            {
                Units targetUnits = skillCmd.targetUnits;
                num = Vector3.Distance(this.self.mTransform.position, targetUnits.mTransform.position);
            }
            else if (skill.data.skillCastingType == 2 && !skill.data.isMoveSkill)
            {
                Vector3 targetPos = skillCmd.targetPos;
                num = Vector3.Distance(this.self.mTransform.position, targetPos);
            }
            float num2;

            if (skill.IsAttack)
            {
                num2 = this.self.GetAttackRange(skillCmd.targetUnits);
            }
            else
            {
                num2 = skill.distance;
            }
            return(num != -1f && num > num2);
        }
Exemple #2
0
        public override void OnInit()
        {
            this.m_preloadCmdMove       = new CmdMove();
            this.m_preloadCmdSkill      = new CmdSkill();
            this.m_cmdRunningController = this.self.mCmdRunningController;
            VTrigger item = TriggerManager.CreateUnitEventTrigger(UnitEvent.UnitDeath, null, new TriggerAction(this.OnUnitDeath), this.self.unique_id);

            this.listTrigger.Add(item);
        }
 private void StopMoveAndSkillCoroutinue()
 {
     if (this.skillTask != null)
     {
         this.m_CoroutineManager.StopCoroutine(this.skillTask);
         this.skillTask      = null;
         this.m_cmdTaskSkill = null;
     }
 }
        public bool CanSkill(CmdSkill cmdSkill)
        {
            if (this.m_cmdRunningSkill != null)
            {
                this.m_cmdRunningSkill.TryDesert();
            }
            Skill skillOrAttackById = this.self.getSkillOrAttackById(cmdSkill.skillMainID);

            return((this.self.CanSkill || skillOrAttackById.CheckSkillCanUseSpecial) && ((this.m_cmdRunningSkill.skillState != CmdRunningSkill.CmdRunningSkillState.ready && this.m_cmdRunningSkill.skillState != CmdRunningSkill.CmdRunningSkillState.start) || this.m_cmdRunningSkill.skill.data.CanBeInterruptInCastManual));
        }
 private void AssignSkillTargetPosition(CmdSkill skillCmd, Skill skill)
 {
     if (!skill.needTarget && skill.data.skillCastingType == 2 && skill.data.isMoveSkill)
     {
         float num = Vector3.Distance(this.self.mTransform.position, skillCmd.targetPos);
         if (num > skill.distance)
         {
             num = skill.distance;
         }
         Vector3 a = skillCmd.targetPos - this.self.mTransform.position;
         a.Normalize();
         skillCmd.targetPos = this.self.mTransform.position + a * num;
     }
 }
        private void RunSkillCmd(CmdBase cmd)
        {
            CmdSkill cmdSkill          = cmd as CmdSkill;
            Skill    skillOrAttackById = this.self.getSkillOrAttackById(cmdSkill.skillMainID);

            if (this.m_cmdRunningSkill != null && this.m_cmdRunningSkill.IsAlreadyRunning(cmdSkill))
            {
                return;
            }
            if (skillOrAttackById.needTarget)
            {
                if (cmdSkill.targetUnits == null || !cmdSkill.targetUnits.isLive)
                {
                    return;
                }
                if (!cmdSkill.targetUnits.CanBeSelected)
                {
                    return;
                }
            }
            if (this.skillTask != null && skillOrAttackById.needTarget)
            {
                if (cmdSkill == null || this.m_cmdTaskSkill == null)
                {
                    return;
                }
                if (cmdSkill.targetUnits != null && !cmdSkill.targetUnits.CanBeSelected)
                {
                    return;
                }
                if (cmdSkill.skillMainID == this.m_cmdTaskSkill.skillMainID && cmdSkill.targetUnits == this.m_cmdTaskSkill.targetUnits)
                {
                    return;
                }
            }
            this.StopMoveAndSkillCoroutinue();
            if (this.SkillNeedMoveToFirst(cmdSkill, skillOrAttackById))
            {
                this.SetSkillTask(cmdSkill);
                this.m_cmdRunningMove.SetMoving(cmdSkill.targetPos);
                this.skillTask = this.m_CoroutineManager.StartCoroutine(this.MoveAndSkillCoroutinue(cmdSkill), true);
            }
            else
            {
                this.AssignSkillTargetPosition(cmdSkill, skillOrAttackById);
                this.LaunchSkill(cmdSkill);
            }
        }
Exemple #7
0
        private bool CanSkill(CmdBase cmd)
        {
            CmdSkill cmdSkill = cmd as CmdSkill;

            if (cmdSkill.skill.IsSkill)
            {
                if (this.m_cmdRunningController.CanSkill(cmdSkill))
                {
                    return(true);
                }
            }
            else if (this.m_cmdRunningController.CanAttack(cmdSkill))
            {
                return(true);
            }
            return(false);
        }
Exemple #8
0
        public void EnqueueSkillCmd(string skillID, Vector3 targetPos, Units targetUnits, bool exeImmediate = true, bool isCrazyMode = true)
        {
            if (!this.DoExtraActionFirst(skillID))
            {
                return;
            }
            Skill skillOrAttackById = this.self.getSkillOrAttackById(skillID);

            if (skillOrAttackById.needTarget)
            {
                if ((targetUnits == null || !targetUnits.isLive) && skillOrAttackById.IsAttack)
                {
                    return;
                }
                if (targetUnits == null || !targetUnits.isLive)
                {
                    UIMessageBox.ShowMessage("未选择目标,不能释放!", 1.5f, 0);
                    return;
                }
                this.self.SetSelectTarget(targetUnits);
                PlayerControlMgr.Instance.SetSelectedTarget(targetUnits);
            }
            if (Singleton <PvpManager> .Instance.IsInPvp)
            {
                this.SendUseSkill(skillID, targetUnits, targetPos, isCrazyMode);
                NewbieManager.Instance.TryHandleNotifyServerUseSkill();
            }
            else
            {
                CmdSkill cmdSkill = new CmdSkill();
                this.m_cmdReady      = cmdSkill;
                cmdSkill.skillMainID = skillID;
                cmdSkill.targetPos   = targetPos;
                cmdSkill.targetUnits = targetUnits;
                cmdSkill.skill       = skillOrAttackById;
                if (exeImmediate)
                {
                    this.doCacheCmd();
                }
            }
        }
        private void LaunchSkill(CmdSkill skillCmd)
        {
            Skill skill = this.self.getSkillById(skillCmd.skillMainID);

            if (skill == null)
            {
                skill = this.self.getAttackById(skillCmd.skillMainID);
            }
            if (this.m_cmdRunningSkill.skill != null && !this.m_cmdRunningSkill.skill.data.CanBeInterruptInCastManual)
            {
                this.m_cmdRunningSkill.skill.InterruptEndTask();
            }
            this.m_cmdRunningSkill.SetSkillState(CmdRunningSkill.CmdRunningSkillState.ready);
            this.m_cmdRunningSkill.skill = skill;
            this.m_cmdRunningSkill.SetTargets(skillCmd.targetUnits, skillCmd.targetPos);
            if (this.m_cmdRunningMove.isMoving && !skill.data.isCanMoveInSkillCastin)
            {
                this.m_moveController.StopMoveForSkill();
                if (skill.data.continueMoveAfterSkillEnd)
                {
                    this.m_cmdRunningMove.Finish(true);
                }
                else
                {
                    this.m_cmdRunningMove.Finish(false);
                }
            }
            if (skill.IsAttack)
            {
                this.self.ComboAttack(skillCmd.targetUnits);
            }
            else
            {
                this.self.Conjure(skillCmd.skillMainID, skillCmd.targetUnits, new Vector3?(skillCmd.targetPos));
            }
            this.m_lastCmd = skillCmd;
        }
 public bool CanAttack(CmdSkill cmdSkill)
 {
     if (this.m_cmdRunningSkill != null)
     {
         this.m_cmdRunningSkill.TryDesert();
     }
     if (!this.self.CanAttack)
     {
         if (this.m_cmdRunningMove.isMoving)
         {
             this.m_moveController.StopMoveForSkill();
             this.m_cmdRunningMove.Finish(false);
         }
         if (cmdSkill.targetUnits != null)
         {
             this.self.moveController.TurnToTarget(new Vector3?(cmdSkill.targetUnits.mTransform.position), false, false, 0f);
         }
     }
     if (this.m_cmdRunningSkill != null && this.m_cmdRunningSkill.skill != null && this.m_cmdRunningSkill.skill.IsSkill)
     {
         return((this.m_cmdRunningSkill.skillState != CmdRunningSkill.CmdRunningSkillState.ready && this.m_cmdRunningSkill.skillState != CmdRunningSkill.CmdRunningSkillState.start) || this.m_cmdRunningSkill.skill.data.CanBeInterruptInCastManual);
     }
     return((this.m_cmdRunningSkill.skillState != CmdRunningSkill.CmdRunningSkillState.ready && this.m_cmdRunningSkill.skillState != CmdRunningSkill.CmdRunningSkillState.start && this.m_cmdRunningSkill.skillState != CmdRunningSkill.CmdRunningSkillState.end) || this.m_cmdRunningSkill.skill.data.CanBeInterruptInCastManual || (this.m_cmdRunningSkill.skill.IsAttack && this.m_cmdRunningSkill.skillState == CmdRunningSkill.CmdRunningSkillState.ready));
 }
 public bool IsAlreadyRunning(CmdSkill skillCmd)
 {
     return(this.skill != null && (this.skillState == CmdRunningSkill.CmdRunningSkillState.ready && this.skill.data.skillId == skillCmd.skillMainID));
 }
 private IEnumerator MoveAndSkillCoroutinue(CmdSkill skillCmd)
 {
     CmdRunningController.< MoveAndSkillCoroutinue > c__Iterator34 <MoveAndSkillCoroutinue> c__Iterator = new CmdRunningController.< MoveAndSkillCoroutinue > c__Iterator34();