示例#1
0
    void JumpUp()
    {
        if (gameIsPlaying == false)
        {
            return;
        }
        // we want to move to the next strip on the field
        //this.transform.position = new Vector3 (strip5.transform.position.x, transform.position.y, transform.position.z);

        // A) move the strips current index by 1 (increment)
        // B) get the strip at this index within the strips list
        // C) get the x position of this new stip and apply it to the chicken

        // A)
        stripsCurrentIndex += 1;
        if (stripsCurrentIndex > indexOfTheHighestRoadStrip)
        {
            tagSubject.setPlayer(this);
            tagSubject.setTag("strip");
            indexOfTheHighestRoadStrip = stripsCurrentIndex;
            Debug.Log("new  score: " + indexOfTheHighestRoadStrip.ToString());
        }

        // B)
        GameObject nextStrip = strips [stripsCurrentIndex] as GameObject;

        // C)
        JumpTargetLocation = new Vector3(nextStrip.transform.position.x - jumpOffsetX, transform.position.y, transform.position.z);
        midWayPointX       = JumpTargetLocation.x + ((this.transform.position.x - JumpTargetLocation.x) / 2);
        mesh.transform.localEulerAngles = new Vector3(0, 0, 0);

        //SpawnNewStrip ();
        GameObject lastStrip = strips [strips.Count - 1] as GameObject;

        StripCache.loadCache(poolOfStripsPrefabs, lastStrip);
        strips.Add(StripCache.getStrip());

        // todo: move boundy up
        // we need to to figure out the distance that the chicken will travel as it jumps
        float distanceX = this.transform.position.x - JumpTargetLocation.x;

        BoundaryLeft.transform.position  -= new Vector3(distanceX, 0, 0);
        BoundaryRight.transform.position -= new Vector3(distanceX, 0, 0);
    }