Exemple #1
0
 public void Follow(VanillaCharacter charac, float distMax = Cst.CUBE_SIDE * 3)
 {
     this.mYawGoal = this.GetYaw();
     this.mForcedDestination.Clear();
     this.mFollow            = charac;
     this.mStaySqrDistToGoal = distMax * distMax;
 }
Exemple #2
0
        public void Update(float frameTime)
        {
            foreach (List <VanillaCharacter> characList in this.mCharacters)
            {
                List <VanillaCharacter> needToRemove = new List <VanillaCharacter>();
                for (int i = 0; i < characList.Count; i++)
                {
                    if (characList[i].WaitForRemove)
                    {
                        if (characList[i] is VanillaPlayer)
                        {
                            this.mStateMgr.RequestStatePush(typeof(DeathMenuState));
                        }
                        else
                        {
                            VanillaCharacter charac = characList[i];
                            needToRemove.Add(charac);
                            this.mStateMgr.MainState.User.RemoveSelectedAlly((VanillaNonPlayer)charac);
                            charac.Dispose();
                            continue;
                        }
                    }
                    characList[i].Update(frameTime);
                }

                foreach (VanillaCharacter charac in needToRemove)
                {
                    characList.Remove(charac);
                }
            }
        }
Exemple #3
0
        public CollisionMgr(API.Geo.World world, VanillaCharacter charac)
        {
            this.mWorld       = world;
            this.mCharac      = charac;
            this.mNbrHitStage = 2 + (int)charac.Size.y / Cst.CUBE_SIDE;

            this.mHitRadius  = charac.Size.x / 2 * COL_SIDE_MARGE;
            this.mHitDegrees = new Degree[NBR_HIT_POINTS];
            Degree delta = 360 / this.mHitDegrees.Length;

            for (int i = 0; i < this.mHitDegrees.Length; i++)
            {
                this.mHitDegrees[i] = i * delta;
            }
        }
Exemple #4
0
        public void MoveTo(Vector3 destination, float stayAtDist = 0)
        {
            Vector3 diff = destination - this.FeetPosition;

            if (diff.x * diff.x + diff.z * diff.z < SQUARED_DIST_PRECISION + stayAtDist * stayAtDist || MainWorld.AbsToRelative(destination) == this.BlockPosition)
            {
                return;
            }

            this.mStaySqrDistToGoal = stayAtDist * stayAtDist;

            /* Disable the previous orders */
            this.mFollow  = null;
            this.mYawGoal = this.GetYaw();

            this.FindPathTo(destination);
        }
        public override void updateTargets()
        {
            float actTargetDistance = this.Target != null ? (this.Target.FeetPosition - this.FeetPosition).Length : LIMIT_TARGET_DISTANCE + 1;

            this.Target = null;
            foreach (Faction faction in Enum.GetValues(typeof(Faction)).Cast <Faction>().Where(faction => faction != this.mCharInfo.Faction))
            {
                foreach (VanillaCharacter ennemy in this.mCharacMgr.GetFactionCharacters(faction))
                {
                    Vector3 diff     = ennemy.FeetPosition - this.FeetPosition;
                    float   distance = diff.Length;
                    if (distance < actTargetDistance && distance < LIMIT_TARGET_DISTANCE && System.Math.Abs(diff.y / Cst.CUBE_SIDE) <= 6)
                    {
                        this.Target = ennemy;
                    }
                }
            }

            base.updateTargets();
        }
Exemple #6
0
        public void Hit(float damage, VanillaCharacter source = null)
        {
            if (this.mCharInfo.Life <= 0 || damage <= 0)
            {
                return;
            }
            this.mCharInfo.Life -= damage;

            if (this.mCharInfo.IsPlayer)
            {
                if (this.mCharacMgr.StateMgr.Controller.GamePadState.IsConnected)
                {
                    float force = (damage + 15) / VanillaPlayer.DEFAULT_PLAYER_LIFE * 7;
                    this.mCharacMgr.StateMgr.Controller.Vibrate(force, force, 0.2f);
                }
                ((PlayerRTS)this.mCharInfo.RTS).UpdateLife();
            }

            if (this.mCharInfo.Life <= 0)
            {
                this.MovementInfo.IsJumping = false;
                this.MovementInfo.IsPushedByArcaneLevitator = false;

                // Don't remove the charac right now to play the animation
                if (!this.mCharInfo.IsPlayer)
                {
                    ((Robot)this.mMesh).Die();
                }
                else
                {
                    this.WaitForRemove = true;
                }
            }
            else if (!this.Info.IsPlayer && ((VanillaNonPlayer)this).Target == null && !this.MovementInfo.IsMovementForced &&
                     this.mFollow == null && source != null)
            {
                ((VanillaNonPlayer)this).SetTargetAndFollow(source);
            }
        }
 public void SetTargetAndFollow(VanillaCharacter ennemy)
 {
     this.Target = ennemy;
     this.Follow(ennemy, Cst.CUBE_SIDE * 15);
 }
Exemple #8
0
 public bool IsFollowingCharac(VanillaCharacter charac)
 {
     return(this.mFollow == charac);
 }
Exemple #9
0
 public void StopFollowing()
 {
     this.mFollow  = null;
     this.mYawGoal = this.GetYaw();
     this.mForcedDestination.Clear();
 }