Exemplo n.º 1
0
    public static void OnDeath(Player.DeathType type, bool dead)
    {
        switch (type)
        {
        case Player.DeathType.Boundary:
            DoDeath(_i._deathsBoundary, _i._quickDeathBoundary, dead);
            break;

        case Player.DeathType.Vehicle:
            DoDeath(_i._deathsVehicle, _i._quickDeathVehicle, dead);
            break;

        case Player.DeathType.Fuel:
            DoDeath(_i._deathsFuel, _i._quickDeathFuel, dead);
            break;

        case Player.DeathType.WrongWay:
            DoDeath(_i._deathsWrongWay, _i._quickDeathWrongWay, dead);
            break;

        case Player.DeathType.Sanity:
            DoDeath(_i._deathsSanity, _i._quickDeathSanity, dead);
            break;
        }
    }
Exemplo n.º 2
0
    public static void OnPlayerDie(Player.DeathType type)
    {
        if (_i._firstRoundabout)
        {
            _i.StartCoroutine(_Respawn());
        }
        else if (_i._lives == 0)
        {
            _i._dead = true;
        }
        else
        {
            --_i._lives;
            _i.StartCoroutine(_Respawn());
        }

        if (_i._dead)
        {
            _i._onDie.Invoke();
            if (!Roundabout.Active.OffsetCamera)
            {
                var camEnd = Camera.main.transform.position + Vector3.right * 10;
                _i.StartCoroutine(MoveCamera(_i._camDeathTime, camEnd, () => {
                    DeathsUi.OnDeath(type, true);
                }));
            }
            else
            {
                DeathsUi.OnDeath(type, true);
            }
        }
        else
        {
            _i._onCrash.Invoke();
            DeathsUi.OnDeath(type, false);
        }

        IEnumerator _Respawn()
        {
            yield return(new WaitForSeconds(_i._respawnTime));

            Destroy(Player.Instance.gameObject);
            yield return(null);

            var player = Instantiate <Player>(_i._playerPrefab);

            player.transform.position = Polar.FromPolar(0, Roundabout.Active.RadiusInner, Roundabout.Active.transform.position);
            player.transform.forward  = Polar.PolarForward(0, Roundabout.Active.RadiusInner);
        }
    }