Inheritance: MonoBehaviour
コード例 #1
0
        // TODO: move to a map generator class
        // Floor name is something like 1F, etc.
        private void GenerateMap(string floorName)
        {
            var mapData = MapGenerator.GenerateFloor(1, ScreenAndMapWidth, ScreenAndMapHeight);

            // Apply changes to our map
            var map = new ArrayMap <AbstractMapTile>(ScreenAndMapWidth, ScreenAndMapHeight);

            // Convert ArrayMap<Bool> to ArrayMap<MapTile>
            foreach (var tile in mapData.Map.Positions())
            {
                AbstractMapTile mapTile;

                // Convert from boolean (true/false) to tiles
                if (mapData.Map[tile.X, tile.Y])
                {
                    mapTile = new FloorTile();
                }
                else
                {
                    mapTile = new WallTile();
                }

                map[tile.X, tile.Y] = mapTile;
            }

            // Position player and stairs
            player.Position.X = mapData.PlayerPosition.X;
            player.Position.Y = mapData.PlayerPosition.Y;

            map[mapData.StairsDownPosition.X, mapData.StairsDownPosition.Y] = new StairsDownTile();

            EventBus.Instance.Broadcast("Map changed", map);

            this.container.DrawFrame(0); // Initial draw without player moving
        }
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (GameSceneManager.LOGGING)
        {
            Debug.Log("Collided Gameobject name:" + collision.gameObject.name);
        }

        if (collision.gameObject.tag == GameSceneManager.TILE_TAG)
        {
            FloorTile _tile = collision.gameObject.GetComponent <FloorTile>();
            if (_tile.TileTypeGetSet == FloorTile.TileType.Tentative)
            {
                manager.RestartTurn();
            }
        }
        else if (collision.gameObject.tag == GameSceneManager.ENEMY_TAG)
        {
            manager.RestartTurn();
        }
        if (collision.gameObject.tag == GameSceneManager.POWERUPS_TAG)
        {
            manager.ApplySlowSpell();
            collision.gameObject.SetActive(false);
        }
    }
コード例 #3
0
    public void UpdateDialog(FloorTile floorTile)
    {
        InitDialog();
        List <Seed> seeds = InventoryManager.Instance.SearchItem <Seed>();

        Debug.Log(seeds.Count);
        foreach (Seed seed in seeds)
        {
            GameObject obj = Instantiate(SeedElementPrefab, Vector3.zero, Quaternion.identity);
            obj.transform.SetParent(SeedContent.transform, true);
            obj.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
            // ItemComponent 재사용함. SetItem과 ItemCount는 이렇게 재사용해도 문제없음.
            ItemComponent component = obj.GetComponent <ItemComponent>();
            component.SetItem(seed);
            component.ItemCount = seed.Component.ItemCount;
            seed.UpdatePlantSeedDialogElement(component);
            // TODO: SeedDialogElementComponent 따로 만들어서 GetComponent 호출 줄이기
            Button button = obj.GetComponent <Button>();
            // TODO: 좀 더러운 구조니 다른 방법 생각나면 고치기
            // TODO: CompleteFlower State 말고 Seed State로 나중에 바꾸기
            button.onClick.AddListener(() => {
                MoveDialog(false);
                InventoryManager.Instance.RemoveItem(seed);
                floorTile.State = new TileState.SeedFlower(seed).Init(floorTile);
            });
        }
    }
コード例 #4
0
    private void UpdateMouseInput()
    {
        if (m_isMoving)
        {
            return;
        }

        m_hoveredTile = GetHoveredTile();

        if (m_hoveredTile == null)
        {
            return;
        }

        Game.m_Me.WorldManager.Grid.HighlightTile(m_hoveredTile);

        if (!Input.GetMouseButtonDown(0))
        {
            return;
        }

        //make player face in the direction of the tile they clicked
        Vector3 playerToTile = m_hoveredTile.transform.position - transform.position;

        m_playerRigidBody.MoveRotation(Quaternion.LookRotation(playerToTile.normalized));

        Game.m_Me.Player.Inventory.UseTool(m_hoveredTile);
    }
