示例#1
0
 void Start()
 {
     imageToToggle         = GetComponent <MaskableGraphic> ();
     imageToToggle.enabled = visibleAfterEnding;
     durationTimer         = new CounterTimer(duration);
     durationTimer.Update(duration);
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (EEGManager.IsInitialized() && outline && raycastTimer.Finished)
        {
            raycastTimer.Reset();
            RaycastHit hit;
            Vector3    dir = ((EEGGameManager.Instance.player.transform.position + Vector3.up * 0.2f) - transform.position);
            if (Physics.Raycast(transform.position + (dir.normalized * 0.5f), dir, out hit, EEGGameManager.Instance.hearingDistance))
            {
                if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Wall"))
                {
                    foreach (MaterialSwitcher s in materialSwitchers)
                    {
                        s.SwitchToAlternative();
                    }
                }
                else
                {
                    foreach (MaterialSwitcher s in materialSwitchers)
                    {
                        s.SwitchToMain();
                    }
                }
            }
        }

        raycastTimer.Update(Time.deltaTime);
    }
示例#3
0
 // Update is called once per frame
 void Update()
 {
     recoilTimer.Update(Time.deltaTime);
     if (recoilTimer.Finished)
     {
         dx = 0;
         dy = 0;
     }
 }
示例#4
0
    void Update()
    {
        if (durationTimer.Finished && blinking)
        {
            blinking = false;
            CancelInvoke();
            imageToToggle.enabled = visibleAfterEnding;
        }

        durationTimer.Update(Time.deltaTime);
    }
示例#5
0
    void Start()
    {
        base.OnStart();
        coolDownTimer = new CounterTimer(CoolDown);
        coolDownTimer.Update(CoolDown);

        reloadTimer = new CounterTimer(ReloadTime);
        reloadTimer.Update(ReloadTime);
        rounds          = magSize;
        remainingRounds = (magsCount - 1) * magSize;
    }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        if (playing && !waiting)
        {
            StartCoroutine(Play());
        }

        if (outline.Outline && !exploded)
        {
            hitCollider.enabled = true;
            mesh.enabled        = true;
        }

        if (raycastTimer.Finished && playerInRange != null && CheckVisibility(playerInRange, triggerDistance * 1.2f))
        {
            Explode();
        }

        raycastTimer.Update(Time.deltaTime);
    }
示例#7
0
    // Update is called once per frame
    void Update()
    {
        if (Status == Spo2GameStatus.Playing)
        {
            if (Input.GetKeyDown(KeyCode.P))
            {
                Status = Spo2GameStatus.Paused;
                return;
            }


            if (remainingZombies <= 0)
            {
                if (wave == waves.Count)
                {
                    Status = Spo2GameStatus.PlayerWins;
                    return;
                }

                wave += 1;
                SoundManager.Instance.PlayClip(newWaveClip);
                waveTimer.Reset();
                remainingZombies = waves [wave - 1];
                waveEnded        = true;
                spawnedZombies   = 0;

                if (healthCount == 0)
                {
                    healthCount = spawnItems(healthSpawnLocations, minAmmoSpawn, maxAmmoSpawn, ItemType.HEALTH);
                }
            }

            if (ammoCount == 0)
            {
                ammoCount = spawnItems(ammoSpawnLocations, minAmmoSpawn, maxAmmoSpawn, ItemType.AMMO);
            }

            if (waveEnded && waveTimer.Finished)
            {
                waveEnded = false;
                Spawn();
            }

            if (!waveEnded && spawnTimer.Finished && spawnedZombies < waves [wave - 1])
            {
                Spawn();
            }

            spawnTimer.Update(Time.deltaTime);
            waveTimer.Update(Time.deltaTime);

            if (player.health <= 0)
            {
                Status = Spo2GameStatus.GameOver;
            }
        }
        else if (Status == Spo2GameStatus.Paused)
        {
            if (Input.GetKeyDown(KeyCode.P))
            {
                Status = Spo2GameStatus.Playing;
                return;
            }
        }
    }
