Exemple #1
0
    Vector3 GetPatrolPos(AiLevel sb)
    {
        Vector3 pos   = Vector3.zero;
        var     tower = GetEnemyTower();

        if (tower != null)
        {
            switch (sb)
            {
            case AiLevel.Low:
                pos = tower.transform.TransformPoint((tower.GetComponent <TowerState>().patrolPoint.transform.localPosition).normalized * 0.5f);
                break;

            case AiLevel.Mid:
                break;

            case AiLevel.High:
                pos = tower.transform.TransformPoint((tower.GetComponent <TowerState>().patrolPoint.transform.localPosition).normalized * (tower.AttackRange + 0.5f));
                break;

            default:
                break;
            }
        }
        return(pos);
    }
        private void goBtn_Click(object sender, RoutedEventArgs e)
        {
            finalizeships();
            AiLevel currSelectionLevel = (AiLevel)Enum.Parse(typeof(AiLevel), ((string)((ComboBoxItem)levelCBox.SelectedItem).Content).ToUpper());
            int     currSelectionTime  = int.Parse((string)((ComboBoxItem)timerCBox.SelectedItem).Content);

            goToGame(new BoardPlacementData(this.startPageData, aiships, battleships, currSelectionLevel, currSelectionTime));
        }
Exemple #3
0
 void Start()
 {
     level = GameManager.instance.Level;
     for (int i = 0; i < transform.childCount; i++)
     {
         tiles.Add(transform.GetChild(i));
     }
 }
Exemple #4
0
 void Start()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Level = AiLevel.Hard;
         DontDestroyOnLoad(gameObject);
         instance = this;
     }
 }
Exemple #5
0
 void Start()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Level = AiLevel.Hard;
         DontDestroyOnLoad(gameObject);
         instance = this;
     }
 }
Exemple #6
0
 protected override void OnStart()
 {
     mo = SceneMoba3.instance;
     if (mo == null)
     {
         return;
     }
     aiLv      = mo.aiLv;
     myCamp    = thisCs.groupIndex == 1 ? mo.CampBlue : mo.CampRed;
     enemyCamp = thisCs.groupIndex == 1 ? mo.CampRed : mo.CampBlue;
     myHome    = thisCs.groupIndex == 1 ? mo.HomeBlue : mo.HomeRed;
     InitTowers();
     myHomeRadius = myHome.GetComponent <SphereCollider>().radius;
     aiSkillHandler.SetSkills(thisCs.GetSkills());
     OnPlayerAction += this.PlayerAction;
 }
Exemple #7
0
        public int Start(string selected, BoardSize size, AiLevel level, bool first)
        {
            var score = new GameScore();

            do
            {
                var symbol = GetSymbolForPlayer(selected);
                var player = first ? symbol.Item1 : symbol.Item2;

                var game  = new OxGame(size);
                var board = new Board(size);
                var human = new Human(symbol.Item1);
                var ai    = new AI(symbol.Item2, level);

                // game loop
                while (game.GameState == State.Playing)
                {
                    if (player == human.Symbol)
                    {
                        // ตาผู้เล่น
                        game.CheckError(PlayerTurn(game, board, human));
                        player = ChangeTurn(player);
                    }
                    else
                    {
                        // ตา ai
                        game.CheckError(PlayerTurn(game, board, ai));
                        player = ChangeTurn(player);
                    }
                }

                if (game.GameState == State.Win || game.GameState == State.Draw)
                {
                    // นับสถิติการแข่งขัน
                    AddSore(game, score, human, ai);
                }
                else if (game.GameState == State.Error)
                {
                    // แสดงข้อผิดพลาด
                    DisplayError();
                }
            } while (PlayAgain());

            score.Summary();

            return(0);
        }
Exemple #8
0
        /* Wraps around a StartPageData object (adding additional information) */
        public BoardPlacementData(StartPageData startPageData, Ship[] playerShips, Ship[] aiShips, AiLevel level, int idleTime)
        {
            /* Checking nullity and idleTime */
            if (startPageData == null)
            {
                throw new ArgumentException("startPageData cannot be null");
            }
            else if (startPageData == null || startPageData == null)
            {
                throw new ArgumentException("both Ship[] cannot be null");
            }
            else if (idleTime < 1)
            {
                throw new ArgumentException("idleTime should be at least 1");
            }

            /* Verify if both arrays are filled to capacity with Ship objects and deep-copy each Ship at the same time */
            this.playerShips = new Ship[playerShips.Length];
            for (int i = 0; i < playerShips.Length; i++)
            {
                if (playerShips[i] == null)
                {
                    throw new ArgumentException("Ship at " + i + " cannot be null in playerShips");
                }
                /* Deep-copy */
                this.playerShips[i] = new Ship(playerShips[i]);
            }
            this.aiShips = new Ship[aiShips.Length];
            for (int i = 0; i < aiShips.Length; i++)
            {
                if (aiShips[i] == null)
                {
                    throw new ArgumentException("Ship at " + i + " cannot be null in aiShips");
                }
                /* Deep-copy */
                this.aiShips[i] = new Ship(aiShips[i]);
            }

            this.startPageData = startPageData;
            this.level         = level;
            this.idleTime      = idleTime;
        }
Exemple #9
0
        public BoardPlacementData(StartPageData startPageData, Ship[] playerShips, Ship[] aiShips, AiLevel level, int idleTime)
        {
            if (startPageData == null)
            {
                throw new ArgumentException("");
            }
            else if (startPageData == null || startPageData == null)
            {
                throw new ArgumentException("");
            }
            else if (idleTime < 1)
            {
                throw new ArgumentException("");
            }


            this.playerShips = new Ship[playerShips.Length];
            for (int i = 0; i < playerShips.Length; i++)
            {
                if (playerShips[i] == null)
                {
                    throw new ArgumentException("Корабль на " + i + " не может быть null ");
                }

                this.playerShips[i] = new Ship(playerShips[i]);
            }
            this.aiShips = new Ship[aiShips.Length];
            for (int i = 0; i < aiShips.Length; i++)
            {
                if (aiShips[i] == null)
                {
                    throw new ArgumentException("Корабль на " + i + " не может быть null ");
                }

                this.aiShips[i] = new Ship(aiShips[i]);
            }

            this.startPageData = startPageData;
            this.level         = level;
            this.idleTime      = idleTime;
        }
Exemple #10
0
 void Start()
 {
     level = GameManager.instance.Level;
     for (int i = 0; i < transform.childCount; i++)
     {
        tiles.Add(transform.GetChild(i));
     }
 }
Exemple #11
0
 public AI(string symbol, AiLevel level) : base(symbol)
 {
     Level = level;
 }