Ejemplo n.º 1
0
    // when collided with another gameObject
    //void OnCollisionEnter (Collision newCollision)
    void OnTriggerEnter(Collider newCollision)
    {
        Debug.Log("Colisiona");
        // exit if there is a game manager and the game is over
        if (GameManagerSushi.gms)
        {
            if (GameManagerSushi.gms.gameIsOver)
            {
                return;
            }
        }

        // only do stuff if hit by a projectile
        if ((newCollision.gameObject.tag == "KatanaLeft" && fishingHand == "left") || (newCollision.gameObject.tag == "KatanaRight" && fishingHand == "right"))
        {
            if (explosionPrefab)
            {
                // Instantiate an explosion effect at the gameObjects position and rotation
                Instantiate(explosionPrefab, transform.position, transform.rotation);
            }

            if (informationPrefab)
            {
                //Intantiate an information dialog at the gameObjects position and rotation
                Instantiate(informationPrefab, transform.position, GameObject.FindWithTag("MainCamera").transform.rotation);
            }

            // if game manager exists, make adjustments based on target properties
            if (GameManagerSushi.gms)
            {
                GameManagerSushi.gms.targetHit(scoreAmount);
            }

            // if explosion sound exists, make adjustments based on target properties
            if (explosionSound)
            {
                explosionSound.Play();
            }

            // destroy the projectile
            //Destroy (newCollision.gameObject);

            gameM.NewRepetition();

            if (gameM.withTime)
            {
                if (gameM.currentTime > 0.0f)
                {
                    spawner.MakeThingToSpawn();
                }
            }
            else
            {
                if (gameM.GetRepetitions() >= 0)
                {
                    spawner.MakeThingToSpawn();
                }
            }

            sSpawner.MakeSpawn();

            GameObject.Find("GameManager").GetComponent <PointFeedbackManager>().GreenPoint();
            // destroy self
            Destroy(gameObject);
        }
        else if ((newCollision.gameObject.tag == "KatanaLeft" && fishingHand == "right") || (newCollision.gameObject.tag == "KatanaRight" && fishingHand == "left"))
        {
            GameObject.Find("GameManager").GetComponent <PointFeedbackManager>().RedPoint();
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!moving)
            return;
        // do the appropriate motion based on the motionState
        switch (motionState)
        {
            case status.Up:
                // rotate around the up axix of the gameObject
                gameObject.transform.Translate(Vector3.up * 2.0f * ((objectiveHeight - initialHeight) / upTime) * Time.deltaTime, Space.World);
                break;
            case status.UpII:
                // rotate around the up axix of the gameObject
                gameObject.transform.Translate(Vector3.back * (4.0f / upTime) * Time.deltaTime, Space.World);
                break;
            case status.Static:
                // move up and down over time
                gameObject.transform.Rotate(Vector3.up * spinSpeed * Time.deltaTime, Space.World);
                gameObject.transform.Rotate(Vector3.right * (180.0f / floatingTime) * Time.deltaTime);
                break;
            case status.Down:
                // move up and down over time
                gameObject.transform.Translate(Vector3.down * 2.0f * ((objectiveHeight - initialHeight) / upTime) * Time.deltaTime, Space.World);
                gameObject.transform.Translate(Vector3.back * (8.0f / upTime) * Time.deltaTime, Space.World);
                break;
        }
        aliveTime += Time.deltaTime;
        if (aliveTime < upTime / 2.0f)
        {
            motionState = status.Up;
        }
        else if (aliveTime < upTime)
        {
            motionState = status.UpII;
        }
        else if (aliveTime < upTime + floatingTime)
        {
            motionState = status.Static;
        }
        else if (aliveTime < upTime + floatingTime + 1.0f)
        {
            motionState = status.Down;
        }
        else
        {
            if (gameM.withTime)
            {
				gameM.NewRepetition();
                if (gameM.currentTime > 0.0f)
                {
                    Debug.Log("Makethingtospawn");
                    spawner.MakeThingToSpawn();
                }
            }
            else
            {
                gameM.NewRepetition();
                if (gameM.GetRepetitions() >= 0)
                {
                    Debug.Log("Makethingtospawn2");
                    spawner.MakeThingToSpawn();
                }
            }

            GameObject.Find("GameManager").GetComponent<PointFeedbackManager>().RedPoint();
            Destroy(gameObject);
        }

    }