示例#8
0
    // Update is called once per frame
    void Update()
    {
        if (training)
        {
            float remainingTime      = statusTimer.Length - statusTimer.CurrentTime;
            float totalRemainingTime = trainingTimer.Length - trainingTimer.CurrentTime;

            EEGUIManager uiManager = EEGUIManager.Instance;
            uiManager.trainingTimer = ((int)Mathf.Min((remainingTime), totalRemainingTime));
            uiManager.remainingTime = totalRemainingTime;

            if (!beepPlayed && remainingTime < 1.3f && !(totalRemainingTime < 1.3f))
            {
                SoundManager.Instance.PlayClip(trainingBeep);
                if (Processor.Status == EyesStatus.OPEN)
                {
                    StartCoroutine(PlayDelayed());
                    uiManager.actionText = "Cierra los ojos!";
                }
                else
                {
                    uiManager.actionText = "Abre los ojos!";
                }
                uiManager.trainingPanel.actionText.GetComponent <Blink> ().StartBlinking();
                beepPlayed = true;
            }

            if (trainingTimer.Finished)
            {
                Processor.Training = false;
                uiManager.Training(false);
                EEGGameManager.Instance.Status = GameStatus.Playing;
                Trained = true;
            }
            else if (statusTimer.Finished)
            {
                if (Processor.Status == EyesStatus.OPEN)
                {
                    Processor.Status     = EyesStatus.CLOSED;
                    uiManager.statusText = "Manten los ojos cerrados";
                }
                else
                {
                    Processor.Status     = EyesStatus.OPEN;
                    uiManager.statusText = "Manten los ojos abiertos";
                }
                beepPlayed  = false;
                statusTimer = new CounterTimer(Random.Range(minStatusDuration, maxStatusDuration));
            }

            statusTimer.Update(Time.deltaTime);
            trainingTimer.Update(Time.deltaTime);
        }

        if (reading && Processor != null)
        {
            Processor.Update();

            // If the player moves, he stops hearing
            if (Vector3.Distance(player.transform.position, previousPlayerPos) > 0.005)
            {
                StatusCount = 0;
            }

            previousPlayerPos = player.transform.position;
        }
    }
示例#9
0
 // Use this for initialization
 void Start()
 {
     recoilTimer = new CounterTimer(RecoilDuration);
     recoilTimer.Update(RecoilDuration);
 }
示例#10
0
    // Update is called once per frame
    void Update()
    {
        if (health > 0 && currentTarget != null)
        {
            Vector3 dir = (player.transform.position - transform.position);

            if (patrolMode && !playerFound && player.enabled)
            {
                if (Agent.remainingDistance < 0.1)
                {
                    patrolIndex++;
                    patrolIndex  %= patrols.Count;
                    currentTarget = patrols [patrolIndex];
                }

                if (raycastTimer.Finished)
                {
                    raycastTimer.Reset();
                    RaycastHit hit;
                    Vector3    rayOrigin = transform.position;
                    dir.y = 0.2f;
                    float dot      = Vector3.Dot(transform.forward, dir);
                    float distance = Vector3.Distance(transform.position, player.transform.position);
                    if (distance <= maxViewingDistance && Physics.Raycast(rayOrigin, dir, out hit, maxViewingDistance))
                    {
                        if (dot >= 0 || distance <= hearingDistance)
                        {
                            FPSPlayer player = hit.collider.GetComponent <FPSPlayer> ();
                            if (player != null)
                            {
                                PlayerFound();
                            }
                        }
                    }
                }
            }
            else if (playerFound)
            {
                dir.y = 0.2f;
                float dot = Vector3.Dot(transform.forward, dir);
                if (!attacking && Vector3.Distance(player.transform.position, transform.position) <= (stoppingDistance * 1.2f) && dot >= 0)
                {
                    StartCoroutine(Attack());
                }
            }
            if (Agent.enabled)
            {
                Agent.destination = currentTarget.position;
            }

            if (animator.enabled)
            {
                animator.SetFloat("Speed", Agent.speed);
            }

            if (growlTimer.Finished && !AudioSrc.isPlaying)
            {
                growlTimer.Reset();
                AudioSrc.PlayOneShot(growlClip);
                AudioSrc.volume = 1;
            }

            growlTimer.Update(Time.deltaTime);
            raycastTimer.Update(Time.deltaTime);
        }
    }
