コード例 #1
0
        public override void GameUpdate(float dtime)
        {
            base.GameUpdate(dtime);

            //onHitSoundPlayedThisFrame = false;
            UpdatePlaybackCount(dtime, ref onHitSoundCooldown, ref onHitSoundPlaybackCount);
            //UpdatePlaybackCount(ref onKilledSoundCooldown, ref onKilledSoundPlaybackCount);

            if (State == UnitState.RaisableCorpse)
            {
                lookForMainCharTimer -= dtime;
                if (lookForMainCharTimer <= 0)
                {
                    lookForMainCharTimer = 0.5f;
                    var inRange = new List <Destructible>(NearestNeightboursObject.InRange);
                    foreach (var u in inRange)
                    {
                        if (u == Game.Instance.Map.MainCharacter ||
                            u.State == UnitState.RaisingCorpse)
                        {
                            State = UnitState.RaisingCorpse;
                            return;
                        }
                    }
                }
            }
            else if (State == UnitState.RaisingCorpse)
            {
                raiseTimer -= dtime;
                if (raiseTimer <= 0)
                {
                    State = UnitState.Alive;
                    MotionNPC.Pursue(Game.Instance.Map.MainCharacter.MotionObject, 0);
                }
            }
            else if (State == UnitState.Alive)
            {
                if (MotionUnit != null)
                {
                    Running = MotionUnit.RunVelocity.Length() > 0;
                }

                if (!CanControlMovement)
                {
                    return;
                }

                aiState.Update(dtime);

                if (Abilities.Count == 1 && aiState is TryPerformAbility)
                {
                    return;
                }

                aiEvalTimer -= dtime;
                if (aiEvalTimer <= 0)
                {
                    EvaluateAI();
                    aiEvalTimer = 0.5f;
                }
            }
        }
コード例 #2
0
 public void PursueNPC(Common.IMotion.INPC pursuer)
 {
     pursuer.Pursue(npc.MotionObject, 1.5f);
 }