Example #1
0
    public void enterRoom()
    {
        background.sprite = currentRoom.background; //set background
        background.color  = Color.white;

        //check room type
        if (currentRoom == map.endRoom)
        {
            //entered last room, end game
            EndGame(true);
        }
        else if (currentRoom is NavRoom)
        {
            startNav();
        }
        else if (currentRoom is CombatRoom)
        {
            if (!((CombatRoom)currentRoom).hasFought)
            {
                CombatStarted();
            }
            else
            {
                startNav();
            }
        }
        else if (currentRoom is TrapRoom)
        {
            if (!((TrapRoom)currentRoom).hasTriggered)
            {
                TrapActivated();
            }
            else
            {
                trap.Deactivate();
                startNav();
            }
        }
    }
Example #2
0
    private void HandleTraps()
    {
        foreach (GameObject tile in DungeonGenerator.instance.GetTiles())
        {
            if (tile.GetComponent <Trap>() != null)
            {
                Trap trap = tile.GetComponent <Trap>();

                // if the trap is activated on this turn.
                if (trap.GetActiveStatus() == Trap.State.Active)
                {
                    if (trap.activatedOnTurn + trapDelayInTurns == turnCount)
                    {
                        // open spikes
                        trap.UpdateGraphics();

                        // on next turn this trap will be inactive.
                        trap.Deactivate();

                        Tile t = tile.GetComponent <Tile>();

                        // damage whoever is on the tile.
                        if (t.actor != null)
                        {
                            // flying enemies dodge traps.
                            if (t.actor.GetComponent <Actor>().canFly == false)
                            {
                                // set bleed effect.
                                if (trapsCauseBleedEffect)
                                {
                                    // create effect
                                    StatusEffect bleed = StatusEffect.CreateEffect(
                                        StatusEffect.EffectType.Bleeding, trapDoTDamage, trapDoTDuration);

                                    // add effect to the actor.
                                    t.actor.GetComponent <Actor>().AddStatusEffect(bleed);

                                    // gui stuff
                                    GUIManager.instance.CreatePopUpEntry("BLEEDING", t.position, GUIManager.PopUpType.Damage);
                                    GUIManager.instance.CreateJournalEntry(
                                        t.actor.GetComponent <Actor>().actorName + " started to bleed.",
                                        GUIManager.JournalType.Status);
                                }

                                // initial damage
                                t.actor.GetComponent <Health>().TakeDamageSimple(trapInitialDamage);
                            }
                        }

                        // turn the tile to a wall
                        // -> actors can't step on spikes after their have popped out.
                        t.myType = Tile.TileType.Wall;
                    }
                }
                else if (trap.GetActiveStatus() == Trap.State.Inactive)
                {
                    // close the spikes
                    trap.UpdateGraphics();

                    // turn the tile to a floor again.
                    tile.GetComponent <Tile>().myType = Tile.TileType.Floor;
                }
            }
        }
    }