Пример #1
0
    void PickUpItemAttributeUpdate(ref int playerAttribute, Collider2D collider, int attribute)
    {
        if (playerAttribute >= 100)
        {
            return;
        }

        PickUp pickUp = collider.GetComponent <PickUp>();

        playerAttribute = Mathf.Min(100, playerAttribute + pickUp.GetValue());
        GameController.Instance.PlayerAttributeUpdate(attribute);
        Destroy(collider.gameObject);
    }
Пример #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PickUp pickUp = collision.GetComponent <PickUp>();

        if (pickUp == null)
        {
            return;
        }
        else
        {
            ui.AddScore(scoreXCrate);

            switch (pickUp.GetPickupType())
            {
            case PickUp.PickUps.food:
                if (inmateAssigned.Length > 1)
                {
                    foreach (InmateAI inmate in inmateAssigned)
                    {
                        inmate.AddHunger(pickUp.GetValue() / inmateAssigned.Length);
                    }
                }
                else
                {
                    inmateAssigned[0].AddHunger(pickUp.GetValue());
                }
                break;

            case PickUp.PickUps.meds:
                if (inmateAssigned.Length > 1)
                {
                    foreach (InmateAI inmate in inmateAssigned)
                    {
                        inmate.AddHealth(pickUp.GetValue() / inmateAssigned.Length);
                    }
                }
                else
                {
                    inmateAssigned[0].AddHealth(pickUp.GetValue());
                }
                break;

            case PickUp.PickUps.water:
                if (inmateAssigned.Length > 1)
                {
                    foreach (InmateAI inmate in inmateAssigned)
                    {
                        inmate.AddThirst(pickUp.GetValue() / inmateAssigned.Length);
                    }
                }
                else
                {
                    inmateAssigned[0].AddThirst(pickUp.GetValue());
                }
                break;

            default:

                print("not yet implemented");
                break;
            }

            FindObjectOfType <SoundManager>().PlaySound("powerUp");

            Destroy(pickUp.gameObject);
        }
    }