コード例 #1
0
 private void UpdateResource(int amount, Collectable.CollectableType type)
 {
     if (type == _type)
     {
         _text.text = amount.ToString();
     }
 }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: musickgm/Maze-Game
    /// <summary>
    /// Handles collectable logic and feeds coroutines if a powerup.
    /// </summary>
    /// <param name="collectionType"></param> What type of collectable?
    /// <param name="clip"></param> What audio clip to play?
    public void CollectObject(Collectable.CollectableType collectionType, AudioClip clip)
    {
        GetComponent <AudioSource>().PlayOneShot(clip, 0.7f);
        switch (collectionType)
        {
        case Collectable.CollectableType.Coin:
            score += coinValue;
            break;

        case Collectable.CollectableType.Camera:
            if (minimapCoroutine != null)
            {
                StopCoroutine(minimapCoroutine);
            }
            minimapCoroutine = MiniMap();
            StartCoroutine(minimapCoroutine);
            break;

        case Collectable.CollectableType.Invisible:
            if (invisibleCoroutine != null)
            {
                StopCoroutine(invisibleCoroutine);
            }
            invisibleCoroutine = InvisibleWalls();
            StartCoroutine(invisibleCoroutine);
            break;

        case Collectable.CollectableType.Objective:
            FinishGame();
            break;
        }
    }
コード例 #3
0
 private void WarnListeners(Collectable.CollectableType type)
 {
     foreach (Listener listener in listeners)
     {
         listener.OnPlayerCollectedSomething(type);
     }
 }
コード例 #4
0
 public PlayerStats(int Score = 0, int Lives = 3)
 {
     this.Score      = Score;
     this.Lives      = Lives;
     LastCollectable = Collectable.CollectableType.none;
     GameState       = GameStates.game_running;
 }
コード例 #5
0
    private void OnTriggerEnter(Collider col)
    {
        Debug.Log("Colliding trigger with: " + col.transform.parent);
        if (col.transform.tag == "Death")// ||
        //col.transform.parent?.transform.tag == "Rock" ||
        //col.transform.parent?.transform.parent.tag == "Prop")
        {
            gameController.Death();
        }

        if (col.gameObject.name == "EpicBigChungusFloor")
        {
            Debug.Log("Hello");
            playerController.OnWin();
        }

        if (col.transform.tag == "Collectable")
        {
            Collectable collect = col.transform.parent.gameObject.GetComponent <Collectable>();
            Collectable.CollectableType ctype = collect.collectableType;
            Debug.Log("Collectable found: " + ctype);
            PlayerPrefs.SetFloat(collect.collectableType.ToString() + collect.phase, 1);

            Destroy(col.transform.parent.gameObject);
        }
    }
コード例 #6
0
ファイル: GameManager.cs プロジェクト: vband/MePoSaLi
    public override void OnPlayerCollectedThreeLetters(Collectable.CollectableType t)
    {
        switch (t)
        {
        case Collectable.CollectableType.Meme:
            playerCollectedTheeMs = true;
            break;

        case Collectable.CollectableType.P**n:
            playerCollectedThreePs = true;
            break;
        }
    }
コード例 #7
0
    public override void OnPlayerCollectedSomething(Collectable.CollectableType t)
    {
        if (t == type)
        {
            InstantiateLetter();

            if (listOfLetters.Count == 3)
            {
                WarnListeners_TreeLetters();
            }

            else if (listOfLetters.Count == 4)
            {
                WarnListeners_FourLetters();
            }
        }
    }
コード例 #8
0
    public void UpdateResource(int amount, Collectable.CollectableType resourceType)
    {
        switch (resourceType)
        {
        case Collectable.CollectableType.OXYGEN:
            _oxygenAmount += amount;

            if (_oxygenAmount < 0)
            {
                _oxygenAmount = 0;
            }

            ResourcesUpdated?.Invoke(_oxygenAmount, Collectable.CollectableType.OXYGEN);

            break;

        case Collectable.CollectableType.FUEL:
            _fuelAmount += amount;
            ResourcesUpdated?.Invoke(_fuelAmount, Collectable.CollectableType.FUEL);
            break;
        }
    }
コード例 #9
0
 public virtual void OnPlayerCollectedSomething(Collectable.CollectableType t)
 {
 }
コード例 #10
0
 public virtual void OnPlayerCollectedThreeLetters(Collectable.CollectableType t)
 {
 }
コード例 #11
0
    public void RequestLootsplosion(Vector3 a_position, int minAmount, int maxAmount, Collectable.CollectableType a_type)
    {
        for (int i = 0; i < m_pool.Count; ++i)
        {
            if (m_pool[i][0].m_script.m_type == a_type)
            {
                //found correct type of collectible

                //dig in
                int spawnAmount = Random.Range(minAmount, maxAmount);

                for (int j = 0; j < spawnAmount; ++j)
                {
                    Vector3 forceVector = Random.onUnitSphere;
                    forceVector.y = 0;
                    GameObject loot = FindInactive(m_pool[i]);

                    if (loot != null)
                    {
                        loot.transform.position = a_position + forceVector.normalized;
                        loot.SetActive(true);

                        Rigidbody rb = loot.GetComponent <Rigidbody>();

                        if (rb != null)
                        {
                            rb.AddForce(forceVector.normalized * m_lootsplosionForce, ForceMode.Impulse);
                        }
                    }
                }
                break;
            }
        }
    }