Beispiel #1
0
	void Start () {
		worldSize = FindObjectOfType<Terrain> ().WorldSize;

		for (int x = 1-worldSize; x < worldSize; x++) {
			for (int y = 1-worldSize; y < worldSize; y++) {
				TileLocation location = new TileLocation(x, y);
				locations [location] = false;
			}
		}
	}
Beispiel #2
0
	void Spawn(TileLocation spawningLocation) {
		spawning = true;
		timer = 0;

		bool result;
		locations.TryGetValue (spawningLocation, out result);
		if (!(result)) {
			SimplePool.Spawn (firePrefab, spawningLocation).GetComponent<Burn> ().location = spawningLocation;
		}

		locations [spawningLocation] = true;
		spawning = false;
	}
Beispiel #3
0
	void Spawn(TileLocation spawningLocation) {
		spawning = true;
		timer = 0;


		if (spawningLocation.X == 0 && spawningLocation.Y == 0) {
			SceneManager.LoadScene("Score");
		}

		bool result;
		locations.TryGetValue (spawningLocation, out result);
		if (!(result)) {
			SimplePool.Spawn (firePrefab, spawningLocation).GetComponent<Burn> ().location = spawningLocation;
		}



		locations [spawningLocation] = true;
		spawning = false;
	}
 void RemoveShieldingHeight(TileLocation l)
 {
     if (Terrain.self.validTileLocation(l))
         Terrain.self.defenceHeightBonuses[l] -= ShieldingHeight(l);
 }
Beispiel #5
0
 public virtual bool CanPlace(ITile tile, TileLocation location)
 {
     return(location.Chunk.GetTile(location.AsLocalized.X, location.AsLocalized.Y, location.Z) == null);
 }
        /// <summary>
        /// Overrides usual use-with-item behaviours to limit the set to working in
        /// specific locations with specific items, as well as other funky behaviour.
        /// </summary>
        /// <param name="dropIn">Our candidate item.</param>
        /// <param name="probe">Base game check for determining outcomes without consequences.</param>
        /// <param name="who">Farmer using the machine.</param>
        /// <returns>
        /// Whether the dropIn object is appropriate for this machine in this context.
        /// </returns>
        public override bool performObjectDropInAction(Item dropIn, bool probe, Farmer who)
        {
            if (!probe)
            {
                Log.D($"performObjectDropInAction(dropIn:{dropIn?.Name ?? "null"}) at {Game1.currentLocation?.Name} {TileLocation.ToString()}",
                      ModEntry.Instance.Config.DebugMode);
            }

            // Ignore usages with inappropriate items
            if (dropIn == null)
            {
                return(false);
            }

            // Extract held mushrooms prematurely
            if (!probe && SourceMushroomIndex > 0)
            {
                if (heldObject.Value != null)
                {
                    // Get a copy of the root mushroom
                    PopExposedMushroom(false);
                }
                else if (!ModEntry.Instance.Config.OnlyToolsCanRemoveRootMushrooms)
                {
                    // Remove the root mushroom if it hasn't settled overnight
                    PopExposedMushroom(true);
                }
            }

            // Determine if being used in an appropriate location
            if (!probe && who != null)
            {
                var flag = (who.currentLocation is Cellar && ModEntry.Instance.Config.WorksInCellar) ||
                           (who.currentLocation is FarmCave && ModEntry.Instance.Config.WorksInFarmCave) ||
                           (who.currentLocation is BuildableGameLocation && ModEntry.Instance.Config.WorksInBuildings) ||
                           (who.currentLocation is FarmHouse && ModEntry.Instance.Config.WorksInFarmHouse) ||
                           (who.currentLocation.IsGreenhouse && ModEntry.Instance.Config.WorksInGreenhouse) ||
                           (who.currentLocation.IsOutdoors && ModEntry.Instance.Config.WorksOutdoors);

                if (!flag)
                {
                    // Ignore bad machine locations
                    Game1.showRedMessage(ModEntry.Instance.i18n.Get("error.location"));
                    return(false);
                }
            }

            // Ignore Truffles
            if (!probe && dropIn.ParentSheetIndex.Equals(430))
            {
                Game1.showRedMessage(ModEntry.Instance.i18n.Get("error.truffle"));
                return(false);
            }

            if (!(dropIn is Object o) || !ModEntry.IsValidMushroom(o))
            {
                if (!probe)
                {
                    Log.D($"Invalid mushroom: [{dropIn.ParentSheetIndex}] {dropIn.Name}",
                          ModEntry.Instance.Config.DebugMode);
                }
                return(false);
            }

            if (probe)
            {
                return(true);
            }

            // Accept the deposited item as the new source mushroom
            PutSourceMushroom(dropIn);
            who?.currentLocation.playSound("Ship");
            return(true);
        }
