Ejemplo n.º 1
0
        public override PlanStep DecideWhatToDo()
        {
            //Vector2 PlayerLoc = StealthManager.Instance.PlayerLoc;
            if (HaveConfirmedTile && !WaitingforGoAhead && !HasAPlan)
            {//plan could make enemy face different direction in navigation to player, so shouldn't unconfirm the tile
                if (StealthMethod.CheckLOS(map, Me.TilePosition, StealthManager.Instance.PlayerLoc) &&
                    StealthMethod.CheckFOV(Me.TilePosition, StealthManager.Instance.PlayerLoc, Me.Direction))
                {
                    //player in sight, so move confirmed location to him
                    MoveConfirmedPosition(StealthManager.Instance.PlayerLoc);

                    //All behaviour for when seeing the enemy

                    if (RectMethod.DistanceBetweenLocations
                            (Me.TilePosition, StealthManager.Instance.PlayerLoc) == 1)
                    {
                        return(AttackAdjacentEnemy());
                    }
                    else
                    {
                        return(base.DecideWhatToDo());//act using the usual protocol.
                    }
                }
                //if not in sight, then UNCONFIRM
                else
                {
                    CancelConfirmedPosition();

                    // behaviour for not
                }
            }
            // no confirmed tile, but on alert
            return(base.DecideWhatToDo());
        }
Ejemplo n.º 2
0
        public void MakeSuspiciousOfTile(Vector2 Loc, int HowSuspicious)
        {
            Dictionary <Vector2, int> New = new Dictionary <Vector2, int>
            {
                { Loc, HowSuspicious }
            };

            CurrentSuspicions = StealthMethod.CombineSuspicionLists(CurrentSuspicions, New);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates suspicions without applying any effect of time passing, like decaying anything. Just uses currentsuspicions again to recalc alertpoints.
        /// </summary>
        private void UpdateSuspicionsLite()
        {
            AlertPoints = StealthMethod.TallyTotalSuspicion(CurrentSuspicions);
            AlertLevel  = AlertPoints / AlertPointsPerLevel;
            AlertPoints = AlertPoints % AlertPointsPerLevel;

            if (AlertLevel > 3)
            {
                AlertPoints = AlertPointsPerLevel - 1;
                AlertLevel  = 3;
            }
        }
Ejemplo n.º 4
0
 public override void End()
 {
     // run the ConfirmationCheck now!
     if (signalreturn.AttemptPlayerConfirmation(out Vector2 playerLoc))
     {
         signalreturn.ConfirmEnemyLocation(playerLoc);
     }
     else
     {
         //disperse every suspicious tile you can currently see.
         Dictionary <Vector2, int> CandidatesToDisperse = Me.CurrentSuspicions;
         CandidatesToDisperse = ListMethod.FilterFarAway(CandidatesToDisperse, signalreturn.MaxConfirmDistance, Me.TilePosition);
         CandidatesToDisperse = StealthMethod.MassCheckLineOfSight(mapRef, Me.TilePosition, Me.Direction, CandidatesToDisperse);
         ///for those tiles in range, dissipate suspicion
         foreach (Vector2 LocToDisperse in CandidatesToDisperse.Keys)
         {
             signalreturn.DissipateSuspicion(LocToDisperse);
         }
     }
 }
Ejemplo n.º 5
0
        public void UpdateSuspicions(GameTime gameTime)
        {
            Dictionary <Vector2, int> NewSuspicions = new Dictionary <Vector2, int>();

            if (IsInRoom)
            {
                foreach (KeyValuePair <Vector2, int> I in StealthManager.Instance.RoomSuspiciousPointsThisPass[CurrentRoomIn])
                {
                    NewSuspicions.Add(I.Key, I.Value);
                }
                foreach (Room.EntryPoint E in mapRef.Rooms[CurrentRoomIn].EntryPoints)
                {
                    foreach (KeyValuePair <Vector2, int> S in StealthManager.Instance.PassageSuspiciousPointsThisPass[E.PassagewayUsing])
                    {
                        NewSuspicions.Add(S.Key, S.Value / 2);
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <Vector2, int> I in StealthManager.Instance.PassageSuspiciousPointsThisPass[CurrentPassagewayIn])
                {
                    NewSuspicions.Add(I.Key, I.Value);
                }
                //the room at one end of a passage
                foreach (KeyValuePair <Vector2, int> S in StealthManager.Instance.RoomSuspiciousPointsThisPass[mapRef.Passages[CurrentPassagewayIn].End1.EndPointID])
                {
                    NewSuspicions.Add(S.Key, (3 * S.Value) / 4);
                }
                foreach (KeyValuePair <Vector2, int> S in StealthManager.Instance.RoomSuspiciousPointsThisPass[mapRef.Passages[CurrentPassagewayIn].End2.EndPointID])
                {
                    NewSuspicions.Add(S.Key, (3 * S.Value) / 4);
                }
            }


            //Apply all Suspicious Activities and Noises in the room you are currently in to the suspicious points.

            //run L.O.S checks on these suspicious things to "thin down the herd"
            NewSuspicions = StealthMethod.MassCheckLineOfSight(mapRef, TilePosition, this.Direction, NewSuspicions);
            //now add the Noises by adding a few random tiles in the noise range to the suspicious points.
            NewSuspicions    = StealthMethod.TemperSuspicionsByDistance(NewSuspicions, TilePosition);
            RecentSuspicions = NewSuspicions;

            /*foreach (KeyValuePair<Rectangle, int> Noise in StealthManager.Instance.Noises)
             * {
             *  int NoiseX = mapRef.D.Next(Noise.Key.X, Noise.Key.Right);
             *  int NoiseY = mapRef.D.Next(Noise.Key.Y, Noise.Key.Bottom);
             *  StealthMethod.AddNewSuspiciousness(ref NewSuspicions, new Vector2(NoiseX, NoiseY), Noise.Value);
             * }
             */
            if (CurrentSuspicions.Count > 0 || NewSuspicions.Count > 0)
            {
                double elapsed_time_seconds = gameTime.ElapsedGameTime.TotalSeconds;
                Dictionary <Vector2, int> CommonSuspicions = StealthMethod.TallyAndDecaySuspicionInLists
                                                                 (NewSuspicions, CurrentSuspicions,
                                                                 out Dictionary <Vector2, int> OnlyOldSuspicions, AlertDecayHalfLife, elapsed_time_seconds);

                //Decrement points that haven't been topped up since last Update - carried out in above process.
                CurrentSuspicions = StealthMethod.CombineSuspicionLists(OnlyOldSuspicions, CommonSuspicions);
                //Calculate new Suspicion Level.
                AlertPoints = StealthMethod.TallyTotalSuspicion(CurrentSuspicions);
                AlertLevel  = AlertPoints / AlertPointsPerLevel;
                AlertPoints = AlertPoints % AlertPointsPerLevel;

                if (AlertLevel > 3)
                {
                    AlertPoints = AlertPointsPerLevel - 1;
                    AlertLevel  = 3;
                }
            }
        }