public void End()
    {
        foreach (TrackSegment seg in m_Segments)
        {
            Destroy(seg.gameObject);
        }

        for (int i = 0; i < m_PastSegments.Count; ++i)
        {
            Destroy(m_PastSegments[i].gameObject);
        }

        m_Segments.Clear();
        m_PastSegments.Clear();

        characterController.End();

        gameObject.SetActive(false);
        Destroy(characterController.character.gameObject);
        characterController.character = null;

        Camera.main.transform.SetParent(null);

        characterController.gameObject.SetActive(false);

        for (int i = 0; i < parallaxRoot.childCount; ++i)
        {
            Destroy(parallaxRoot.GetChild(i).gameObject);
        }
    }
示例#2
0
    public void End()
    {
        foreach (TrackSegment seg in m_Segments)
        {
            Destroy(seg.gameObject);
        }

        for (int i = 0; i < m_PastSegments.Count; ++i)
        {
            Destroy(m_PastSegments[i].gameObject);
        }

        m_Segments.Clear();
        m_PastSegments.Clear();

        AICharacterController.End();
        if (humanCharacterController != null)
        {
            humanCharacterController.End();
        }

        gameObject.SetActive(false);
        Destroy(AICharacterController.character.gameObject);
        AICharacterController.character = null;
        if (humanCharacterController != null)
        {
            Destroy(humanCharacterController.character.gameObject);
            humanCharacterController.character = null;
        }

        Camera.main.transform.SetParent(null);

        AICharacterController.gameObject.SetActive(false);
        if (humanCharacterController != null)
        {
            humanCharacterController.gameObject.SetActive(false);
        }

        for (int i = 0; i < parallaxRoot.childCount; ++i)
        {
            Destroy(parallaxRoot.GetChild(i).gameObject);
        }

        //if our consumable wasn't used, we put it back in our inventory
        if (AICharacterController.inventory != null)
        {
            PlayerData.instance.Add(AICharacterController.inventory.GetConsumableType());
            AICharacterController.inventory = null;
        }
    }
    public void End()
    {
        foreach (TrackSegment seg in m_Segments)
        {
            Addressables.ReleaseInstance(seg.gameObject);
            _spawnedSegments--;
        }

        for (int i = 0; i < m_PastSegments.Count; ++i)
        {
            Addressables.ReleaseInstance(m_PastSegments[i].gameObject);
        }

        m_Segments.Clear();
        m_PastSegments.Clear();

        characterController.End();

        gameObject.SetActive(false);
        Addressables.ReleaseInstance(characterController.character.gameObject);
        characterController.character = null;

        Camera.main.transform.SetParent(null);
        Camera.main.transform.position = m_CameraOriginalPos;

        characterController.gameObject.SetActive(false);

        for (int i = 0; i < parallaxRoot.childCount; ++i)
        {
            _parallaxRootChildren--;
            Destroy(parallaxRoot.GetChild(i).gameObject);
        }

        //if our consumable wasn't used, we put it back in our inventory
        if (characterController.inventory != null)
        {
            PlayerData.instance.Add(characterController.inventory.GetConsumableType());
            characterController.inventory = null;
        }
    }
示例#4
0
    public void End()
    {
        foreach (TrackSegment seg in m_Segments)
        {
            Destroy(seg.gameObject);
        }

        for (int i = 0; i < m_PastSegments.Count; ++i)
        {
            Destroy(m_PastSegments[i].gameObject);
        }

        m_Segments.Clear();
        m_PastSegments.Clear();

        characterController.End();

        gameObject.SetActive(false);
        Destroy(characterController.character.gameObject);
        characterController.character = null;

        Camera.main.transform.SetParent(null);

        characterController.gameObject.SetActive(false);

        for (int i = 0; i < parallaxRoot.childCount; ++i)
        {
            Destroy(parallaxRoot.GetChild(i).gameObject);
        }

        //如果我们购买的道具没有使用,则放回背包中
        if (characterController.inventory != null)
        {
            PlayerData.instance.Add(characterController.inventory.GetConsumableType());
            characterController.inventory = null;
        }
    }
    protected void OnTriggerEnter(Collider c)
    {
        if (c.gameObject.layer == k_CoinsLayerIndex)
        {
            if (magnetCoins.Contains(c.gameObject))
            {
                magnetCoins.Remove(c.gameObject);
            }

            if (c.GetComponent <Coin>().isPremium)
            {
                Destroy(c.gameObject);
                PlayerData.instance.premium += 1;
                controller.premium          += 1;
                m_Audio.PlayOneShot(premiumSound);
            }
            else
            {
                Coin.coinPool.Free(c.gameObject);
                PlayerData.instance.coins += 1;
                controller.coins          += 1;
                m_Audio.PlayOneShot(coinSound);
            }
        }
        else if (c.gameObject.layer == k_ObstacleLayerIndex)
        {
            if (m_Invincible || controller.IsCheatInvincible())
            {
                if (c.gameObject.tag == "Enemy")
                {
                    PlayerData.instance.coins += 10;
                    controller.coins          += 10;
                    return;
                }
                else if (c.gameObject.tag == "Baricada")
                {
                    sosi.activatedSound = null;
                    controller.powerupSource.Stop();
                    controller.End("nothing");

                    m_Armor = false;
                    return;
                }
            }


            controller.StopMoving();

            c.enabled = false;

            Obstacle ob = c.gameObject.GetComponent <Obstacle>();

            if (ob != null)
            {
                ob.Impacted();
            }
            else
            {
                Destroy(c.gameObject);
            }

            controller.currentLife -= 1;
            controller.character.animator.SetTrigger(s_HitHash);

            if (controller.currentLife > 0)
            {
                m_Audio.PlayOneShot(controller.character.hitSound);
                SetInvincible();
            }
            // The collision killed the player, record all data to analytics.
            else
            {
                m_Audio.PlayOneShot(controller.character.deathSound);

                m_DeathData.character     = controller.character.characterName;
                m_DeathData.themeUsed     = controller.trackManager.currentTheme.themeName;
                m_DeathData.obstacleType  = ob.GetType().ToString();
                m_DeathData.coins         = controller.coins;
                m_DeathData.premium       = controller.premium;
                m_DeathData.score         = controller.trackManager.score;
                m_DeathData.worldDistance = controller.trackManager.worldDistance;
            }
        }
        else if (c.gameObject.layer == k_PowerupLayerIndex)
        {
            Consumable consumable = c.GetComponent <Consumable>();
            if (consumable != null)
            {
                controller.UseConsumable(consumable);
            }
        }
    }