Exemplo n.º 1
0
    void ReevaluateTarget()
    {
        var player = LevelCoordinator.GetPlayer();
        var loot   = LevelCoordinator.GetClosestLoot(transform);
        var mob    = LevelCoordinator.GetClosestMob(transform);

        if (player == null)
        {
            Debug.LogWarning("No player found, player ded or scene was not initialised correctly");
            return;
        }

        if (state == State.PlayerAggro)
        {
            // If player is killed, this function should not be called
            Debug.Assert(target != null, "Target should always be defined when aggroed to a player");

            // Can only be compelled by loot in vision
            if (loot != null && CanSee(loot))
            {
                state  = State.LootAggro;
                target = loot;
            }
            return;
        }

        // Once aggroed to loot or mob, it won't retarget until its picked up or killed
        if (target != null)
        {
            return;
        }

        if (loot != null && CanSee(loot))
        {
            state  = State.LootAggro;
            target = loot;
            return;
        }

        // If there is no more mobs on the map, always targets player unless there is loot
        if (CanSee(player) || mob == null)
        {
            state  = State.PlayerAggro;
            target = player;
            return;
        }

        if (mob != null)
        {
            state  = State.MobAggro;
            target = mob;
            return;
        }
    }
Exemplo n.º 2
0
 // Aggro to player when he channels portal
 void OnStartPortal(GameMessage msg)
 {
     state  = State.PlayerAggro;
     target = LevelCoordinator.GetPlayer();
 }