Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     curCube    = transform.parent.gameObject.GetComponent <cubeNodeScript>();
     qBert      = GameObject.FindGameObjectWithTag("Player").GetComponent <QbertController>();
     moveToCube = qBert.CurrentCube;
     coilyDead  = false;
     randomDir  = Random.Range(0, 2);
     InvokeRepeating("Seek", 0.35f, 0.75f);
 }
Esempio n. 2
0
 void Start()
 {
     currentCubePos       = transform.GetComponentInParent <cubeNodeScript> ();
     startCubePos         = currentCubePos;
     qBertBoxColl         = gameObject.GetComponent <BoxCollider>();
     qBertBoxColl.enabled = false;
     isHit            = false;
     isFalling        = false;
     moveTimer        = 0;
     canMove          = true;
     greenBallPower   = false;
     curseImg.enabled = false;
 }
Esempio n. 3
0
 void Move(cubeNodeScript moveToCube)
 {
     //failed to lerp between cubes
     //  float timerStart = Time.time;
     CurrentCube      = moveToCube;
     transform.parent = CurrentCube.transform;
     //float distanceMoved = (Time.time - timerStart) * 1;
     // float fracDistance = distanceMoved / Vector3.Distance(currentCubePos.transform.position, moveToCube.transform.position);
     //  = Vector3.Lerp(currentCubePos.transform.position, moveToCube.transform.position, fracDistance);
     //  Debug.Log(timerStart);
     cubePosition = new Vector3(CurrentCube.transform.position.x, CurrentCube.transform.position.y + 0.5f, CurrentCube.transform.position.z);
     qbertJumpSound.Play();
 }
Esempio n. 4
0
    void Seek()
    {
        randomDir  = Random.Range(0, 2);
        prevCube   = moveToCube;
        moveToCube = qBert.CurrentCube;

        LookAtQbert();

        distToQbert = moveToCube.transform.position - transform.position;
        //Debug.Log(curCube);
        if (!QbertController.isHit && !GameManagerScript._gameOver && !GameManagerScript._victory && !QbertController.greenBallPower)
        {
            if (curCube == null)
            {
                moveToCube = qBert.CurrentCube;
            }
            if (moveToCube.gameObject.tag == "rightElevator")
            {
                moveToCube = rightElevatorGap;
                Debug.Log(moveToCube);
            }

            if (moveToCube.gameObject.tag == "leftElevator")
            {
                moveToCube = leftElevatorGap;
            }

            //go left and up
            if (moveToCube.transform.position.x < curCube.transform.position.x && moveToCube.transform.position.y > curCube.transform.position.y)
            {
                curCube = curCube.backLeft;
                MoveCoily();
            }
            //go right and up
            else if (moveToCube.transform.position.x > curCube.transform.position.x && moveToCube.transform.position.y > curCube.transform.position.y)
            {
                curCube = curCube.backRight;
                MoveCoily();
            }
            //choose left or right and up
            else if (moveToCube.transform.position.x == curCube.transform.position.x && moveToCube.transform.position.y > curCube.transform.position.y)
            {
                if (randomDir == 0 && curCube.backLeft != null)
                {
                    curCube = curCube.backLeft;
                    MoveCoily();
                }
                else if (randomDir == 1 && curCube.backRight != null)
                {
                    curCube = curCube.backRight;
                    MoveCoily();
                }
            }

            //go down pyramid
            //down and left
            else if (moveToCube.transform.position.x < curCube.transform.position.x && moveToCube.transform.position.y < curCube.transform.position.y)
            {
                curCube = curCube.frontLeft;
                MoveCoily();
            }
            //dowwn and right
            else if (moveToCube.transform.position.x > curCube.transform.position.x && moveToCube.transform.position.y < curCube.transform.position.y)
            {
                curCube = curCube.frontRight;
                MoveCoily();
            }
            //down and choose left or right
            else if (moveToCube.transform.position.x == curCube.transform.position.x && moveToCube.transform.position.y < curCube.transform.position.y)
            {
                if (randomDir == 0)
                {
                    curCube = curCube.frontLeft;
                    MoveCoily();
                }
                else if (randomDir == 1)
                {
                    curCube = curCube.frontLeft;
                    MoveCoily();
                }
            }
            //resolve vertical conflicts
            //if moving left and height is equal
            else if (moveToCube.transform.position.x < curCube.transform.position.x && moveToCube.transform.position.y == curCube.transform.position.y)
            {
                if (randomDir == 0 && curCube.frontLeft != null)
                {
                    curCube = curCube.frontLeft;
                    MoveCoily();
                }
                else if (randomDir == 1 && curCube.backLeft != null)
                {
                    curCube = curCube.backLeft;
                    MoveCoily();
                }
            }
            //if moving right and height is equal
            else if (moveToCube.transform.position.x > curCube.transform.position.x && moveToCube.transform.position.y == curCube.transform.position.y)
            {
                if (randomDir == 0 && curCube.frontRight != null)
                {
                    curCube = curCube.frontRight;
                    MoveCoily();
                }
                else if (randomDir == 1 && curCube.backRight != null)
                {
                    curCube = curCube.backRight;
                    MoveCoily();
                }
            }
        }
    }
Esempio n. 5
0
 public virtual void StartBehaviour(ref GameObject cube)
 {
     curCube = cube.GetComponent <cubeNodeScript>();
     //Debug.Log (curCube);
     transform.parent = cube.transform;
 }