Ejemplo n.º 1
0
    protected override void OnCollectItem(SpawnerScript item)
    {
        //Calls Entity's
        base.OnCollectItem(item);

        //Update the UI
        if (uiScript != null)
        {
            uiScript.SetCollectedItem(item.CurrItem);
        }
    }
Ejemplo n.º 2
0
    //Call this when the player collects the item
    //destroy the item, and reset the spawner
    public void Collect(int a_playerIndex = 0)
    {
        isSpawned        = false;
        isPickedUp       = true;
        timeUntilRespawn = Random.Range(minRespawnTime, maxRespawnTime);

        Destroy(gameObject.transform.GetChild(0).gameObject);

        //loading InGameUIScript here just in case it hasn't been loaded
        if (inGameUIScript == null)
        {
            inGameUIScript = FindObjectOfType <IngameUIScript>();
        }

        inGameUIMultiScript = FindObjectOfType <IngameUIMultiScript>();

        //tell the ui that you've collected this item type (MOVE THIS LINE INTO WHERE THE PLAYER COLLECTS IT)
        //check if we are in Multi or Single mode by checking if the script is active
        GameStateID currState = GameObject.Find("GameManager").GetComponent <GameStateManagerScript>().currState;

        //if we are playing single play mode
        if (currState == GameStateID.InGame)
        {
            //set single play mode's IngameUI to change the item icon
            inGameUIScript.SetCollectedItem(currActivatedItemNum);
        }

        //if we are playing multi play mode
        if (currState == GameStateID.InGameMuilti)
        {
            //set multi play mode's IngameUI to change the item icon
            inGameUIMultiScript.SetCollectedItem(currActivatedItemNum, a_playerIndex);
        }

        totalPickedUpTimes++;
    }