コード例 #5
0
        public VMPlacementError FloorChangeValid(FloorTile floor,sbyte level)
        {
            var placeFlags = (VMPlacementFlags)ObjectData[(int)VMStackObjectVariable.PlacementFlags];

            if (floor.Pattern == 65535)
            {
                if ((placeFlags & (VMPlacementFlags.AllowOnPool | VMPlacementFlags.RequirePool)) == 0)
                {
                    return(VMPlacementError.CantPlaceOnWater);
                }
            }
            else
            {
                if ((placeFlags & VMPlacementFlags.RequirePool) > 0)
                {
                    return(VMPlacementError.MustPlaceOnPool);
                }
                if (floor.Pattern == 63354)
                {
                    if ((placeFlags & (VMPlacementFlags.OnWater | VMPlacementFlags.RequireWater)) == 0)
                    {
                        return(VMPlacementError.CantPlaceOnWater);
                    }
                }
                else
                {
                    if ((placeFlags & VMPlacementFlags.RequireWater) > 0)
                    {
                        return(VMPlacementError.MustPlaceOnWater);
                    }
                    if (floor.Pattern == 0)
                    {
                        if (level == 1)
                        {
                            if ((placeFlags & VMPlacementFlags.OnTerrain) == 0)
                            {
                                return(VMPlacementError.NotAllowedOnTerrain);
                            }
                        }
                        else
                        {
                            if ((placeFlags & VMPlacementFlags.InAir) == 0 && Object.OBJ.LevelOffset == 0)
                            {
                                return(VMPlacementError.CantPlaceInAir);
                            }
                            //TODO: special hack check that determines if we need can add/remove a tile to fulfil this if LevelOffset > 0
                        }
                    }
                    else
                    {
                        if ((placeFlags & VMPlacementFlags.OnFloor) == 0 &&
                            ((Object.OBJ.LevelOffset == 0) || (placeFlags & VMPlacementFlags.InAir) == 0))
                        {
                            return(VMPlacementError.NotAllowedOnFloor);
                        }
                    }
                }
            }
            return(VMPlacementError.Success);
        }
コード例 #6
0
ファイル: VMArchitecture.cs プロジェクト: simscolony/FreeSims
        public bool SetFloor(short tileX, short tileY, sbyte level, FloorTile floor, bool force)
        {
            //returns false on failure
            var offset = GetOffset(tileX, tileY);

            if (!force)
            {
                //first check if we're supported
                if (floor.Pattern > 65533 && level > 1 && RoomData[(int)Rooms[level - 2].Map[offset] & 0xFFFF].IsOutside)
                {
                    return(false);
                }
                if (level > 1 && !Supported[level - 2][offset])
                {
                    return(false);
                }
                //check if objects need/don't need floors
                if (!Context.CheckFloorValid(LotTilePos.FromBigTile((short)tileX, (short)tileY, level), floor))
                {
                    return(false);
                }
            }

            Floors[level - 1][offset] = floor;

            if (RealMode)
            {
                FloorsDirty = true;
            }
            Redraw = true;
            return(true);
        }
コード例 #7
0
        public void UpdateTile()
        {
            //NOTE: Because all floors were prefabbed without a FloorTile component attached
            //it is now easier to add the FloorTile from this component if it is a TileType.Floor
            if (currentTileTypeIndex == TileType.List.IndexOf(TileType.Floor))
            {
                FloorTile fT = GetComponent <FloorTile>();
                if (fT == null)
                {
                    gameObject.AddComponent <FloorTile>();
                }
            }

            if (currentTileTypeIndex == TileType.List.IndexOf(TileType.Item))
            {
                if (Matrix.At(transform.position).ContainsItem(gameObject))
                {
                    //Don't do anything
                    return;
                }
            }

            Matrix.At(savedPosition).TryRemoveTile(gameObject);

            savedPosition = transform.position;

            AddTile();
        }
コード例 #8
0
        public void Deserialize(BinaryReader reader)
        {
            Width   = reader.ReadInt32();
            Height  = reader.ReadInt32();
            Stories = reader.ReadInt32();

            var size = Width * Height;

            Walls = new WallTile[Stories][];
            for (int l = 0; l < Stories; l++)
            {
                Walls[l] = new WallTile[size];
                for (int i = 0; i < size; i++)
                {
                    Walls[l][i] = WallTileSerializer.Deserialize(reader);
                }
            }

            Floors = new FloorTile[Stories][];
            for (int l = 0; l < Stories; l++)
            {
                Floors[l] = new FloorTile[size];
                for (int i = 0; i < size; i++)
                {
                    Floors[l][i] = new FloorTile {
                        Pattern = reader.ReadUInt16()
                    }
                }
                ;
            }

            WallsDirty  = reader.ReadBoolean();
            FloorsDirty = reader.ReadBoolean();
        }