示例#11
0
    // Update is called once per frame
    void Update()
    {
        if (!started)
        {
            processorContainer = FindObjectOfType <ProcessorContainer> ();
            if ((processorContainer != null && processorContainer.processor != null))
            {
                EEGManager.Instance.Processor = processorContainer.processor;
                EEGManager.Instance.Trained   = true;
                Status = GameStatus.Playing;
            }
            else
            {
                Status = GameStatus.Training;
            }

            started = true;
        }

        switch (status)
        {
        case GameStatus.Playing:
            if (Input.GetKeyDown(KeyCode.P))
            {
                Status = GameStatus.Paused;
                return;
            }

            if (player.health <= 0)
            {
                Status = GameStatus.GameOver;
                return;
            }

            EyesStatus status = EEGManager.Instance.Status;

            if (status == EyesStatus.CLOSED)
            {
                if (previousStatus == EyesStatus.OPEN)
                {
                    visibilityOn = false;
                    foreach (OutlineObject visibleObject in activeObjects)
                    {
                        visibleObject.Outline = false;
                    }
                    inactiveObjects.UnionWith(activeObjects);
                    activeObjects.Clear();
                }

                visibilityTime += Time.deltaTime;

                if (checkingTimer.Finished)
                {
                    checkingTimer.Reset();
                    foreach (Bomb bomb in bombs)
                    {
                        float distance = Vector3.Distance(player.transform.position, bomb.transform.position);
                        if (distance <= hearingDistance)
                        {
                            if (!activeBombs.Contains(bomb))
                            {
                                bomb.PlayBeepSound();
                                activeBombs.Add(bomb);
                            }
                        }
                        else
                        {
                            if (activeBombs.Contains(bomb))
                            {
                                activeBombs.Remove(bomb);
                                bomb.StopPlaying();
                            }
                        }
                    }

                    foreach (OutlineObject inactiveObject in inactiveObjects)
                    {
                        float distance = Vector3.Distance(player.transform.position, inactiveObject.transform.position);
                        if (distance <= hearingDistance)
                        {
                            activeObjects.Add(inactiveObject);
                        }
                    }

                    inactiveObjects.RemoveWhere(x => activeObjects.Contains(x));
                }
            }
            else
            {
                foreach (Bomb bomb in activeBombs)
                {
                    bomb.StopPlaying();
                }
                activeBombs.Clear();

                if (previousStatus == EyesStatus.CLOSED)
                {
                    visibilityTimer = new CounterTimer(Mathf.Min(visibilityTime + EEGManager.Instance.minThreshold, maxVisibilityDuration));
                    foreach (OutlineObject activeObject in activeObjects)
                    {
                        activeObject.Outline = true;
                    }
                    visibilityOn = true;
                }
                else
                {
                    if (visibilityOn && visibilityTimer.Finished)
                    {
                        visibilityOn = false;
                        foreach (OutlineObject activeObject in activeObjects)
                        {
                            activeObject.Outline = false;
                        }
                        inactiveObjects.UnionWith(activeObjects);
                        activeObjects.Clear();
                    }
                }

                if (visibilityOn)
                {
                    visibilityTimer.Update(Time.deltaTime);
                }

                visibilityTime = 0;
            }

            previousStatus = status;
            checkingTimer.Update(Time.deltaTime);
            break;

        case GameStatus.Paused:
            if (Input.GetKeyDown(KeyCode.P))
            {
                Status = GameStatus.Playing;
                return;
            }
            break;

        case GameStatus.Training:
            if (Input.GetKey(KeyCode.K))
            {
                EEGManager.Instance.StopTraining();
            }
            break;

        default:

            break;
        }
    }
示例#12
0
    // Update is called once per frame
    void Update()
    {
        coolDownTimer.Update(Time.deltaTime);
        reloadTimer.Update(Time.deltaTime);

        if (Input.GetKeyDown(KeyCode.L))
        {
            flashlight.enabled = !flashlight.enabled;
            MainAudioSource.PlayOneShot(flashlightClip);
        }

        if (Input.GetKeyDown(reloadKey) && reloadTimer.Finished)
        {
            if (remainingRounds >= 1)
            {
                gunAudioSource.PlayOneShot(ReloadClip);
                reloadTimer.Reset();
                int reloadCount = Mathf.Min(magSize - rounds, remainingRounds);
                rounds          += reloadCount;
                remainingRounds -= reloadCount;
            }
            else
            {
                gunAudioSource.PlayOneShot(GunEmptyClip);
            }
        }

        if (reloadTimer.Finished && coolDownTimer.Finished && Input.GetMouseButtonDown(0))
        {
            if (rounds <= 0)
            {
                gunAudioSource.PlayOneShot(GunEmptyClip);
            }
            else
            {
                Animator.SetTrigger("Fire");
                shellEffect.Play();
                coolDownTimer.Reset();
                gunAudioSource.PlayOneShot(GunShotClip);
                rounds--;
                LookManager.Instance.Recoil();
                Vector3 rayOrigin = FPSCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f));

                RaycastHit hit;

                if (Physics.Raycast(rayOrigin, FPSCam.transform.forward, out hit, Range))
                {
                    HitBox hitBox = hit.collider.GetComponent <HitBox> ();
                    // If there was a health script attached
                    if (hitBox != null)
                    {
                        // Call the damage function of that script, passing in our gunDamage variable
                        hitBox.Hit(hit);
                    }
                    else
                    {
                        BombHitBox bombHitBox = hit.collider.GetComponent <BombHitBox> ();
                        if (bombHitBox != null)
                        {
                            Bomb bomb = bombHitBox.transform.parent.gameObject.GetComponent <Bomb> ();
                            bomb.Explode();
                        }
                    }
                }
            }
        }
    }