示例#1
0
    public void AddModelToTile(TileEntity tileEnt)
    {
        TileBorder.SetActive(false);
        Model = Instantiate(tileEnt.GetModel(), transform);


        //Reset the position of the model to 0.
        Model.transform.localPosition = Vector3.zero;

        //Add Gesture Components to Buildings
        Model.AddComponent <MoveGesture>();
        Model.AddComponent <RotateGesture>();

        //Set the layer mask.
        Model.layer = LayerMask.NameToLayer("Hologram");

        //enable any sounds
        if (Model.GetComponent <AudioSource>())
        {
            Model.GetComponent <AudioSource>().Play();
        }

        //Tell the Tile entity that this tile exists now.
        tileEnt.OnWorldGridTileCreated(this);
    }
示例#2
0
    public void PlaceBuilding(WorldGridTile tile, int index, TileEntity tileEnt)
    {
        int gridID = 0;

        gridID = tile.ParentGrid.Id;
        Vector2Int pos = tile.Position;


        if (tile.Model)
        {
            tile.UpdateModel(tileEnt.GetModel());
        }
        else if (CheckCanPlace(tile, index))
        {
            Game.CurrentSession.City.GetGrid(gridID).AddTileEntityToTile(pos.x, pos.y, tileEnt);
            //Take money
            Game.CurrentSession.TakeFunds(Buildings[index].Cost);
        }
    }