Exemplo n.º 1
0
    void Update()
    {
        if (model.gameState == GameState.Running)
        {
            if (model.sceneState == SceneState.Shooting)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out RaycastHit hit) && hit.collider.gameObject.tag == "UFO")
                    {
                        OnHitUFO(hit.collider.gameObject);
                    }
                }

                for (int i = 0; i < UFOs.Count; i++)
                {
                    if (!UFOs[i].GetComponent <UFO>().visible)
                    {
                        OnMissUFO(UFOs[i].gameObject);
                    }
                }

                if (UFOs.Count == 0 && model.gameState == GameState.Running)
                {
                    model.sceneState = SceneState.Waiting;
                    model.NextTrial();
                }
            }
            else
            {
                if (Input.GetKeyDown("space"))
                {
                    UFOs             = ruler.GetUFOs(model.currentRound, model.type);
                    model.sceneState = SceneState.Shooting;
                }
            }
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        for (int i = 0; i < UFOs.Count; i++)
        {
            if (UFOs[i].GetComponent <UFO>().speed == 0)
            {
                OnMissUFO(UFOs[i].gameObject);
            }
        }

        if (model.gameState == GameState.Running)
        {
            if (model.sceneState == SceneState.Shooting && Input.GetButtonDown("Fire1"))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out RaycastHit hit) && hit.collider.gameObject.tag == "UFO")
                {
                    OnHitUFO(hit.collider.gameObject);
                }
            }

            if (model.sceneState == SceneState.Waiting && Input.GetKeyDown("space"))
            {
                model.sceneState = SceneState.Shooting;
                model.NextTrial();
                if (model.gameState == GameState.Win)
                {
                    return;
                }
                UFOs.AddRange(ruler.GetUFOs());
            }

            if (UFOs.Count == 0)
            {
                model.sceneState = SceneState.Waiting;
            }
        }
    }