예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (health <= 0)
        {
            EnemyWaveHandler.numEnemiesLeft--;
            if (EnemyWaveHandler.numEnemiesLeft <= 0) //wave complete
            {
                gameStateHandler.SetGameState(GameStateHandler.GameState.READYTOPLAY);
                EnemyWaveHandler.setWaveParameters(++EnemyWaveHandler.wave);
            }
            Destroy(gameObject);
        }
        if (faceGardenTime > 0)
        {
            faceGardenTime -= Time.deltaTime;
        }
        else //if (!gardenFaced)
        {
            LookAtGarden();
            gardenFaced = true;
        }

        shootTimer += Time.deltaTime;
        if (shootTimer > 4.0f)
        {
            shootTimer = 0.0f;
            shootAtGarden();
        }
    }
예제 #2
0
 private void CheckWin()
 {
     if (_guests.Count == 0)
     {
         GameStateHandler.SetGameState(_reward.value);
         StartCoroutine(LoadNewScene());
     }
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        gardenHealthText.GetComponent <TextMesh>().text = "Health: " + gardenHealth;

        if (gardenHealth <= 0)
        {
            //GameOver
            gameStateHandler.SetGameState(GameStateHandler.GameState.GAMEOVER);
        }
    }
예제 #4
0
 public void Solve()
 {
     if (!_stageOneFinished)
     {
         bool result = true;
         for (int i = 0; i < _width; i++)
         {
             for (int j = 0; j < _height; j++)
             {
                 KVelement temp = _grid.GetObjFromCoordinate(new Vector2Int(i, j)).GetComponent <KVelement>();
                 if (temp != null)
                 {
                     if (_expectedResults.valueArray[temp.charge] != temp.setting)
                     {
                         result = false;
                     }
                 }
             }
         }
         if (result)
         {
             _booleanTerms.booleanTerms = new List <BooleanTerm>();
             UITableFiller.FillTable(_stageOnePanel, _booleanTerms.booleanTerms);
             _stageTwoPanel.SetActive(true);
             _stageOneFinished = true;
             ChangeGUI();
             InputHandler.instance.ChangeGIT(GameInputType.None);
         }
     }
     else
     {
         if (IsDMF())
         {
             GameStateHandler.SetGameState(_rewardSO.value);
             AudioManager.instance.PlaySound(_clips[0]);
             _winPanel.SetActive(true);
         }
         else
         {
             AudioManager.instance.PlaySound(_clips[1]);
         }
     }
 }
예제 #5
0
    public void Resolve()
    {
        _resolveResults = new int[Convert.ToInt32(Math.Pow(2, _variableCount.value))];
        for (int i = 0; i < Math.Pow(2, _variableCount.value); i++)
        {
            SetCharges(i);
            int output = GridResolver.ResolveGrid(grid, _startingpoints, _endpoint);
            _resolveResults[i] = output;
        }
        if (_resolveResults.SequenceEqual(_expectedResults.valueArray))
        {
            GameStateHandler.SetGameState(_rewardSO.value);
            AudioManager.instance.PlaySound(_clips[0]);
            _winPanel.SetActive(true);
        }
        else
        {
            AudioManager.instance.PlaySound(_clips[1]);
        }

        UITableFiller.FillTable(_panel, _resolveResults, _variableCount.value, _expectedResults.valueArray, 2);
    }
    /// <summary>
    /// Called via event when the player collides with an asteroid
    /// </summary>
    public void TakeDamage()
    {
        // Unsubscribe to the event before the player is destroyed
        player.GetComponent <ShipMovementController>().onPlayerTakeDamage -= TakeDamage;

        // Destroy the player
        Destroy(player.gameObject);
        playerExplosion.Play();

        // Update lives counter
        levelInformation.CurrentLives -= 1;
        UpdateLifeSprites();

        if (levelInformation.CurrentLives >= 1)
        {
            // Respawn the player if they still have some lives left
            Invoke("RespawnPlayerAfterDeath", 1f);
        }
        else
        {
            gameStateHandler.SetGameState(GameState.GameOver);
        }
    }
예제 #7
0
 // Set the new gamestate using the reward-value and go back to the main menu.
 public void SkipStage()
 {
     GameStateHandler.SetGameState(_reward.value);
     SceneTransitionManager.instance.Transition(0);
 }
예제 #8
0
 public void ReturnToMenu()
 {
     gameStateHandler.SetGameState(GameState.MainMenu);
 }
 public void Play()
 {
     PlayAudioClip();
     gameStateHandler.SetGameState(GameState.Game);
 }
