Ejemplo n.º 1
0
    public void kill(Player player)
    {
        if (player.isRespawned)
        {
            currentSceneState.players.Remove(player);
            Debug.Log("Player copy is dead");
            return;
        }
        History.PlayerHistory.PlayerHistoryElement rollBackPlayer = currentPlayerHistory.getPlayback();

        if (rollBackPlayer == null)
        {
            Debug.Log("You lose");
            showDefeat();
            return;
        }

        if (resurectedTimes == maxResurects)
        {
            showDefeat();
            return;
        }

        // Ghost
        var ghost = Instantiate(player);

        rollBackPlayer.position.y = 1.5f;
        ghost.transform.position  = rollBackPlayer.position;
        ghost.currentHealth       = rollBackPlayer.health;
        Debug.Log("Respawn with " + rollBackPlayer.health);
        ghost.respawnWith(currentPlayerHistory);
        ghost.setLightColor(ghostColor);
        ghost.setBorders(limitTopLeft, limitBotRight);
        currentSceneState.players.Add(ghost);


        // Playable player char
        var respawned = Instantiate(player);

        rollBackPlayer.position.y    = 3.0f;
        respawned.transform.position = rollBackPlayer.position;
        respawned.currentHealth      = rollBackPlayer.health;
        respawned.setBorders(limitTopLeft, limitBotRight);
        playerHealthBar.changeSubscription(respawned);
        currentSceneState.players.Add(respawned);

        resurectedTimes++;
        resurectsLeft.text = "" + (maxResurects - resurectedTimes);


        history.needToBePlayed.Add(currentPlayerHistory);
        currentPlayerHistory = new History.PlayerHistory();

        currentSceneState.players.Remove(player);
        Debug.Log("Player is dead");
    }
Ejemplo n.º 2
0
    public void takeNextTarget()
    {
        if (hasHistoryItems())
        {
            History.PlayerHistory.PlayerHistoryElement el = playerHistory.history.Dequeue();
            targetPos = el.position;

            if (el.wasAttacking)
            {
                attack();
            }
        }
        else
        {
            die();
        }
    }