コード例 #9
0
    public void LoadLevel()
    {
        ClearLevel();

        currentPlaceable = null;
        levelPassed      = false;

        Level level = levels[currentLevel];

        // Place tiles
        foreach (Level.TilePlacement tilePlacement in level.tiles)
        {
            // Tiles are always on 0.5 on y to pop out of ground
            Vector3   position = new Vector3(tilePlacement.x, 0.5f, tilePlacement.z);
            FloorTile tile     = Instantiate(tilePrefab, position, Quaternion.identity, tilesParent);
            tiles.Add(tile);
            tile.xIndex = (int)tilePlacement.x;
            tile.zIndex = (int)tilePlacement.z;
            tileGrid[tile.xIndex, tile.zIndex] = tile;
        }

        // Set Camera
        Camera.main.transform.position = level.cameraPosition;

        // Set UI
        uiManager.SetPlaceableButtons(level);
    }
コード例 #10
0
    FloorTile getSeed(int index)
    {
        int       lastTileCounter = floorMaker.Rows * floorMaker.Columns;
        FloorTile _seed           = null;
        int       seedNeighbours  = 0;

        foreach (var item in TentativeTileList[index].Neighbours)
        {
            if (item.TileTypeGetSet == FloorTile.TileType.Space)
            {
                seedNeighbours++;
                int currentTileCounter = item.fillThis(FloorTile.TileType.Counting);
                if (lastTileCounter > currentTileCounter)
                {
                    _seed           = item;
                    lastTileCounter = currentTileCounter;
                }
                //Debug.Log("Count:" + item.fillThis(FloorTile.TileType.Counting));
            }
        }
        if (seedNeighbours <= 1)
        {
            _seed = null;
        }
        return(_seed);
    }
コード例 #11
0
    bool BounceToNeighbour(Transform player)
    {
        List <FloorTile> availableNeighbours = new List <FloorTile> ();

        if (upTile != null && !upTile.isSpecial)
        {
            availableNeighbours.Add(upTile);
        }
        if (downTile != null && !downTile.isSpecial)
        {
            availableNeighbours.Add(downTile);
        }
        if (rightTile != null && !rightTile.isSpecial)
        {
            availableNeighbours.Add(rightTile);
        }
        if (leftTile != null && !leftTile.isSpecial)
        {
            availableNeighbours.Add(leftTile);
        }

        FloorTile randomNeigh = availableNeighbours[Random.Range(0, availableNeighbours.Count)];

        if (randomNeigh != null)
        {
            player.GetComponent <CharacterMovement> ().ShiftTo(randomNeigh);
        }
        player.DOShakePosition(0.5f, 0.2f, 5);

        return(randomNeigh != null);
    }
コード例 #12
0
 public void addToTentativeList(FloorTile _tileScript)
 {
     if (_tileScript != null)
     {
         TentativeTileList.Add(_tileScript);
     }
 }
コード例 #13
0
ファイル: ToolTile.cs プロジェクト: ArthurCurry/PCGDemo
    /// <summary>
    /// 根据周边的floor地块种类自动变更自身精灵
    /// </summary>
    /// <param name="tilemap"></param>
    /// <param name="position"></param>
    private void JudgeSorroundings(ITilemap tilemap, Vector3Int position)
    {
        TileBase right = tilemap.GetTile(position + Vector3Int.right);
        TileBase left  = tilemap.GetTile(position + Vector3Int.left);
        TileBase up    = tilemap.GetTile(position + Vector3Int.up);
        TileBase down  = tilemap.GetTile(position + Vector3Int.down);
        ToolTile self  = (ToolTile)tilemap.GetTile(position);

        if (right is FloorTile && right.name.Contains(TileType.Floor.ToString()))
        {
            FloorTile temp = right as FloorTile;
            self.sprite = temp.sprite;
            return;
        }
        else if (left is FloorTile && left.name.Contains(TileType.Floor.ToString()))
        {
            FloorTile temp = left as FloorTile;
            self.sprite = temp.sprite;
            return;
        }
        else if (up is FloorTile && up.name.Contains(TileType.Floor.ToString()))
        {
            FloorTile temp = up as FloorTile;
            self.sprite = temp.sprite;
            return;
        }
        else if (down is FloorTile && down.name.Contains(TileType.Floor.ToString()))
        {
            FloorTile temp = down as FloorTile;
            self.sprite = temp.sprite;
            return;
        }
    }
