コード例 #1
0
    /// <summary>
    /// 战斗主循环
    /// </summary>
    public void Update()
    {
        float delta = Time.deltaTime;

        for (int idx = 0; idx < AllFighters.Count; ++idx)
        {
            FightUnit unit = AllFighters[idx];

            //自动放大招,写在外面防止被暂停
            if (!FightPause)
            {
                if (!unit.IsDead && (unit.IsEnemy || unit.IsSummon || (!unit.IsEnemy && FightLogic.Instance.IsAutoFight)))
                {
                    if (unit.State != FightUnitState.Skill || unit.SklState == SkillState.Post)
                    {
                        unit.UseActiveSkill();
                    }
                }
            }

            if (UnitPause && !unit.IsUsingActiveSkill && !unit.SkillMgrObj.IsWaitActiveSkill())
            {
                continue;
            }
            unit.Update(delta);
        }

        //子弹、特效和View都在内部判断暂停
        BulletMgrObj.UpdateBullet(delta);
        EffectMgr.Instance.Update(delta);
        DropMgrObj.Update();    //不需要暂停

        //游戏超时,判输
        if (!FightPause && (State == FightState.Fight || State == FightState.Prepare))
        {
            this.AccRoundTime += delta;
            if (AccRoundTime >= RoundTime)
            {
                //战斗超时,判输
                _terminate(false);
            }
        }
    }