Example #1
0
 // ================================================================================================== //
 public void RevealPartySurroundings()
 {
     foreach (Position pos in SightAlgorithm.GetPositionsInSight(Party.Instance.Position))
     {
         if (pos.DungeonTile != null)
         {
             pos.DungeonTile.IsRevealed = true;
         }
     }
 }
Example #2
0
    // ====================================================================================================== //
    private void creaturesTurn()
    {
        if (!_creaturesTurn)
        {
            return;
        }

        Debug.Log("Creatures turn");

        _isPartyInPeaceMode = true;

        foreach (Creature creature in Dungeon.Instance.GetCreatures())
        {
            // continue if dead
            if (!creature.IsAlive)
            {
                continue;
            }

            // check is see party & starting to chase them
            if (!creature.IsChasing)
            {
                if (SightAlgorithm.CanSee(creature.Position, Party.Instance.Position))
                {
                    creature.IsChasing = true;
                }
            }

            // continue if not chasing
            if (!creature.IsChasing)
            {
                creature.ResetActionUnits(); // if not chasing, fill all action points
                continue;
            }

            _isPartyInPeaceMode = false;

            // cancel the travel of the party
            _partyTargetPosition = Position.NullPosition;

            // if close to party - melee
            if (creature.Position.DistanceTo(Party.Instance.Position) == 1)
            {
                Creature randomPartyMember = Party.Instance.GetRandomLiveMember();
                if (randomPartyMember != null)
                {
                    creature.MeleeAttack(randomPartyMember);
                }
            }
            else // otherwise, move toward party
            {
                Position nextPosition = WalkingAlgorithm.GetNextPosition(creature.Position, Party.Instance.Position);
                if (nextPosition != Position.NullPosition)
                {
                    DungeonTile nextTile = nextPosition.DungeonTile;
                    if (nextTile != null)
                    {
                        Debug.Log(creature.name + " move");
                        Dungeon.Instance.PutDungeonObjectInTile(creature, nextTile);
                        creature.PayWalkCost();
                    }
                }
            }
        }

        // end of creatures turn...
        _creaturesTurn = false;

        // save area
        Dungeon.Instance.SaveCurrentArea();

        // TODO: prepare party should be after monsters turn.. but it blinks - deal with it!
        // preparePartyForNextTurn();
    }