Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        var bottomLeftCorner = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, 0));
        var upperRightCorner = Camera.main.ViewportToWorldPoint(new Vector3(1f, 1f, 0));

        //		topBound.transform.position = upperRightCorner;
//		bottomBound.transform.position = bottomLeftCorner;
//		leftBound.transform.position = bottomLeftCorner;
        rightBound.transform.position = upperRightCorner;
        if (plantRestart == true)
        {
            spawnPlants();
            plantRestart = false;
        }

        MultiObjGameManager multiObjGameManager = GameObject.Find("MultiObjGameManager").GetComponent <MultiObjGameManager>();

        var successText = GameObject.Find("SuccessText").GetComponent <Text> ();

        successText.text = ("Successes: " + multiObjGameManager.successes);

        var failureText = GameObject.Find("FailureText").GetComponent <Text> ();

        failureText.text = ("Strikes: " + multiObjGameManager.failures);
    }
Exemplo n.º 2
0
    //Calculates final health, calls plantDestroyed from PlantSpawner, then destroy object
    void plantRemovalAndCalc()
    {
        PlantSpawner        plantSpawner        = GameObject.Find("PlantSpawner").GetComponent <PlantSpawner>();
        Movement            bugMovement         = GameObject.FindGameObjectWithTag("Bug").GetComponent <Movement>();
        MultiObjGameManager multiObjGameManager = GameObject.Find("MultiObjGameManager").GetComponent <MultiObjGameManager>();

        Debug.Log("bugMovement's name: " + bugMovement.tag);

        var healed = gameObject.GetComponent <Animator> ().GetBool("healed");
        var hurt   = gameObject.GetComponent <Animator> ().GetBool("hurt");

//		if (this.health >= 80) {
//			plantSpawner.plantDestroyed ("success");
//		}
//		else {
//			plantSpawner.plantDestroyed ("failure");
//		}

        //Tells PlantSpawner.cs plantDestroyer function if it was a success or a failure
        if (healed)
        {
            plantSpawner.plantDestroyed("success");
        }
        else if (hurt)
        {
            plantSpawner.plantDestroyed("failure");
        }
        Destroy(gameObject);
        plantSpawner.plantRestart = true;
        bugMovement.plantIsAlive  = false;
//		multiObjGameManager.restartBugs = true;
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        // Use settings if it was set and loaded from Menu
        if (Settings.isSet)
        {
            enablePattern     = Settings.togglePattern;
            enableNback       = Settings.toggleNback;
            enableMultiObject = Settings.toggleMultiObj;
        }

        // Set game modes
        gameModes = new List <GameModes> ();
        if (enablePattern)
        {
            gameModes.Add(GameModes.Pattern);
        }
        if (enableNback)
        {
            gameModes.Add(GameModes.Nback);
        }
        if (enableMultiObject)
        {
            gameModes.Add(GameModes.Multiobj);
        }


        patternGame  = FindObjectOfType(typeof(PatternLevelManager)) as PatternLevelManager;
        multiObjGame = FindObjectOfType(typeof(MultiObjGameManager)) as MultiObjGameManager;
        nbackGame    = FindObjectOfType(typeof(NbackGameManager)) as NbackGameManager;
        player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Player> ();

        // Start each game if enabled
        // Note: Disable/Enable of Pattern and Nback currently done
        // by disabling their generators in TerrainGenerator.cs, should be here

        if (!enableNback)
        {
            StartCoroutine("GameTimeWait", 4f);
        }
        else
        {
            player.canJump       = true;
            player.canRun        = true;
            player.canDoubleJump = true;

            player.GetComponent <Animator>().SetInteger("PlayerState", 1);

            if (enablePattern)
            {
                patternGame.StartPatternGame();
            }
            if (enableMultiObject)
            {
                multiObjGame.startLevel();
            }
        }
        //StartCoroutine("GameTimeWait",4f);
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        patternGame = FindObjectOfType (typeof(PatternLevelManager)) as PatternLevelManager;
        multiObjGame = FindObjectOfType (typeof(MultiObjGameManager)) as MultiObjGameManager;
        nbackGame = FindObjectOfType (typeof(NbackGameManager)) as NbackGameManager;
        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();

        // Start each game if enabled
        // Note: Disable/Enable of Pattern and Nback currently done
        // by disabling their generators in TerrainGenerator.cs, should be here

        StartCoroutine("GameTimeWait",5f);
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        patternGame  = FindObjectOfType(typeof(PatternLevelManager)) as PatternLevelManager;
        multiObjGame = FindObjectOfType(typeof(MultiObjGameManager)) as MultiObjGameManager;
        nbackGame    = FindObjectOfType(typeof(NbackGameManager)) as NbackGameManager;

        // Start each game if enabled
        // Note: Disable/Enable of Pattern and Nback currently done
        // by disabling their generators in TerrainGenerator.cs, should be here
        if (enableMultiObject)
        {
            multiObjGame.startLevel();
        }
    }
Exemplo n.º 6
0
    public void plantDestroyed(string code)
    {
        MultiObjGameManager multiObjGameManager = GameObject.Find("MultiObjGameManager").GetComponent <MultiObjGameManager>();

        if (code == "success")
        {
//			Debug.Log ("Successful polination!");
//			this.successes += 1;
//			Debug.Log ("Successes: " + this.successes);
            multiObjGameManager.successes += 1;
        }
        else if (code == "failure")
        {
//			Debug.Log ("Unsuccessful polination =[");
//			this.failures += 1;
//			Debug.Log ("Strikes: " + this.failures);
            multiObjGameManager.failures += 1;
        }
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        // Use settings if it was set and loaded from Menu
        if (Settings.isSet) {
            enablePattern = Settings.togglePattern;
            enableNback = Settings.toggleNback;
            enableMultiObject = Settings.toggleMultiObj;
        }

        // Set game modes
        gameModes = new List<GameModes> ();
        if (enablePattern)
            gameModes.Add (GameModes.Pattern);
        if (enableNback)
            gameModes.Add (GameModes.Nback);
        if (enableMultiObject)
            gameModes.Add (GameModes.Multiobj);

        patternGame = FindObjectOfType (typeof(PatternLevelManager)) as PatternLevelManager;
        multiObjGame = FindObjectOfType (typeof(MultiObjGameManager)) as MultiObjGameManager;
        nbackGame = FindObjectOfType (typeof(NbackGameManager)) as NbackGameManager;
        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();

        // Start each game if enabled
        // Note: Disable/Enable of Pattern and Nback currently done
        // by disabling their generators in TerrainGenerator.cs, should be here

        if(!enableNback)
        {
            StartCoroutine("GameTimeWait",4f);
        }
        else
        {
            player.canJump = true;
            player.canRun = true;
            player.canDoubleJump = true;

            player.GetComponent<Animator>().SetInteger("PlayerState",1);

            if(enablePattern)
            {
                patternGame.StartPatternGame();
            }
            if (enableMultiObject) {
                multiObjGame.startLevel();
            }
        }
        //StartCoroutine("GameTimeWait",4f);
    }