Пример #1
0
    IEnumerator SlowTime()
    {
        Debug.Log("In slow time");
        coins.coinsColected -= 3;
        inSlowTimePower      = true;

        HaltAllPowerUps();
        displayCoins.text = $"{coins.coinsColected}";

        var dialCreated = Instantiate(dial, canvas.transform, false);

        dialCreated.GetComponent <Dial>().timeLeft   = slowTime;
        dialCreated.GetComponent <Dial>().totalTime  = slowTime;
        dialCreated.GetComponent <Dial>().startTimer = true;

        Debug.Log("Slowing time down");

        gameTimeManager.SlowTimeDown(slowness);

        yield return(new WaitForSecondsRealtime(slowTime));

        Debug.Log("Done Slowing time down");

        UpdateDisplayCoins();               // Check new status of power ups and their validation state.

        CheckPowers();

        Destroy(dialCreated, 0.1f);
        inSlowTimePower = false;
        gameTimeManager.NormalTimeRestore();  // FIX when player is within in and out then dont restore normal time!

        yield break;
    }
Пример #2
0
    public void LifeLost()
    {
        gameTime.HaltTime();

        LifeTracker.instance.LostLife();

        if (LifeTracker.instance.isGameOver == false)
        {
            Debug.Log("Made it here");
            gameTime.NormalTimeRestore();
        }
        else
        {
            // TODO: Call Game Over
            Debug.Log("In GAME OVER in GAMEMANAGER");
            gameTime.HaltTime();
        }
    }
Пример #3
0
    public IEnumerator Shoot()
    {
        // PreFab shooting
        // Instantiate(bulletPrefab, firePoint.transform.position, firePoint.transform.rotation);

        yield return(StartCoroutine(DisplayTarget()));

        inShoot = true;

        laserBeam.DrawInitialPredictions(firePoint.position, firePoint.forward, 7, 7, bulletLine);
        laserBeam.DisplayLines();
        laserBeam.ClearList();

        //ray = new Ray(firePoint.position, firePoint.forward + new Vector3(0, 0, deviation));

        //Physics.Raycast(ray, out RaycastHit hit);

        //if (hit.collider != null)
        //{
        //    Debug.Log($"Shooter hit: {hit.collider.gameObject.name}, Shooter name: {gameObject.name}");

        //    if (coinManager.inShieldPower)
        //    {
        //        inShoot = true;
        //        Debug.Log("In Shoot when shield is ON");
        //        bulletLine.SetPosition(0, ray.origin);
        //        bulletLine.SetPosition(1, hit.point);
        //        inShieldAfterShot = true;
        //        bulletLine.endColor = Color.red;
        //    }

        //    else if (hit.collider.gameObject.name == "Player")
        //    {
        //        Debug.Log("hit the player!");

        //        gameTimeManager.HaltTime();

        //        bulletLine.SetPosition(0, ray.origin);
        //        bulletLine.SetPosition(1, hit.point);
        //        bulletLine.SetPosition(2, (hit.point + (reflectionDepth * Vector3.Reflect(firePoint.forward + new Vector3(0, 0, deviation), hit.normal))));
        //    }
        //    else if (hit.collider.gameObject.name == "RightShield" || hit.collider.gameObject.name == "LeftShield")
        //    {
        //        //Debug.Log("Shield Touch");
        //        inShoot = true;

        //        bulletLine.SetPosition(0, ray.origin);
        //        bulletLine.SetPosition(1, hit.point);
        //        bulletLine.SetPosition(2, (hit.point + (reflectionDepth * Vector3.Reflect(firePoint.forward + new Vector3(0, 0, deviation), hit.normal))));
        //    }
        //    else
        //    {

        //        Debug.Log("SOME target is hit");
        //        if((Convert.ToInt32(hit.collider.gameObject.tag) != targetIndex[index] - 4) && (Convert.ToInt32(hit.collider.gameObject.tag) != targetIndex[index] - 5))
        //            gameTimeManager.HaltTime();

        //        bulletLine.SetPosition(0, ray.origin);
        //        bulletLine.SetPosition(1, hit.point);
        //        bulletLine.SetPosition(2, (hit.point + (reflectionDepth * Vector3.Reflect(firePoint.forward + new Vector3(0, 0, deviation), hit.normal))));


        //    }
        //}
        //else
        //{
        //    Debug.Log("NONE of the objects hit");
        //    bulletLine.SetPosition(0, ray.origin);
        //    bulletLine.SetPosition(1, ray.origin + (ray.direction * 10));
        //    bulletLine.SetPosition(2, bulletLine.GetPosition(1));
        //}

        bulletLine.enabled = true;
        index++;
        yield return(new WaitForSeconds(0.1f));

        bulletLine.enabled = false;


        gameTimeManager.NormalTimeRestore();
        inShoot           = false;
        inShieldAfterShot = false;
    }