コード例 #14
0
    public FloorTile GetHoveredTile()
    {
        Ray        camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit floorHit;

        //check if we moused over the floor
        if (Physics.Raycast(camRay, out floorHit, 1000f, 1 << LayerMask.NameToLayer("Floor")))
        {
            FloorTile selectedTile = Game.m_Me.WorldManager.Grid.GetTileAtPosition(floorHit.point);

            if (selectedTile == null)
            {
                return(null);
            }

            //ignore tiles that are not near to the player
            if (Mathf.Abs(m_playerTile.XPos - selectedTile.XPos) > 2 || Mathf.Abs(m_playerTile.ZPos - selectedTile.ZPos) > 2)
            {
                return(null);
            }

            return(selectedTile);
        }

        return(null);
    }
コード例 #15
0
    public Level(string filename) : base()
    {
        AddChild(spawner);
        AddChild(bullet_handler);
        AddChild(acid_handler);
        // tile spawning for floor
        colliders = new List <Sprite>();
        for (int tileX = -MyGame.TILE_SIZE; tileX <= game.width + MyGame.TILE_SIZE; tileX += MyGame.TILE_SIZE)
        {
            Sprite floor_tile = new FloorTile(tileX, game.height - MyGame.TILE_SIZE);
            //colliders.Add(floor_tile);
            AddChild(floor_tile);
        }


        player1.SetXY(256, 128);
        AddChild(player1);
        player1.other_player   = player2;
        player1.bullet_handler = bullet_handler;

        player2.SetXY(512, 128);
        AddChild(player2);
        player2.other_player   = player1;
        player2.bullet_handler = acid_handler;
    }
コード例 #16
0
    //This method creates the map bounds for the enemys
    void CreateMapBounds()
    {
        Transform child = gameObject.transform.FindChild("Bounds");

        if (child != null)
        {
            Destroy(child.gameObject);
            boundSpawns.Clear();
        }

        // Adds a container for the bounds
        GameObject boundContainer = new GameObject("Bounds");

        boundContainer.transform.SetParent(this.gameObject.transform);

        for (int i = 0; i < FloorTilesList.Count; i++)
        {
            FloorTile tile = FloorTilesList[i].transform.GetChild(0).GetComponent <FloorTile>();


            if (tile.XID == 0)
            {
                boundSpawns.Add(new Vector3(tile.transform.parent.position.x - 1f, tile.transform.parent.position.y, 0));
            }
        }

        for (int j = 0; j < boundSpawns.Count; j++)
        {
            GameObject tile = Instantiate(boundaryTilePrefab, boundSpawns[j], Quaternion.identity) as GameObject;
            tile.transform.SetParent(boundContainer.transform);
        }
    }
コード例 #17
0
 public override void Use(FloorTile _hoveredTile)
 {
     if (Game.m_Me.WorldManager.Grid.RemovePlantFromTile(_hoveredTile))
     {
         Game.m_Me.Player.Inventory.AddItem(ItemDatabase.ItemType.FlowerCrop, 1);
     }
 }
コード例 #18
0
        FloorTile[] ResizeFloors(FloorTile[] floors, int size)
        {
            if (size >= 64)
            {
                return(floors);
            }
            var result = new FloorTile[size * size];
            int iS     = 0;
            int iD     = 0;

            for (int y = 0; y < 64; y++)
            {
                if (y >= size)
                {
                    return(result);
                }
                for (int x = 0; x < 64; x++)
                {
                    if (x < size)
                    {
                        result[iD++] = floors[iS];
                    }
                    iS++;
                }
            }
            return(result);
        }
コード例 #19
0
    /* in the following method...
     */
    public void makeConcreteTiles()
    {
        int       counter = 0;
        FloorTile _seed   = null;

        foreach (var item in TentativeTileList)
        {
            item.TileTypeGetSet = FloorTile.TileType.Concrete;
            if (_seed == null)
            {
                resettingGridAfterCounting();
                _seed = getSeed(counter);
            }
            counter++;
        }

        resettingGridAfterCounting();

        /*In case, if both area is same, we dont do anything*/
        if (_seed != null)
        {
            _seed.fillThis(FloorTile.TileType.Concrete);
        }


        TentativeTileList.Clear();
        checkGameEnd();
    }
