示例#1
0
文件: Tile.cs 项目: RyuK-H/20111630
    public void Init(Vector3 _pos, TILE_TYPE _type)
    {
        Rend = this.gameObject.GetComponent <Renderer>();

        Set_Tile_Type(_type);
        Set_Tile_Pos(_pos);
    }
示例#2
0
 // This is not fully tested and probably doesn't work in all cases.
 public void ShowEmpty()
 {
     gameObject.SetActive(false);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(false);
     tileType = LibrettoTile.TILE_TYPE.EMPTY;
 }
示例#3
0
    public void CreateStage()
    {
        tileSize         = prefabs[0].GetComponent <SpriteRenderer>().bounds.size.x;
        centerPosition.x = (tileList.GetLength(0) / 2) * tileSize;
        centerPosition.y = (tileList.GetLength(1) / 2) * tileSize;

        for (int y = 0; y < tileList.GetLength(1); y++)
        {
            for (int x = 0; x < tileList.GetLength(0); x++)
            {
                Vector2Int position = new Vector2Int(x, y);

                GameObject ground = Instantiate(prefabs[(int)TILE_TYPE.GROUND]);
                ground.transform.position = GetScreenPositionFromTileList(position);

                TILE_TYPE  tileType = tileList[x, y];
                GameObject obj      = Instantiate(prefabs[(int)tileType]);
                obj.transform.position = GetScreenPositionFromTileList(position);
                if (tileType == TILE_TYPE.PLAYER)
                {
                    playerManager = obj.GetComponent <PlayerManager>();
                    moveObjPositionOnTile.Add(obj, position);
                }
                if (tileType == TILE_TYPE.BLOCK)
                {
                    moveObjPositionOnTile.Add(obj, position);
                    blockCount++;
                    //Debug.Log("block : " + blockCount);
                }
            }
        }
    }
示例#4
0
 public void CopyTileInfo(MapTile tile)
 {
     //tileValue = tile.tileValue;
     myTileType            = tile.myTileType;
     spriteRenderer.sprite = tile.originSprite;
     originSprite          = spriteRenderer.sprite;
 }
示例#5
0
 public void makeWall(bool empty)
 {
     passages   = DIRECTION_NONE;
     occupation = empty? TILE_TYPE.EMPTY : TILE_TYPE.WALL;
     space      = null;
     doors      = DIRECTION_NONE;
 }
示例#6
0
 public Coord(int _x, int _y, TILE_TYPE _tileType, Transform _tileObject)
 {
     x          = _x;
     y          = _y;
     tileType   = _tileType;
     tileObject = _tileObject;
 }
示例#7
0
 public void ShowFixed()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(LibrettoPalette.FIXED_BG_COLOR, LibrettoPalette.FIXED_FG_COLOR);
     tileType = TILE_TYPE.CLUE;
 }
示例#8
0
 public void ShowFixed()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(placedColor, Color.black);
     tileType = TILE_TYPE.CLUE;
 }
示例#9
0
 public void ShowTemporary()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(LibrettoPalette.GAP_BG_COLOR, LibrettoPalette.GAP_FG_COLOR);
     tileType = TILE_TYPE.TEMPORARY;
 }
示例#10
0
 public void ShowTemporary()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(gapColor, Color.white);
     tileType = TILE_TYPE.TEMPORARY;
 }
示例#11
0
 public void ShowButton()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(gapColor, Color.white);
     tileType = TILE_TYPE.BUTTON;
 }
示例#12
0
 public bool Is_down_tile_of_type(Tile tile, TILE_TYPE type)
 {
     if (tile.Y_Position + 1 < this.tiles.GetLength(1) && this.tiles[tile.X_Position, tile.Y_Position + 1].type == type)
     {
         return(true);
     }
     return(false);
 }
示例#13
0
 public bool Is_up_tile_of_type(Tile tile, TILE_TYPE type)
 {
     if (tile.Y_Position - 1 > 0 && this.tiles[tile.X_Position, tile.Y_Position - 1].type == type)
     {
         return(true);
     }
     return(false);
 }
示例#14
0
 public Tile(Texture2D texture_in, Texture2D texture_out, Vector2 position, TILE_TYPE type, TILE_ORIENTATION orientation)
 {
     this.texture_in  = texture_in;
     this.texture_out = texture_out;
     this.position    = position;
     this.orientation = orientation;
     this.type        = type;
 }
示例#15
0
 public void ShowPlaced()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(LibrettoPalette.PLACED_BG_COLOR, LibrettoPalette.PLACED_FG_COLOR);
     tileType = TILE_TYPE.PLACED;
 }
示例#16
0
 public void ShowButton()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(LibrettoPalette.GAP_BG_COLOR, LibrettoPalette.GAP_FG_COLOR);
     tileType = TILE_TYPE.BUTTON;
 }