예제 #10
0
    public void Solve()
    {
        if (_resultPanel.activeSelf == true)
        {
            _resultPanel.SetActive(false);
            return;
        }
        List <RouteData> routeQueue = new List <RouteData>();

        bool[][] setResults = new bool[(int)Math.Pow(2, _variableCount.value)][];
        for (int i = 0; i < Math.Pow(2, _variableCount.value); i++)
        {
            setResults[i] = new bool[_outputCount.value];
            List <GridElement> resetList = new List <GridElement>();
            for (int j = 0; j < _variableCount.value; j++)
            {
                RouteData temp = new RouteData {
                    charge = i & (1 << j), route = j, position = _startingpoints[j]
                };
                routeQueue.Add(temp);
            }
            while (routeQueue.Any())
            {
                RouteData tempData = routeQueue[0];
                if (tempData.charge == -1)
                {
                    break;
                }

                MultiSocketObject tempObj = _grid.GetObjFromCoordinate(tempData.position) ? _grid.GetObjFromCoordinate(tempData.position).GetComponent <MultiSocketObject>():null;
                if (tempObj && !tempObj.IsVisited(tempData.route))
                {
                    tempObj.VisitMulti(tempData.charge, tempData.route, tempData.position, routeQueue, resetList);
                    resetList.Add(_grid.GetObjFromCoordinate(tempData.position).GetComponent <GridElement>());
                }
                routeQueue.Remove(tempData);
            }
            int res = 0;
            for (int j = 0; j < _outputCount.value; j++)
            {
                if (_outputs[j].routes.Count != 0)
                {
                    setResults[i][j] = true;
                    if (_outputs[j].setting > 0)
                    {
                        res |= (1 << j);
                    }
                }
                else
                {
                    setResults[i][j] = false;
                }
            }
            _results[i] = res;
            foreach (GridElement gridElem in resetList)
            {
                gridElem.Reset();
            }
        }
        UITableFiller.FillTable(_resultPanel, _results, _outputCount.value, _variableCount.value, _expectedResults.valueArray, setResults);

        _resultPanel.SetActive(true);
        _expectedPanel.SetActive(false);
        if (_results.SequenceEqual(_expectedResults.valueArray))
        {
            GameStateHandler.SetGameState(_rewardSO.value);
            AudioManager.instance.PlaySound(_clips[0]);
            _winPanel.SetActive(true);
        }
        else
        {
            AudioManager.instance.PlaySound(_clips[1]);
        }
    }
예제 #11
0
 private void LoadMainMenu()
 {
     uiInteractionSound.Play();
     gameStateHandler.SetGameState(GameState.MainMenu);
 }
예제 #12
0
    void screenTouched()
    {
        if (GameStateHandler.gamestate != GameStateHandler.GameState.PLACINGMARKERS)
        {
            //do not need more than 4 beacons.
            return;
        }
        Touch touch = Input.GetTouch(0);

        // Raycast against the location the player touched to search for planes.
        TrackableHit      hit;
        TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon |
                                          TrackableHitFlags.FeaturePointWithSurfaceNormal;

        if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
        {
            // Use hit pose and camera pose to check if hittest is from the
            // back of the plane, if it is, no need to create the anchor.
            if ((hit.Trackable is DetectedPlane) &&
                Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position,
                            hit.Pose.rotation * Vector3.up) < 0)
            {
                Debug.Log("Hit at back of the current DetectedPlane");
            }
            else
            {
                if (hit.Trackable is DetectedPlane)
                {
                    DetectedPlane plane = (DetectedPlane)hit.Trackable;
                    if (plane.PlaneType == DetectedPlaneType.HorizontalUpwardFacing)
                    {
                        //Set target to point
                        Quaternion targetQuaternion = Quaternion.Euler(90,
                                                                       hit.Pose.rotation.eulerAngles.y,
                                                                       hit.Pose.rotation.eulerAngles.z
                                                                       );

                        GameObject beacon = Instantiate(BeaconPrefab, hit.Pose.position, targetQuaternion);

                        // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
                        // world evolves.
                        var anchor = hit.Trackable.CreateAnchor(hit.Pose);

                        // Make target model a child of the anchor.
                        beacon.transform.parent = anchor.transform;
                        beacon.transform.Rotate(90, 180, 0);

                        PositionArray[numBeacons] = hit.Pose.position;
                        numBeacons++;
                        if (numBeacons == 4)
                        {
                            if (OnPositionsDetermined != null)
                            {
                                OnPositionsDetermined(PositionArray);
                            }
                            gameStateHandler.SetGameState(GameStateHandler.GameState.READYTOPLAY);
                        }
                    }
                    else
                    {
                        //Cannot place beacon on vertical surface
                    }
                }
            }
        }
    }