void Fire()
    {
        firing = true;
        NotationTime firingStart = new NotationTime(Metronome.Instance.currentTime);

        firingStart.Add(new NotationTime(0, 0, 1));
        int pointsGained = 0;
        int multiplier   = 0;

        foreach (CubeThumper thump in targetedCubes)
        {
            if (thump != null)
            {
                int lockLength = thump.GetLockLength();
                int fireResult = thump.FireCube(firingStart);
                if (fireResult > 0)
                {
                    pointsGained += fireResult;
                    multiplier++;
                }
                firingStart.Add(new NotationTime(0, 0, lockLength));
            }
        }
        GameManager.gameScore += pointsGained * multiplier;
        timeUntilCanFireAgain  = Metronome.Instance.GetFutureTime(firingStart.bar, firingStart.quarter, firingStart.tick);
        targetedCubes.Clear();
        numberOfLocks = 0;
    }
 public void HandleBlastZoneInput(Vector2 touchPosition)
 {
     if (!tickLock && HasFirepower())
     {
         BlastZone touchedBlastZone = CheckForBlastZones(touchPosition);
         if (touchedBlastZone != null)
         {
             if (touchedBlastZone.CanGrow())
             {
                 touchedBlastZone.GrowNextTick();
                 ticksFired++;
             }
         }
         else if (zoneCount < MAX_ZONES)
         {
             Ray        ray = Camera.main.ScreenPointToRay(new Vector3(touchPosition.x, touchPosition.y, 0));
             RaycastHit hit;
             if (blastCollider.Raycast(ray, out hit, 1000.0F))
             {
                 GameObject zoneMade = GameObject.Instantiate(blastZone, hit.point, Quaternion.identity);
                 BlastZones.Add(zoneMade.GetComponent <BlastZone>());
                 zoneMade.transform.parent = blastZoneParent;
                 zoneMade.GetComponent <BlastZone>().CreateZone(Metronome.Instance.currentTime);
                 ticksFired++;
                 zoneCount++;
             }
         }
         tickUnlockTime = new NotationTime(Metronome.Instance.currentTime);
         tickUnlockTime.Add(new NotationTime(0, 0, 1));
         tickLock = true;
     }
 }
Beispiel #3
0
    public int FireCube(NotationTime toFire)
    {
        hasFired               = true;
        currentHealth         -= lockNum;
        spriteRenderer.enabled = false;
        AudioClip soundToPlay;

        if (Destroyed())
        {
            soundToPlay = destroyClips[UnityEngine.Random.Range(0, destroyClips.Length)];
        }
        else
        {
            soundToPlay = fireClips[UnityEngine.Random.Range(0, fireClips.Length)];
        }
        if (Destroyed())
        {
            NotationTime timeLeft = new NotationTime(toFire);
            timeLeft.Add(new NotationTime(0, 1, 0));
            timeAlive = Metronome.Instance.GetFutureTime(timeLeft.bar, timeLeft.quarter, timeLeft.tick);
            return(scoreValue);
        }

        lockNum = 0;

        return(-1);
    }
 public void BeginGame()
 {
     backgroundLoop.GetComponent <BackgroundMusic>().Init("CaptainPlanetBeach");
     player.speed = 6f;
     UpdateText();
     //Delay before activating game controller
     StartCoroutine(StartController(0.01f));
     ChangeState(GameState.Playing);
     tickUnlockTime = new NotationTime(Metronome.Instance.currentTime);
     tickUnlockTime.Add(new NotationTime(0, 0, 1));
     StartCoroutine(StartSpawn(3f));
     Metronome.tickChangeDelegate += HandleTickChange;
 }
Beispiel #5
0
    public void HandleTickChange(NotationTime currentTime)
    {
        if (currentTime.TimeAsTicks() == nextPlay.TimeAsTicks() - 1)
        {
            double nextPlayTime = Metronome.Instance.GetFutureTime(nextPlay);
            //sources[nextSource].clip = nextClip.clip;
            sources[nextSource].clip   = nextClip.clip;
            sources[nextSource].volume = 0.4f;
            sources[nextSource].PlayScheduled(nextPlayTime);
            //Set next time to play
            currentClip = nextClip;
            nextPlay.Add(currentClip.length);

            nextSource = (nextSource + 1) % sources.Length;
        }
    }