示例#17
0
//	void MakeWalls() {
//		Vector2 p1ReceiverLocation = new Vector2 (2, 2);
//		Vector2 p2ReceiverLocation = new Vector2 (rows - 3, columns - 3);
//		Vector2 p3ReceiverLocation = new Vector2 (rows - 3, columns - 3);
//		Vector2 p4ReceiverLocation = new Vector2 (rows - 3, columns - 3);
//		Vector2 emmiter1Location = new Vector2 (rows - 3, 2);
//		Vector2 emmiter2Location = new Vector2 (2, columns - 3);
//        for (var i = 0; i < rows; i++)
//		{
//			pipes [i] = new Pipe[(int)columns];
//			towers [i] = new Tile[(int)columns];
//            for (var j = 0; j < columns; j++)
//            {
//                int x = i;
//				int y = j;
//
//				MakeWall (Utilities.getLocationVector(x, y, WALL_LAYER),
//					new Vector3 (Utilities.tileSize, Utilities.tileSize, Utilities.thickness/2));
//				if (x == p1ReceiverLocation.x && y == p1ReceiverLocation.y) {
//					AddPlayerTower (x, y, TILE_TYPE.PLAYER_ONE_GOAL, p1_receiver_mat);
//				} else if (x == p2ReceiverLocation.x && y == p2ReceiverLocation.y) {
//					AddPlayerTower (x, y, TILE_TYPE.PLAYER_TWO_GOAL, p2_receiver_mat);
//				} else if (x == p3ReceiverLocation.x && y == p3ReceiverLocation.y) {
//					AddPlayerTower (x, y, TILE_TYPE.PLAYER_THREE_GOAL, p3_receiver_mat);
//				} else if (x == p4ReceiverLocation.x && y == p4ReceiverLocation.y) {
//					AddPlayerTower (x, y, TILE_TYPE.PLAYER_FOUR_GOAL, p4_receiver_mat);
//				} else if (x == emmiter1Location.x && y == emmiter1Location.y) {
//					AddEmitter (x, y);
//				} else if (x == emmiter2Location.x && y == emmiter2Location.y) {
//					AddEmitter (x, y);
//				} else {
//					AddPipe (x, y, (int)Utilities.getRandomDropTile());
//				}
//			}
//        }
//	}

    void AddPlayerTower(int x, int y, TILE_TYPE tileType, Material mat)
    {
        Tile tower = new Receiver(Utilities.getLocationVector(x, y, Utilities.PIPE_LAYER), tileType, mat);

        tower.Rotate();
        towers [x] [y] = tower;
        playerTowers.Add(tower);
    }
示例#18
0
 public void ShowPlaced()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(false);
     tileBg.SetActive(true);
     SetColor(gapColor, Color.white);
     tileType = TILE_TYPE.PLACED;
 }
示例#19
0
 public SCR_Node(bool _isWalkable, bool _isPassable, Vector3 _position, int _gridX, int _gridY, TILE_TYPE _tile)
 {
     isWalkable = _isWalkable;
     position   = _position;
     gridX      = _gridX;
     gridY      = _gridY;
     tileType   = _tile;
 }
示例#20
0
        public Tile(int x, int y, Map map)
        {
            this.map   = map;
            occupation = TILE_TYPE.EMPTY;
            this.coord = new MapCoord(x, y);

            setStartingPassages();
            this.doors = DIRECTION_NONE;
        }
示例#21
0
    public Tile GetTileRef(TILE_TYPE tileType)
    {
        if (tileRefs[(int)tileType] != null)
        {
            return(tileRefs[(int)tileType]);
        }

        return(tileRefs[0]); // if tile cannot be found return default tile
    }
示例#22
0
    void SetupTilesArray()
    {
        tiles = new TILE_TYPE[columns][];

        for (int i = 0; i < tiles.Length; i++)
        {
            tiles[i] = new TILE_TYPE[rows];
        }
    }
示例#23
0
    public GameObject GetPrefab(TILE_TYPE type)
    {
        int idx = tileTypes.IndexOf(type);

        if (idx >= 0)
        {
            return(tiles[idx]);
        }
        return(tiles[0]);
    }
示例#24
0
 public void DecrementUnitOccupied()
 {
     --m_NumberOfUnitOccupied;
     Assert.IsFalse(m_NumberOfUnitOccupied < 0, "Number of units occupying has goes less than 0");
     if (m_NumberOfUnitOccupied <= 0)
     {
         m_NumberOfUnitOccupied = 0;
         m_TileType             = TILE_TYPE.WALKABLE;
     }
 }
示例#25
0
    public float GetLost(ref TILE_TYPE type)
    {
        int idx = tileType.IndexOf(type);

        if (idx >= 0)
        {
            return(losts[idx]);
        }
        return(0.0f);
    }
