コード例 #1
0
    private void OnTriggerExit2D(Collider2D other)
    {
        string OtherTag = other.gameObject.tag;

        Debug.Log(OtherTag);

        switch (OtherTag)
        {
        case "Oxygen":
            OxygenTowerBehavior OxygenRef = other.GetComponent <OxygenTowerBehavior>();
            bInOxygenArea = false;
            Debug.Log("Left the oxygen area");
            StopCoroutine(ReceivingOxygen(OxygenRef));
            break;

        case "Ship":
            bInOxygenArea = false;
            StopCoroutine(ReceivingOxygenFromShip(ship));
            break;

        case "Health":
            HealthTowerBehavior HealthRef = other.GetComponent <HealthTowerBehavior>();
            bInHealthArea = false;
            StopCoroutine(ReceivingHealth(HealthRef));
            break;
        }
    }
コード例 #2
0
    public IEnumerator ReceivingHealth(HealthTowerBehavior TowerRef)
    {
        if (!bAlreadyInHealth)
        {
            bAlreadyInHealth     = true;
            Health               = Mathf.Clamp(Health + 20, 0, MaxHealth);
            TowerRef.HealthLevel = Mathf.Clamp(TowerRef.HealthLevel - 10, 0, 100);

            yield return(new WaitForSecondsRealtime(1f));

            bAlreadyInHealth = false;
            if ((bInHealthArea) && TowerRef.HealthLevel > 0)
            {
                StartCoroutine(ReceivingHealth(TowerRef));
            }

            yield return(new WaitForSecondsRealtime(1f));

            bAlreadyInHealth = false;
        }
    }
コード例 #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        string OtherTag = other.gameObject.tag;


        switch (OtherTag)
        {
        case "Resource":
            //if (other.gameObject.CompareTag("Resource"))

            //Resources += 15;
            SoundManager.PlaySound("Resource");
            Destroy(other.gameObject);

            break;

        case "Oxygen":

            OxygenTowerBehavior OxygenRef = other.GetComponent <OxygenTowerBehavior>();
            bInOxygenArea = true;
            if (OxygenRef.oxygenLevel > 0)
            {
                StartCoroutine(ReceivingOxygen(OxygenRef));
            }

            break;

        case "Ship":
            //ShipResources += Resources;
            //manager.ShipCount += manager.Count;
            if (ship.Health < manager.WinCondition)
            {
                ship.Health  += manager.Count;
                manager.Count = 0;
                SoundManager.PlaySound("ShipRepairSFX");
            }


            //Resources = 0;
            bInOxygenArea = true;
            if (ship.Oxygen > 0)
            {
                StartCoroutine(ReceivingOxygenFromShip(ship));
            }
            // SoundManager.PlaySound("ShipFix");
            break;

        case "Health":

            HealthTowerBehavior HealthRef = other.GetComponent <HealthTowerBehavior>();
            bInHealthArea = true;
            if (HealthRef.HealthLevel > 0)
            {
                StartCoroutine(ReceivingHealth(HealthRef));
            }

            break;

        case "EnemyProjectile":
            Health -= 10f;
            SoundManager.PlaySound("PlayerHitSFX");
            break;

        case "AmmoTower":
            weapon.bullets = 99;
            GrenadeCount   = 3;
            SoundManager.PlaySound("ReloadSFX");
            break;
        }
    }