Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        base.OnStart();

        if (!outlined)
        {
            Destroy(GetComponent <OutlineObject>());
        }

        growlClip = GrowlClips[Random.Range(0, GrowlClips.Count)];
        deathClip = deathClips[Random.Range(0, deathClips.Count)];

        growlTimer = new CounterTimer(growlInterval + Random.value);

        raycastTimer = new CounterTimer(raycastInterval);
        patrolMode   = patrols.Count > 1;
        if (patrolMode)
        {
            currentTarget          = patrols[patrolIndex];
            Agent.stoppingDistance = 0;
        }
        else if (player != null)
        {
            currentTarget          = player.transform;
            playerFound            = true;
            Agent.stoppingDistance = stoppingDistance;
        }

        colliders = new List <Collider> (GetComponentsInChildren <Collider>());
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     inRangeHumanoids = new HashSet <Humanoid> ();
     raycastTimer     = new CounterTimer(raycastInterval);
     mesh.enabled     = false;
     outline          = GetComponent <OutlineObject> ();
 }
Esempio n. 3
0
    public void StartTraining(int duration, int port)
    {
        if (this.port != port || processor == null)
        {
            this.port = port;
            if (processor != null)
            {
                processor.StopAndJoin();
                processor = null;
            }
            reader    = new EEGOSCReader(port);
            Processor = new EEGProcessor(reader);
            EEGGameManager.Instance.SetProcessor(processor, false);
            reading = false;
        }
        else
        {
            Processor.Reset();
        }

        trainingTimer      = new CounterTimer(duration);
        statusTimer        = new CounterTimer(Random.Range(minStatusDuration, maxStatusDuration));
        Processor.Status   = EyesStatus.OPEN;
        Processor.Training = true;
        training           = true;
        StartReading();
    }
Esempio n. 4
0
        private void btnGrab_Click(object sender, EventArgs e)
        {
            if (ProxyManager.Proxies.Count != 0)
            {
                try
                {
                    GrabberThread = new Thread(() =>
                    {
                        new Grabber(Decimal.ToInt32(MaxThreads.Value), this).Grab();
                    });

                    GrabberThread.Start();

                    btnGrab.Enabled = false;

                    CounterTimer.Start();

                    MessageBox.Show(
                        "Grabber has started. This can take a while... be patient!",
                        "Info",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                }
                catch
                {
                    ShowErrorMessage("An unknown error occured. Contact Raghav.");
                }
            }
            else
            {
                ShowErrorMessage("You need to import your proxies! Press \"Config...\" on the top left.");
            }
        }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     MaterialSwitcher[] switchers = GetComponentsInChildren <MaterialSwitcher> ();
     materialSwitchers = new List <MaterialSwitcher> (switchers);
     materialSwitchers.AddRange(GetComponents <MaterialSwitcher>());
     raycastTimer = new CounterTimer(raycastInterval);
 }
Esempio n. 6
0
 void Start()
 {
     imageToToggle         = GetComponent <MaskableGraphic> ();
     imageToToggle.enabled = visibleAfterEnding;
     durationTimer         = new CounterTimer(duration);
     durationTimer.Update(duration);
 }
Esempio n. 7
0
 public void StartCounter(int index, int repetitionsNumber, int interval)
 {
     this.repetitionsNumber = repetitionsNumber;
     RepetitionsLabel.Text  = "Ilość powtórzeń: " + repetitionsNumber.ToString();
     IntervalLabel.Text     = "Interwał: " + interval.ToString();
     CounterTimer.Interval  = interval;
     CounterTimer.Start();
     CounterTimer.Tick += CounterTimer_Tick;
     ResultLabel.Text   = "0";
 }
Esempio n. 8
0
        private void CounterTimer_Tick(object sender, EventArgs e)
        {
            ticks += 1;

            ResultLabel.Text = ticks.ToString();

            if (ticks == repetitionsNumber)
            {
                CounterTimer.Stop();
            }
        }
 // Use this for initialization
 void Start()
 {
     Bomb[] a = bombsContainer.GetComponentsInChildren <Bomb> ();
     bombs           = new HashSet <Bomb> (a);
     activeObjects   = new HashSet <OutlineObject> ();
     inactiveObjects = new HashSet <OutlineObject> (FindObjectsOfType <OutlineObject> ());
     activeBombs     = new HashSet <Bomb> ();
     previousStatus  = EyesStatus.NONE;
     checkingTimer   = new CounterTimer(checkingInterval);
     zombies         = new List <Zombie> (zombiesContainer.GetComponentsInChildren <Zombie> ());
 }
Esempio n. 10
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;
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        fpsController        = player.GetComponent <FirstPersonController> ();
        remainingZombies     = 0;
        wave                 = 0;
        spawnLocations       = new List <SpawnLocation>(spawnLocationsContainer.GetComponentsInChildren <SpawnLocation> ());
        ammoSpawnLocations   = new List <ItemSpawnLocation>(ammoSpawnLocationsContainer.GetComponentsInChildren <ItemSpawnLocation> ());
        healthSpawnLocations = new List <ItemSpawnLocation>(healthSpawnLocationsContainer.GetComponentsInChildren <ItemSpawnLocation> ());

        spawnTimer = new CounterTimer(0.5f);
        waveTimer  = new CounterTimer(wavesInterval);
        Status     = Spo2GameStatus.Playing;
    }
Esempio n. 12
0
    private void Spawn()
    {
        int spawnNumber = Random.Range(minSpawnZombies, maxSpawnZombies + 1);

        spawnNumber     = Mathf.Min(spawnNumber, remainingZombies - spawnNumber);
        spawnedZombies += spawnNumber;
        for (int i = 0; i < spawnNumber; i++)
        {
            Zombie zombie = ZombieFactory.Instance.pool.Retrieve();
            zombie.SetPlayer(player);
            SpawnLocation sl = spawnLocations [Random.Range(0, spawnLocations.Count)];
            zombie.transform.position = sl.transform.position + (Random.insideUnitSphere * sl.range);
        }
        spawnTimer = new CounterTimer(Random.Range(minSpawnInterval, maxSpawnInterval + 1));
    }
 void Make()
 {
     if (instance == null)
     {
         DontDestroyOnLoad(gameObject);
         // DontDestroyOnLoad(p);
         // DontDestroyOnLoad(ui);
         // DontDestroyOnLoad(countdown);
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 14
0
        private void CounterTimer_Tick(object sender, EventArgs e)
        {
            lblGrabbed.Text = AccountGrid.Rows.Count.ToString();
            if (!GrabberThread.IsAlive)
            {
                CounterTimer.Stop();

                MessageBox.Show(
                    "Finished grabbing!",
                    "Info",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );
            }
        }
Esempio n. 15
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;
        }
    }
Esempio n. 16
0
 // Use this for initialization
 void Start()
 {
     recoilTimer = new CounterTimer(RecoilDuration);
     recoilTimer.Update(RecoilDuration);
 }
Esempio n. 17
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;
        }
    }