示例#1
0
        public void selectTile()
        {
            Cursor c = currentCursor.GetComponent <Cursor> ();

            if (!selected)
            {
                TileStack ts = gameMap.GetComponent <BoardMap> ().getTile(c.getX(), c.getY()).GetComponent <TileStack> ();
                if (ts.getHeight() != 1 || ts.getPlayer() != null)
                {
                    if (ts.getPlayer() == null || ts.getPlayer().GetComponent <Player> ().getTeam() == c.getTeam())
                    {
                        selectX  = c.getX();
                        selectY  = c.getY();
                        selected = true;

                        newNeutralCursor(c.getX(), c.getY(), c.getTeam());
                    }
                }
            }
            else
            {
                BoardMap bm = gameMap.GetComponent <BoardMap> ();
                Deselect();
                if (bm.Move(bm.getTile(selectX, selectY), bm.getTile(c.getX(), c.getY())))
                {
                    newCursor(c.getX(), c.getY(), !c.getTeam());
                }
            }
        }
示例#2
0
        public bool Move(TileStack src, TileStack dest)
        {
            //is source player if yes check if dest is legal Move
            //if yes player.src = false, dest.player = true
            //
            //if source or dest is a Source of water (source) return false
            //
            if (src.GetSource() == true || dest.GetSource() == true)
            {
                return(false);
            }
            if (CompareDistance(src, dest) > 1)
            {
                return(false);
            }
            else if (src.GetPlayer() != null)
            {
                if (dest.GetWater() == true)
                {
                    return(false);
                }
                else
                {
                    dest.SetPlayer(src.GetPlayer());
                    src.SetPlayer(null);
                    //animate
                }
            }
            else
            {
                src.Lower();
                dest.Raise();
            }


            return(true);
        }
示例#3
0
        public bool Move(GameObject src, GameObject dest)
        {
            //is source player if yes check if dest is legal Move
            //if yes player.src = false, dest.player = true
            //
            //if source or dest is a Source of water (source) return false
            //
            int x, y;

            x = 0;
            y = 0;
            TileStack srcStack  = src.GetComponent <TileStack> ();
            TileStack destStack = dest.GetComponent <TileStack> ();

            if (src.Equals(lastMoveDest) && dest.Equals(lastMoveSrc))
            {
                return(false);
            }

            if (srcStack.getSource() == true || destStack.getSource() == true)
            {
                return(false);
            }

            if (CompareDistance(src, dest) > 1)
            {
                return(false);
            }

            if (srcStack.getPlayer() != null)
            {
                if (destStack.getWater() == true)
                {
                    return(false);
                }
                if (destStack.getPlayer() != null)
                {
                    return(false);
                }
                if (srcStack.getPlayer().GetComponent <Player> ().getTeam() != GameController.instance.teamTurn)
                {
                    return(false);
                }

                if (srcStack.getPlayer().GetComponent <Player>().getTeam() == false)
                {
                    findPos(dest, out x, out y);
                    GameController.instance.newBluePlayer(x, y);
                }
                else
                {
                    findPos(dest, out x, out y);
                    GameController.instance.newRedPlayer(x, y);
                }
                src.GetComponent <TileStack>().setPlayer(null);
            }
            else
            {
                if (src.Equals(dest))
                {
                    return(false);
                }
                if (srcStack.getHeight() == 1)
                {
                    return(false);
                }
                if (destStack.getHeight() == 6)
                {
                    return(false);
                }
                lower(src);
                raise(dest, GameController.instance.teamTurn);
            }


            lastMoveSrc  = src;
            lastMoveDest = dest;
            return(true);
        }
示例#4
0
 public int CompareDistance(TileStack src, TileStack dest)
 {
     return(1);
 }
示例#5
0
 public int CompareHeight(TileStack src, TileStack dest)
 {
     return(src.GetHeight() - dest.GetHeight());
 }
示例#6
0
 public void Lower(TileStack tile)
 {
     tile.Lower();
 }
示例#7
0
 public void Raise(TileStack tile)
 {
     tile.Raise();
 }