コード例 #20
0
 public void UpdateDialog <T>(FloorTile floorTile, T state) where T : TileState.FlowerState
 {
     getFlowerButton.gameObject.SetActive(state.IsComplete);
     flowerNameText.text = state.seed.Flower.Name + " : " + state.LevelName;
     if (state.IsComplete)
     {
         getFlowerButton.onClick.RemoveAllListeners();
         getFlowerButton.onClick.AddListener(() =>
         {
             InventoryManager.Instance.GetItem(state.seed.Flower);
             AudioManager.Instance.PlayAudioClip(AudioManager.Instance.LoadAudioClip("effect/GetFlowerSound"), 1, 1.5f);
             // TODO: 꽃마다 주는 경험치 다르게
             ResourceManager.Instance.ChangeExp(1);
             floorTile.State = new TileState.StemFlower(state.seed).Init(floorTile);
             MoveDialog(false);
         });
     }
     removeFlowerButton.onClick.RemoveAllListeners();
     removeFlowerButton.onClick.AddListener(() =>
     {
         floorTile.State = new TileState.PlantableGrassTile().Init(floorTile);
         Destroy(floorTile.aboveBlock);
         MoveDialog(false);
     });
     sprinklerButton.onClick.RemoveAllListeners();
     sprinklerButton.onClick.AddListener(() =>
     {
         // TODO: 지금은 물 주면 바로 성장하지만, 나중에 수정 필요함
         state.ToNextFlowerState();
         AudioManager.Instance.PlayAudioClip(AudioManager.Instance.LoadAudioClip("effect/SprinklerSound"));
         MoveDialog(false);
     });
 }
コード例 #21
0
    public void FloorIsoCoordsAreAdjacent()
    {
        // Test adjacency test for iso coords - static function
        for (int i = -10; i < 10; i++)
        {
            for (int j = -10; j < -10; j++)
            {
                // Two iso coords are adjacent if they differ by 1 in 1 axis.
                Assert.True(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i, j + 1)));
                Assert.True(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i, j - 1)));
                Assert.True(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i + 1, j)));
                Assert.True(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i - 1, j)));

                // Counter examples
                Assert.False(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i, j)));

                for (int k = 2; k < 10; k++)
                {
                    Assert.False(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i, j + k)));
                    Assert.False(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i, j - k)));
                    Assert.False(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i + k, j)));
                    Assert.False(FloorTile.AreIsoCoordsAdjacent(new Vector2(i, j), new Vector2(i - k, j)));
                }
            }
        }
    }
コード例 #22
0
ファイル: Main.cs プロジェクト: jensj12/MeesGame
        private void AddTileInBetween()
        {
            // Default is a FloorTile
            tileToAdd = new FloorTile();

            // If a key has been placed, immediately place a door
            if (doorsPlaced < keysPlaced)
            {
                tileToAdd = new DoorTile();
                (tileToAdd as DoorTile).SecondarySpriteColor = ChooseColor(doorsPlaced);
                doorsPlaced++;
            }
            // Always have a chance to place a door after a key has been placed
            else if (placeDoors && randomChance(doorChance))
            {
                tileToAdd = new DoorTile();
                (tileToAdd as DoorTile).SecondarySpriteColor = ChooseColor(keysPlaced, true, true);
            }
            tiles.Add(tileToAdd, pointBetween.X, pointBetween.Y);

            behindDoorInfo[next.X, next.Y] = behindDoorInfo[current.X, current.Y];
            if (tiles.GetType(pointBetween) == TileType.Door)
            {
                // If a door is placed, next is behind all the doors it is currently behind as well as the newly placed door.
                behindDoorInfo[next.X, next.Y] |= GetFlagFromColor((tiles.GetTile(pointBetween) as DoorTile).SecondarySpriteColor);
            }
        }
