Exemple #1
0
    void Start()
    {
        FrogPosition = StartFrogPosition = this.transform.localPosition;

        handler            = doNothing;
        handlerMoveTheFrog = doNothing;

        animation = this.GetComponentInChildren <Animation> ();
    }
Exemple #2
0
    void MoveTheModel()
    {
        bool play = false, stopFollowing = false;

        FrogPosition = this.transform.localPosition;
        handler();

        if (Input.anyKeyDown)
        {
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                FrogPosition += Vector3.forward * Jump;
                RotateFrog    = 0;

                play          = true;
                stopFollowing = true;
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                FrogPosition += Vector3.back * Jump;
                RotateFrog    = 180;

                play          = true;
                stopFollowing = true;
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                FrogPosition += Vector3.left * Jump;
                RotateFrog    = -90;

                play = true;
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                FrogPosition += Vector3.right * Jump;
                RotateFrog    = 90;

                play = true;
            }

            Debug.Log("Key");

            if (play)
            {
                //I'm jumping forward/backwards, don't have to follow the object anymore
                if (stopFollowing)
                {
                    handler = doNothing;
                }
//				animation.Play ();
            }
        }

        this.transform.localPosition = FrogPosition;
//		this.transform.localRotation = Quaternion.identity;
        this.transform.localRotation = Quaternion.Euler(0, RotateFrog, 0);
    }
Exemple #3
0
    /**
     * Am I died?
     *
     */
    void OnTriggerEnter(Collider col)
    {
        /*
         * If is a RiverModel log the frog have to stay on it, follow its movement
         */
        if (col.gameObject.tag == "RiverObject")
        {
            RiverModel         = col.gameObject;
            RiverModelPosition = RiverModel.transform.position;

            handler = FollowTheModel;
            return;
        }
        else if (col.gameObject.tag == "FootPath")
        {
            handler    = doNothing;
            RiverModel = null;

            return;
        }
        else if (col.gameObject.tag == "Finish")
        {
            handler    = doNothing;
            RiverModel = null;
//			return;
        }
        else if (col.gameObject.tag != "Enemy")
        {
            return;
        }

        //Died
        handler    = doNothing;
        RiverModel = null;
        this.transform.localPosition = FrogPosition = StartFrogPosition;
//		this.transform.localRotation = Quaternion.identity;
        this.transform.localRotation = Quaternion.Euler(0, 0, 0);
    }