Esempio n. 1
0
    //Gets the possible targets
    public void GetTargets()
    {
        //Empty Targets
        PossibleTargets.Clear();

        //Fill Possible Targets
        foreach (GameObject Char in BSM.PlayerChars)
        {
            if ((BSM.ThisTurn.Action.MustBeDown == true && Char.GetComponent <BaseCharStateMachine>().Status_Down == true) || BSM.ThisTurn.Action.MustBeDown == false)
            {
                PossibleTargets.Add(Char);
            }
        }

        //If Free-For-All match, Fill in EnemyChars other than this one
        if (BSM.Refferee.MatchType == ReffSM.Type.T_THREAT || BSM.Refferee.MatchType == ReffSM.Type.F_FOURWAY)
        {
            foreach (GameObject Char in BSM.EnemyChars)
            {
                if (Char != Wrestler)
                {
                    if ((BSM.ThisTurn.Action.MustBeDown == true && Char.GetComponent <BaseCharStateMachine>().Status_Down == true) || BSM.ThisTurn.Action.MustBeDown == false)
                    {
                        PossibleTargets.Add(Char);
                    }
                }
            }
        }
    }
Esempio n. 2
0
        public List <Shot> Play()
        {
            bool isHunting = true;
            Shot result;

            while (ShipsDestroyed != Ship.NUM_OF_SHIPS)
            {
                Display.Grid(Board); //DISPLAY PURPOSE
                if (isHunting)
                {
                    result = Hunt();
                    if (result.ShotTypeId == (int)ShotType.Hit)
                    {
                        TargetCoords.Add(new Coordinates {
                            X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault()
                        });
                        isHunting = false;
                    }
                }
                else
                {
                    result = Target();
                    if (result.ShotTypeId != (int)ShotType.Missed)
                    {
                        if (result.ShotTypeId == (int)ShotType.Hit)
                        {
                            TargetCoords.Add(new Coordinates {
                                X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault()
                            });
                        }
                        else if (result.ShotTypeId == (int)ShotType.Destroyed)
                        {
                            isHunting = true;
                            ShipsDestroyed++;
                            TargetDirection   = DirectionTaken.Random;
                            TargetOrientation = Orientation.Random;
                            PossibleTargets.Clear();
                            TargetCoords.Clear();
                        }
                    }
                }

                if (result.ShotTypeId != (int)ShotType.Duplicate)
                {
                    Shots.Add(result);
                    ShotNumber++;
                }
            }
            Console.WriteLine("----------------"); //Display Purpose

            return(Shots);
        }
Esempio n. 3
0
        private Shot Target()
        {
            Shot result = null;

            PossibleTargets.Clear();

            foreach (Coordinates crd in TargetCoords)
            {
                PossibleTargets.AddRange(GetAdjacentTargets(crd, TargetOrientation, TargetDirection));
            }

            int randomIndex = GenerateRandom(0, PossibleTargets.Count);

            result = Board.Grid[PossibleTargets[randomIndex].X, PossibleTargets[randomIndex].Y].Shoot();

            result.ShotId        = Guid.NewGuid();
            result.GameId        = GameGuid;
            result.AIState       = (int)State.Target;
            result.DirectionId   = (int)TargetOrientation;
            result.X             = PossibleTargets[randomIndex].X;
            result.Y             = PossibleTargets[randomIndex].Y;
            result.OrientationId = (int)TargetOrientation;
            result.ShotNumber    = ShotNumber;

            if (TargetOrientation == Orientation.Random && result.ShotTypeId == (int)ShotType.Hit)
            {
                TargetOrientation = FindOrientation(TargetCoords[0], PossibleTargets[randomIndex]);
            }
            else if (TargetOrientation != Orientation.Random && result.ShotTypeId == (int)ShotType.Missed)
            {
                TargetDirection = GetOppositeDirection(FindDirection(TargetOrientation, TargetCoords[0], new Coordinates {
                    X = result.X, Y = result.Y
                }));
            }


            return(result);
        }