コード例 #23
0
    public void OnPlace()
    {
        DispensaryManager dm = GetStoreObject().dm;

        RaycastHit[] hits         = Physics.RaycastAll(transform.position + new Vector3(0, 2, 0), Vector3.down);
        string       component    = string.Empty;
        int          subGridIndex = -1;

        if (hits.Length > 0)
        {
            foreach (RaycastHit hit in hits)
            {
                if (hit.transform.tag == "Floor")
                {
                    FloorTile tile = hit.transform.GetComponent <FloorTile>();
                    component = tile.gameObject.name;
                    StoreObject storeObj = GetStoreObject();
                    storeObj.gridIndex = new Vector2(tile.gridX, tile.gridY);
                    subGridIndex       = tile.subGridIndex;
                }
            }
        }
        if (component == string.Empty)
        {
            component = dm.dispensary.GetSelected();
        }
        StoreObject obj = GetStoreObject();

        switch (component)
        {
        case "MainStore":
        case "MainStoreComponent":
            dm.dispensary.Main_c.AddStoreObject(obj);
            obj.grid = dm.dispensary.Main_c.grid.GetSubGrid(subGridIndex);
            break;

        case "Storage0":
        case "StorageComponent0":
            dm.dispensary.Storage_cs[0].AddStoreObject(obj);
            obj.grid = dm.dispensary.Storage_cs[0].grid.GetSubGrid(subGridIndex);
            break;

        case "Storage1":
        case "StorageComponent1":
            dm.dispensary.Storage_cs[1].AddStoreObject(obj);
            obj.grid = dm.dispensary.Storage_cs[1].grid.GetSubGrid(subGridIndex);
            break;

        case "Storage2":
        case "StorageComponent2":
            dm.dispensary.Storage_cs[2].AddStoreObject(obj);
            obj.grid = dm.dispensary.Storage_cs[2].grid.GetSubGrid(subGridIndex);
            break;
        }
        foreach (BoxCollider col in gameObject.transform.GetComponents <BoxCollider>())
        {
            col.gameObject.layer = 19;
        }
    }
コード例 #24
0
        public IGameObject CreateFloorTile(Vector2 position)
        {
            var createdObject = new FloorTile(position);
            var sprite        = new FixedSprite(createdObject, dungeonSpriteAtlas, new Rectangle(984, 11, 16, 16));

            createdObject.Sprite = sprite;
            return(createdObject);
        }
コード例 #25
0
 public void ReverseShift()
 {
     if (prevTile != null)
     {
         Target      = new Vector3(prevTile.GetTilePosition().x, yOffset, prevTile.GetTilePosition().z);
         currentTile = prevTile;
     }
 }
コード例 #26
0
    public void AddFloorTileToRoom(int room_index, Vector2 position, Vector2 dimensions)
    {
        FloorTile new_tile = new FloorTile();

        new_tile.position   = position;
        new_tile.dimensions = dimensions;
        contents.rooms [room_index].tiles.Add(new_tile);
    }
コード例 #27
0
    public void UseTool(FloorTile _hoveredTile)
    {
        if (EquippedItem == null)
        {
            return;
        }

        EquippedItem.ItemData.ItemBehaviour.Use(_hoveredTile);
    }
コード例 #28
0
 public void ShiftTo(FloorTile tile)
 {
     //prevPos = transform.position;
     prevTile    = currentTile;
     Target      = new Vector3(tile.GetTilePosition().x, transform.position.y, tile.GetTilePosition().z);
     currentTile = tile;
     SoundManager.instance.PlaySFX("SFX Player Jump");
     tile.OnLandingBy(transform);
 }
コード例 #29
0
    public void FloorStaticIsoCoordTest()
    {
        // Test calculation of iso coord from position
        // - static function
        Vector3 pos = new Vector3(1, 0, 3);
        Vector2 iso = FloorTile.CalcIsoCoord(pos);

        Assert.AreEqual(iso, new Vector2(1, 3));
    }
コード例 #30
0
    //Ran out of fuel, return to pool
    private void BurntOut()
    {
        FloorTile fT = Matrix.Matrix.At((Vector2)transform.position).GetFloorTile();

        if (fT != null)
        {
            fT.AddFireScorch();
        }
        PoolManager.PoolClientDestroy(gameObject);
    }
コード例 #31
0
ファイル: CraftGrid.cs プロジェクト: monarchshield/TFIL
    void TileFallEvent()
    {
        m_currentTile = m_Tiles [m_RandNumber].GetComponent<FloorTile> ();

        if (!m_currentTile.m_isRigidEnabled)
        {
            m_currentTile.SetRigidEnabled (true);
            Debug.Log("Tile is falling");
        }
        else
            TileFallEvent ();
    }