Beispiel #7
0
 public AddCloneConnectionCommand(int index, TileLocation source, TileLocation destination) : this(index, new TileConnection(source, destination))
 {
 }
Beispiel #8
0
 public TileCtrl GetAdjacentTile(TileCtrl tile, TileLocation adjacentLocation)
 {
     return(GetAdjacentTile(tile.Row, tile.Col, adjacentLocation));
 }
Beispiel #9
0
 public static TileLocationMarker FromMonster(TileLocation location)
 {
     return(new TileLocationMarker(location, Pens.Red));
 }
 public Vector3 GetTilePositionFor(TileLocation tileLocation)
 {
     return(GetTilePositionFor(tileManager.GetTileIndexFor(tileLocation)));
 }
Beispiel #11
0
 public void AddMonster(TileLocation location)
 {
     _history.Do(new AddMonsterCommand(location));
 }
 public CollisionHit(GameObject _GameObject, TileLocation _TileLocation)
 {
     GameObject   = _GameObject;
     TileLocation = _TileLocation;
 }
Beispiel #13
0
 public RemoveMonsterCommand(TileLocation location)
 {
     this.location = location;
 }
 public DrawOnTile(Texture2D texture, TileLocation location)
 {
     this.texture  = texture;
     this.location = location;
 }
Beispiel #15
0
    /// <summary>
    /// This is an overload of the SetupRoom function and has a corridor parameter that represents the corridor entering the room.
    /// This is Used for all rooms except the first and last room
    /// </summary>
    /// <param name="widthRange">The range between which the width of the room is determined</param>
    /// <param name="heightRange">The range between which the height of the room is determined</param>
    /// <param name="columns">The amount of Columns in this Dungeon board</param>
    /// <param name="rows">The amount of Rows in this Dungeon board</param>
    /// <param name="corridor">Corridor leading to this room</param>
    /// <param name="enemies">The range between which the amount of enemies in this room is determined</param>
    /// <param name="destructables">The range between which the amount of destructables in this room is determined</param>
    /// <param name="middle">Optional boolean in case we wish to do something to the middle room</param>
    public void SetupRoom(IntRange widthRange, IntRange heightRange, int columns, int rows, Corridor corridor, IntRange enemies, IntRange destructables, bool middle = false)
    {
        BoardCreator board = BoardCreator.instance;

        // Set the entering corridor direction.
        enteringCorridor = corridor.direction;

        // Set random values for width and height.
        roomWidth  = widthRange.Random;
        roomHeight = heightRange.Random;


        //TODO add monster chance to drop
        enemyAmount         = enemies.Random;
        destructablesAmount = destructables.Random;

        switch (corridor.direction)
        {
        // If the corridor entering this room is going north...
        case Direction.North:
            // ... the height of the room mustn't go beyond the board so it must be clamped based
            // on the height of the board (rows) and the end of corridor that leads to the room.
            roomHeight = Mathf.Clamp(roomHeight, 0, (rows - corridor.EndPositionY) - buffer);

            // The y coordinate of the room must be at the end of the corridor (since the corridor leads to the bottom of the room).
            yPos = corridor.EndPositionY;

            // The x coordinate can be random but the left-most possibility is no further than the width
            // and the right-most possibility is that the end of the corridor is at the position of the room.
            xPos = UnityEngine.Random.Range(corridor.EndPositionX - roomWidth + 1, corridor.EndPositionX);

            // This must be clamped to ensure that the room doesn't go off the board.
            xPos = Mathf.Clamp(xPos, buffer, (columns - roomWidth) - buffer);

            break;

        case Direction.East:
            roomWidth = Mathf.Clamp(roomWidth, 0, (columns - corridor.EndPositionX) - buffer);
            xPos      = corridor.EndPositionX;

            yPos = UnityEngine.Random.Range(corridor.EndPositionY - roomHeight + 1, corridor.EndPositionY);
            yPos = Mathf.Clamp(yPos, buffer, (rows - board.roomHeight.m_Max) - buffer);

            break;

        case Direction.South:
            // clamp the height of the room between 1 and the (int value given from EndPosition y (e.g 8)) and then subtract the buffer
            roomHeight = Mathf.Clamp(roomHeight, 0, corridor.EndPositionY - buffer);
            yPos       = corridor.EndPositionY - roomHeight + 1;

            xPos = UnityEngine.Random.Range(corridor.EndPositionX - roomWidth + 1, corridor.EndPositionX);
            xPos = Mathf.Clamp(xPos, buffer, (columns - roomWidth) - buffer);

            break;

        case Direction.West:
            roomWidth = Mathf.Clamp(roomWidth, 0, corridor.EndPositionX - buffer);
            xPos      = corridor.EndPositionX - roomWidth + 1;

            yPos = UnityEngine.Random.Range(corridor.EndPositionY - roomHeight + 1, corridor.EndPositionY);
            yPos = Mathf.Clamp(yPos, buffer, (rows - BoardCreator.instance.roomHeight.m_Max) - buffer);

            break;
        }

        middleTile = new TileLocation((roomWidth / 2) + xPos, (roomHeight / 2) + yPos);

        if (middle)
        {
            SetMapLocation();
        }

        ChestDropCheck();
    }
