Esempio n. 1
0
        public void init()
        {
            GameConfigure gameConfigure = GameConfigure.instance;

            builderDic    = gameConfigure.buildLibrary.builderList.ToDictionary(t => t.buildType);
            buildMoneyDic = gameConfigure.buildLibrary.builderList.ToDictionary(t => t.buildType, t => t.money);

            land = new Land(gameConfigure.landColumn, gameConfigure.landRow);
            land.init(gameObject.transform);

            initTeam();

            buildPanel = new BuildPanel();
            buildPanel.init();

            resourcePanel = new ResourcePanel();
            resourcePanel.init();
        }
Esempio n. 2
0
        public void showMoveable()
        {
            Land land = Game.instance.land;

            Tile[, ] tiles = land.tiles;
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    if (x + i < 0 || x + i >= land.column || z + j < 0 || z + j >= land.row || (i == 0 & j == 0))
                    {
                        continue;
                    }
                    Tile tile = tiles[x + i, z + j];
                    moveableTileList.Add(tile);
                    tile.enableMove();
                }
            }
        }
Esempio n. 3
0
        public void autoRun()
        {
            clean();
            //查找当前可攻击的
            showAttackable();
            if (attackablePlayerList != null)
            {
                attack(attackablePlayerList[0]);
            }
            else
            {
                showMoveable();

                //查找远处可攻击的
                //向远处可攻击移动
                Land land = Game.instance.land;
                for (int circle = 2; circle < Mathf.Max(land.column, land.row); circle++)
                {
                    for (int i = -circle; i < circle; i++)
                    {
                        for (int j = -circle; j < circle; j++)
                        {
                            if (x + i < 0 || x + i >= land.column || z + j < 0 || z + j >= land.row || (i == 0 & j == 0))
                            {
                                continue;
                            }

                            Player targetPlayer = Tool.findPlayer(x + i, z + j);
                            if (targetPlayer != null && targetPlayer.team != team)
                            {
                                Tile tile = getShortestDistanceTile(targetPlayer);
                                move(tile);
                                return;
                            }
                        }
                    }
                }
                move(moveableTileList[0]);
            }
            state = PlayerState.Finish;
        }
Esempio n. 4
0
        public void showAttackable()
        {
            Land land = Game.instance.land;

            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    if (x + i < 0 || x + i >= land.column || z + j < 0 || z + j >= land.row || (i == 0 & j == 0))
                    {
                        continue;
                    }
                    Player targetPlayer = Tool.findPlayer(x + i, z + j);
                    if (targetPlayer != null && team != targetPlayer.team)
                    {
                        targetPlayer.enableAttack();
                        attackablePlayerList.Add(targetPlayer);
                    }
                }
            }
        }