コード例 #32
0
ファイル: Node.cs プロジェクト: andrewdavis1995/Cinema-Game
    /// <summary>
    /// Find all children nodes for the current node. (i.e. the adjacent nodes)
    /// </summary>
    /// <param name="explored"></param>
    /// <param name="tmp"></param>
    /// <param name="states"></param>
    /// <returns></returns>
    public List<Node> FindChildren(List<Node> explored, List<Node> tmp, FloorTile[,] states)
    {
        List<Node> temp = new List<Node>();

        if (location.x > 0)
        {
            Node toAdd = new Node(new Coordinate(location.x - 1, location.y));

            if (!IsSameLocation(toAdd, explored) && !IsSameLocation(toAdd, tmp) && states[location.y, location.x-1].inUse != 2)
            {
                temp.Add(toAdd);
            }
        }
        if (location.x < 79)
        {
            Node toAdd = new Node(new Coordinate(location.x + 1, location.y));

            if (!IsSameLocation(toAdd, explored) && !IsSameLocation(toAdd, tmp) && states[location.y, location.x + 1].inUse != 2)
            {
                temp.Add(toAdd);
            }
        }
        if (location.y > 0)
        {
            Node toAdd = new Node(new Coordinate(location.x, location.y-1));

            if (!IsSameLocation(toAdd, explored) && !IsSameLocation(toAdd, tmp) && states[location.y-1, location.x].inUse != 2)
            {
                temp.Add(toAdd);
            }
        }
        if (location.y < 39)
        {
            Node toAdd = new Node(new Coordinate(location.x, location.y+1));

            if (!IsSameLocation(toAdd, explored) && !IsSameLocation(toAdd, tmp) && states[location.y+1, location.x].inUse != 2)
            {
                temp.Add(toAdd);
            }
        }

        return temp;
    }
コード例 #33
0
ファイル: Map.cs プロジェクト: brokoli78/ProjectRogue
    public void finalize(int floor)
    {
        tileMap = new Tile[mapX + 2, mapY + 2];

        for (int x = 1; x < mapX + 1; x++)
        {
            for (int y = 1; y < mapY + 1; y++)
            {
                Tile t;
                switch (map[x - 1, y - 1].tile)
                {
                    case Node.tileType.floor:
                        t = new FloorTile(x, y);
                        break;
                    case Node.tileType.wall:
                        t = new WallTile(x, y);
                        break;
                    default:
                        t = null;
                        break;
                }

                tileMap[x, y] = t;
            }
        }

        for (int x = 0; x < mapX + 2; x++)
        {
            tileMap[x, 0] = new WallTile(x, 0);
            tileMap[x, mapY + 1] = new WallTile(x, mapY + 1);

        }

        for (int y = 0; y < mapY + 2; y++)
        {
            tileMap[0, y] = new WallTile(0, y);
            tileMap[mapY + 1, y] = new WallTile(mapY + 1, y);

        }

        mapX += 2;
        mapY += 2;

        foreach (Tile t in tileMap)
        {
            if (t.GetType() == typeof(FloorTile))
            {
                emptyTiles.Add(t);
                notPopulatedTiles.Add(t);
            }
            if (Directions8.Where(d => inMap(t.x + d.X, t.y + d.Y) && tileMap[t.x + d.X, t.y + d.Y].GetType() == typeof(WallTile)).ToList().Count == Directions8.Where(d => inMap(t.x + d.X, t.y + d.Y)).Count())
                t.explorable = false;
        }

        if(floor != 0)
        {
            for (int i = 0; i < 3; i++)
            {
                int rand = r.Next(emptyTiles.Count);
                tileMap[emptyTiles[rand].x, emptyTiles[rand].y].DestroyNow();
                tileMap[emptyTiles[rand].x, emptyTiles[rand].y] = new UpStairTile(emptyTiles[rand].x, emptyTiles[rand].y, i);
                emptyTiles.RemoveAt(rand);
                notPopulatedTiles.RemoveAt(rand);

            }
        }

        if (floor != GameController.saveGame.maxFloors - 1)
        {
            for (int i = 0; i < 3; i++)
            {
                int rand = r.Next(emptyTiles.Count);
                tileMap[emptyTiles[rand].x, emptyTiles[rand].y].DestroyNow();
                tileMap[emptyTiles[rand].x, emptyTiles[rand].y] = new DownStairTile(emptyTiles[rand].x, emptyTiles[rand].y, i);
                emptyTiles.RemoveAt(rand);
                notPopulatedTiles.RemoveAt(rand);
            }
        }

        map = null;
    }