Beispiel #16
0
 public void Draw(TileLocation location)
 {
     new DrawOnTile(road, location).Go();
 }
Beispiel #17
0
 protected virtual void OnRightMouseButtonMove(LevelMapEditor editor, TileLocation location, Keys modifierKeys)
 {
     Default.OnRightMouseButtonMove(editor, location, modifierKeys);
 }
Beispiel #18
0
        private void ExecuteComputerMove(object sender, EventArgs e)
        {
            TileLocation computerMove = _game.PlayMove(_computerType);

            GetButtomFromTileLocation(computerMove).Text = _computerType.ToString();
        }
Beispiel #19
0
 public void Invalidate(TileLocation location)
 {
     Invalidate(location.ToRectangle(_owner.TileSize));
 }
Beispiel #20
0
 public RemoveCloneConnectionCommand(TileLocation source, TileLocation destination) : this(new TileConnection(source, destination))
 {
 }
Beispiel #21
0
 public void RemoveMonster(TileLocation location)
 {
     _history.Do(new RemoveMonsterCommand(location));
 }
Beispiel #22
0
 public ITileObject ToTileObject(TileLocation location)
 {
     return(BaseTile.ToTileObject(location));
 }
 public TTTGame()
 {
     InitializeComponent();
     _tileLocation = new TileLocation(0, 0);
     _winner       = false;
 }
Beispiel #24
0
 public TileLocationMarker(TileLocation location, Pen pen)
 {
     this.location = location;
     this.Pen      = pen;
 }
Beispiel #25
0
        /// <summary>
        /// Perform all start-of-day checks for the Propagator to handle held object events.
        /// </summary>
        internal void DayUpdate()
        {
            Log.D($"DayUpdate (item: [{SourceMushroomIndex}] {SourceMushroomName} Q{SourceMushroomQuality} at {Game1.currentLocation?.Name} {TileLocation.ToString()}",
                  ModEntry.Instance.Config.DebugMode);

            // Indexing inconsistencies with JA/CFR
            ParentSheetIndex = ModValues.PropagatorIndex;

            // Grow mushrooms overnight
            if (SourceMushroomIndex > 0)
            {
                GrowHeldMushroom();
            }
        }
Beispiel #26
0
	// Use this for initialization
	protected override void Start () {
        distanceFromMainBase = 0;
        location = new TileLocation(0, 0);
	}
Beispiel #27
0
 public TileExtensionObject(TTileObject tile, TileLocation location) : base(tile, location)
 {
     this.MainTile = tile;
 }
Beispiel #28
0
 public virtual ITileObject ToTileObject(TileLocation location)
 {
     return(new TileObject(this, location));
 }
Beispiel #29
0
 public PitCorner(Rotation rotation, TileLocation loc, Player player)
     : base(rotation, loc.Through(loc.Plus(4, 4, rotation)))
 {
     _player = player;
 }