示例#26
0
    public static TILE_TYPE getRandomDropTile()
    {
        int       rand     = Random.Range(0, 11);
        TILE_TYPE tileType = TILE_TYPE.CLEAR;

        if (rand == 0)
        {
            tileType = TILE_TYPE.UP_ARROW;
        }
        else if (rand == 1)
        {
            tileType = TILE_TYPE.DOWN_ARROW;
        }
        else if (rand == 2)
        {
            tileType = TILE_TYPE.LEFT_ARROW;
        }
        else if (rand == 3)
        {
            tileType = TILE_TYPE.RIGHT_ARROW;
        }
        else if (rand == 4)
        {
            tileType = TILE_TYPE.LEFT_ELBOW_DOWN;
        }
        else if (rand == 5)
        {
            tileType = TILE_TYPE.LEFT_ELBOW_UP;
        }
        else if (rand == 6)
        {
            tileType = TILE_TYPE.LEFT_ELBOW_LEFT;
        }
        else if (rand == 7)
        {
            tileType = TILE_TYPE.LEFT_ELBOW_RIGHT;
        }
        else if (rand == 8)
        {
            tileType = TILE_TYPE.RIGHT_ELBOW_DOWN;
        }
        else if (rand == 9)
        {
            tileType = TILE_TYPE.RIGHT_ELBOW_UP;
        }
        else if (rand == 10)
        {
            tileType = TILE_TYPE.RIGHT_ELBOW_LEFT;
        }
        else if (rand == 11)
        {
            tileType = TILE_TYPE.RIGHT_ELBOW_RIGHT;
        }
        return(tileType);
    }
示例#27
0
    /// <summary>
    /// Converts the Unity Vector3 Position to tile coordinates
    /// </summary>
    /// <returns>The to coordinate.</returns>
    /// <param name="position">Position.</param>
    public Coord PositionToCoord(Vector3 position)
    {
        float offsetX = ((mapSize.x - 1.0f) * tileSize) / 2.0f;
        float offsetY = ((mapSize.y - 1.0f) * tileSize) / 2.0f;
        int   coordX  = Mathf.RoundToInt((position.x + offsetX) / tileSize);
        int   coordY  = Mathf.RoundToInt((position.z + offsetY) / tileSize);
        //return allTileCoords[coordX * (int)mapSize.y + coordY ];
        TILE_TYPE tileType = coordY % 2 != 0 && coordX > 0 && coordX % 2 != 0 && coordX < mapSize.x - 1 ? TILE_TYPE.WALL : TILE_TYPE.GROUND;

        return(new Coord(coordX, coordY, tileType, allTileCoords[coordX * (int)mapSize.y + coordY].tileObject));
    }
示例#28
0
    public static TILE_TYPE getGridType(Vector2 location, Pipe[][] pipes)
    {
        Pipe      pipe     = pipes[(int)location.x][(int)location.y];
        TILE_TYPE tileType = TILE_TYPE.CLEAR;

        if (pipe != null)
        {
            tileType = pipe.tileType;
        }
        return(tileType);
    }
示例#29
0
 public void ShowGap()
 {
     gameObject.SetActive(true); // Why not false?
     outline.gameObject.SetActive(true);
     tileBg.SetActive(false);
     foreach (var c in charsGO)
     {
         c.SetActive(false);
     }
     outline.color = LibrettoPalette.GAP_BG_COLOR;
     tileType      = TILE_TYPE.GAP;
 }
示例#30
0
 public void ShowGap()
 {
     gameObject.SetActive(true);
     outline.gameObject.SetActive(true);
     tileBg.SetActive(false);
     foreach (var c in charsGO)
     {
         c.SetActive(false);
     }
     outline.color = Color.blue;
     tileType      = TILE_TYPE.GAP;
 }
 public TileClass(TILE_TYPE eTile, bool bResouceTile, Point sPos)
 {
     TType = TILE_TYPE.TT_PLAINS;
     Status = 0;
     Resource = bResouceTile;
     if (Resource)
     {
         Status += 2;
     }
     PlayerID = 0;
     Position = sPos;
 }
示例#32
0
 public TDTile(TILE_TYPE type)
 {
     this.type = (int)type;
 }
        private void TilesetGraphicsPanel_MouseClick(object sender, MouseEventArgs e)
        {
            int Xoutofrange = tilesetSize_RC.Width * TilePixelSize.Width;
            int Youtofrange = tilesetSize_RC.Height * TilePixelSize.Height;

            if (e.Location.X > 0 && e.Location.Y > 0 && e.Location.X < Xoutofrange && e.Location.Y < Youtofrange)
            {
               selectedTilePoint.X = e.X / tilePixelSize.Width;
                selectedTilePoint.Y = e.Y / tilePixelSize.Height;
            }
            UpdateTileset();

            Point matchtilepoint= new Point (0,0);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_PLAINS;
            }

            matchtilepoint = new Point(1,0);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_FOREST;
            }

            matchtilepoint = new Point(2, 0);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_MOUNTAINS;
            }

            matchtilepoint = new Point(3, 0);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_WATER;
            }

            matchtilepoint = new Point(0, 1);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_FARM;
            }
            matchtilepoint = new Point(1, 1);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_MILL;
            }

            matchtilepoint = new Point(2, 1);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_MINE;
            }

            matchtilepoint = new Point(3, 1);
            if (SelectedTilePoint == matchtilepoint)
            {
                selectTileType = TILE_TYPE.TT_CASTLE;
            }
        }
示例#34
0
文件: Tile.cs 项目: Pycorax/SquareDot
 // Use this for initialization
 void Start()
 {
     type = TILE_TYPE.TILE_NONE;
 }
示例#35
0
文件: Tile.cs 项目: Pycorax/SquareDot
 public void Set(TILE_TYPE type)
 {
     this.type = type;
 }