Exemple #1
0
    // Use this for initialization
    void Start()
    {
        SpawnSpeed   = 8.0f;
        IsGamePaused = false;
        GameActive   = true;
        IEnumerator coroutine = SpeedUpCoroutine();

        StartCoroutine(coroutine);
        lastOres = new Ore.OreType[4] {
            Ore.OreType.NONE, Ore.OreType.NONE, Ore.OreType.NONE, Ore.OreType.NONE
        };
        processor       = FindObjectOfType <OreProcessor>();
        player          = FindObjectOfType <Player>();
        wantTimer       = wantTimerSet;
        failTimer       = FailTimerStart;
        nextWholeSecond = FailTimerStart;
        audioSource     = GetComponent <AudioSource>();
    }
Exemple #2
0
 private void HandleGrab()
 {
     //Debug.Log("Grab button pressed.");
     if (myCollider.IsTouching(lastCollider))
     {
         //Debug.Log("Colliders match.");
         if ((carry1 == Ore.OreType.NONE || carry2 == Ore.OreType.NONE) && !IsCarryingUpgrade)
         {
             if (lastCollider.GetComponent <OreBox>() != null)
             {
                 OreBox activeBox = lastCollider.GetComponent <OreBox>();
                 //Debug.Log("Grab used on " + lastCollider.name + " Ore Box (" + activeBox.GetBoxType().ToString() + ").");
                 if (activeBox.TakeOre())
                 {
                     if (carry1 == Ore.OreType.NONE)
                     {
                         carry1 = activeBox.GetBoxType();
                     }
                     else if (carry2 == Ore.OreType.NONE)
                     {
                         carry2 = activeBox.GetBoxType();
                     }
                     //Debug.Log("Now carrying: " + carry1.ToString() + " and " + carry2.ToString() + ".");
                     audioSource.PlayOneShot(grab);
                 }
                 else
                 {
                     //Debug.Log("Could not take ore. Box is empty.");
                     audioSource.PlayOneShot(buzz);
                 }
             }
         }
         else if (IsCarryingUpgrade)
         {
             if (lastCollider.GetComponent <OreBox>() != null)
             {
                 OreBox activeBox = lastCollider.GetComponent <OreBox>();
                 //Debug.Log("Grab used on " + lastCollider.name + " Ore Box (" + activeBox.GetBoxType().ToString() + ").");
                 activeBox.SetCapacity(activeBox.Capacity + 2);
                 //Debug.Log("Upgrade used.");
                 audioSource.PlayOneShot(upgrade_use, 0.8f);
                 IsCarryingUpgrade = false;
             }
         }
         if (lastCollider.GetComponent <UpgradeOTron>() != null)
         {
             UpgradeOTron upgradeOTron = lastCollider.GetComponent <UpgradeOTron>();
             bool         getUpgrade   = false;
             getUpgrade = upgradeOTron.CheckOres(new Ore.OreType[2] {
                 carry1, carry2
             });
             if (getUpgrade)
             {
                 audioSource.PlayOneShot(upgrade, 0.5f);
                 carry1            = Ore.OreType.NONE;
                 carry2            = Ore.OreType.NONE;
                 IsCarryingUpgrade = true;
             }
             else
             {
                 audioSource.PlayOneShot(buzz);
                 if (carry1 != Ore.OreType.NONE)
                 {
                     gameManager.DisplayMessage("Wrong ores! Process them!");
                     audioSource.PlayOneShot(buzz);
                 }
                 else
                 {
                     audioSource.PlayOneShot(buzz);
                 }
             }
         }
         if (lastCollider.GetComponent <OreProcessor>() != null)
         {
             //Debug.Log("Activating Ore Processor.");
             OreProcessor processor = lastCollider.GetComponent <OreProcessor>();
             //Debug.Log("Attempting to deposit Ore " + carry1.ToString() + " and " + carry2.ToString() + " into processor.");
             if (carry1 != Ore.OreType.NONE || carry2 != Ore.OreType.NONE)
             {
                 //Debug.Log("Depositing Ores " + carry1.ToString() + " and " + carry2.ToString() + " into processor.");
                 processor.InsertOres(new Ore.OreType[] { carry1, carry2 });
                 audioSource.PlayOneShot(drop);
                 carry1 = Ore.OreType.NONE;
                 carry2 = Ore.OreType.NONE;
             }
         }
     }
 }