Beispiel #30
0
    private bool CheckSpaceForSecretRoom(Room myRoom, Direction dir)
    {
        BoardCreator board = BoardCreator.instance;

        if (DebugControl.debugDungeon)
        {
            Debug.LogWarning("Entering CheckSpaceForSecretRoom ");
        }

        int westMostPoint  = 5;
        int eastMostPoint  = board.columns - 5;
        int northmostPoint = board.rows - 5;
        int southmostPoint = 5;
        int countX         = 0;
        int countY         = 0;

        switch (dir)
        {
        case Direction.North:

            secretRoomStartPosition = new TileLocation(myRoom.middleTile.x, myRoom.yPos + myRoom.roomHeight);

            /// Sanity Check
            if (secretRoomStartPosition.x > westMostPoint && secretRoomStartPosition.x + myRoom.roomWidth < eastMostPoint)
            {
                if (secretRoomStartPosition.y > southmostPoint && secretRoomStartPosition.y + myRoom.roomHeight < northmostPoint)
                {
                    for (int x = secretRoomStartPosition.x - 4; x <= secretRoomStartPosition.x + myRoom.roomWidth + 4; x += 2)
                    {
                        int xCoord = myRoom.xPos + countX;

                        for (int y = secretRoomStartPosition.y; y <= myRoom.roomWidth; y += 2)
                        {
                            if (DebugControl.debugDungeon)
                            {
                                Debug.LogWarning("Checking Tile " + xCoord + " " + (myRoom.yPos + y));
                            }

                            int yCoord = myRoom.yPos + countY;

                            if (board.tiles[xCoord][yCoord] != BoardCreator.TileType.BlackArea)
                            {
                                return(false);
                            }
                            countY++;
                        }

                        countX++;
                        countY = 0;
                    }

                    return(true);
                }
            }

            return(false);


        case Direction.East:
            break;

        case Direction.South:

            secretRoomStartPosition = new TileLocation(myRoom.middleTile.x, myRoom.yPos - 1);

            /// Sanity Check
            if (secretRoomStartPosition.x > westMostPoint && secretRoomStartPosition.x + myRoom.roomWidth < eastMostPoint)
            {
                if (secretRoomStartPosition.y > southmostPoint && secretRoomStartPosition.y + myRoom.roomHeight < northmostPoint)
                {
                    for (int x = secretRoomStartPosition.x - 4; x <= secretRoomStartPosition.x + myRoom.roomWidth + 4; x += 2)
                    {
                        int xCoord = myRoom.xPos + countX;

                        for (int y = secretRoomStartPosition.y; y <= 20; y += 2)
                        {
                            if (DebugControl.debugDungeon)
                            {
                                Debug.LogWarning("Checking Tile " + xCoord + " " + (myRoom.yPos + y));
                            }

                            int yCoord = myRoom.yPos + countY;

                            if (board.tiles[xCoord][yCoord] != BoardCreator.TileType.BlackArea)
                            {
                                return(false);
                            }
                            countY++;
                        }

                        countX++;
                        countY = 0;
                    }

                    return(true);
                }
            }

            return(false);

        case Direction.West:
            break;

        default:
            break;
        }

        return(false);
    }
 protected override void OnLeftMouseButtonMove(LevelMapEditor editor, TileLocation location, Keys modifierKeys)
 {
     // Do nothing
 }
Beispiel #32
0
    public void LeftClick()   // NO MARKING / just revealing tiles
    {
        //Initialize();

        if (Input.GetMouseButtonDown(0) && gmMg.isPaused == false && isGameOver == false)  // CHECKING is the game is not paused
        {
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 1000) && (!(hit.rigidbody == null) ||
                                                                                                      !(hit.collider == null)))
            {
                if (hit.collider.gameObject.tag == "Tile")
                {
                    TileLocation tileLoc = hit.collider.gameObject.GetComponent <TileLocation>();
                    // in case there is a problem, try using GetComponentInParent<TileLocation>
                    print(tileLoc.locationX.ToString() + ", " + tileLoc.locationZ.ToString());
                    thisTileLocationX = tileLoc.locationX;
                    thisTileLocationZ = tileLoc.locationZ;
                }
                // Makes it so the first tile needs to be clicked to start the game
                if (!firstClick)
                {
                    if (firstTile[0].coordX == thisTileLocationX && firstTile[0].coordZ == thisTileLocationZ)
                    {
                        firstClick = true;
                        firstTile[0].spriteHolder.color = Color.yellow;
                        firstTile[0].spriteHolder.gameObject.SetActive(false);
                        firstTile[0].adjacentTMP.gameObject.SetActive(true);
                        firstTile[0].isClicked = true;
                        if (firstTile[0].numOfAdjacent == 0)
                        {
                            StartCoroutine(BurstDelay(firstTile[0]));
                        }
                    }
                }
                else
                {
                    foreach (TileSO tile in gridMG.allTileSOs)
                    {
                        if (tile.coordX == thisTileLocationX && tile.coordZ == thisTileLocationZ)
                        {
                            // If a safe tile is left clicked
                            if (tile.isMarked == false && tile.type == Type.Safe)
                            {
                                tile.spriteHolder.gameObject.SetActive(false);
                                tile.adjacentTMP.gameObject.SetActive(true);
                                // Sets isClicked to true
                                tile.isClicked = true;
                                Debug.Log("Left click");
                                // If the tile isn't adjacent to any bombTiles burst revealing all adjacent tiles
                                if (tile.numOfAdjacent == 0)
                                {
                                    StartCoroutine(BurstDelay(tile));
                                }
                            }
                            else if (tile.isMarked == false && tile.type == Type.Bomb)
                            {
                                StartCoroutine(GameOverAnim());  // Player loses
                                                                 // GAME OVER
                                isGameOver = true;
                                // Moved into the coroutine
                                //StartCoroutine(PanelWaiting());
                                //inGamePanel.SetActive(false);
                                //losePanel.SetActive(true);
                            }
                        }
                    }
                }
            }
        }
    }
 float ShieldingHeight(TileLocation l)
 {
     return height * (Mathf.Max(0, radius - Vector2.Distance(l, location))) / radius;
 }
Beispiel #34
0
    public void RightClick()   // ONLY MARKING / No revealing the tiles
    {
        // I set it to initialize after the bombs render in the gridmanager
        //Initialize();

        if (Input.GetMouseButtonDown(1) && gmMg.isPaused == false &&
            isGameOver == false && firstClick == true)     // getting Mouse input AND CHECKING is the game is not paused
        {
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 1000) && (!(hit.rigidbody == null) ||
                                                                                                      !(hit.collider == null)))
            {
                if (hit.collider.gameObject.tag == "Tile")
                {
                    TileLocation tileLoc = hit.collider.gameObject.GetComponent <TileLocation>();
                    // in case there is a problem, try using GetComponentInParent<TileLocation>
                    print(tileLoc.locationX.ToString() + ", " + tileLoc.locationZ.ToString());
                    thisTileLocationX = tileLoc.locationX;
                    thisTileLocationZ = tileLoc.locationZ;
                }

                foreach (TileSO tile in gridMG.allTileSOs)
                {
                    if (tile.coordX == thisTileLocationX && tile.coordZ == thisTileLocationZ)
                    {
                        if (tile.isClicked == false && tile.isMarked == false && bombsCount > 0)
                        {
                            tile.isMarked            = true;                // Tile's isMarked state changes to prevent accidental missclicks
                            tile.spriteHolder.sprite = tile.tileSprites[1]; // Change Sprite to the Marked Sprite
                            bombsCount--;                                   // count down the number of Bombs
                            // If the tile clicked was a bomb
                            if (tile.type == Type.Bomb)
                            {
                                // Adds to the total bombs marked
                                bombsMarked++;
                                if (bombsMarked == gridMG.bombTileSOs.Count)
                                {
                                    // Player wins
                                    StartCoroutine(WinAnim());
                                    isGameOver = true;
                                    //StartCoroutine(PanelWaiting());
                                    // Moved into coroutine
                                    //inGamePanel.SetActive(false);
                                    //victoryPanel.SetActive(true);
                                }
                            }
                        }
                        else if (tile.isClicked == false && tile.isMarked == true)
                        {
                            tile.isMarked            = false;               // Tile's isMarked bool is back to default state
                            tile.spriteHolder.sprite = tile.tileSprites[0]; // Change Sprite to the UNmarked Sprite
                            bombsCount++;                                   // count up the bombs;
                            if (tile.type == Type.Bomb)
                            {
                                bombsMarked--;
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #35
0
 public Tile(TileLocation position, int row, int col)
 {
     tilePosition = position;
     rowNum       = row;
     colNum       = col;
 }
Beispiel #36
0
 protected virtual void OnLeftMouseButtonDown(LevelMapEditor editor, TileLocation location, Keys modifierKeys)
 {
     Default.OnLeftMouseButtonDown(editor, location, modifierKeys);
 }