Beispiel #1
0
    void PreAttack()
    {
        if (animator.GetInteger("shark_int") != 2)
        {
            animator.SetInteger("shark_int", 2);
            //splashEvent(new Vector3(gameObject.transform.position.x,gameObject.transform.position.y + 0.2f, gameObject.transform.position.z));
            //print(transform.rotation);

            preAttackCounter = preAttackTime + Time.time;

            if (towardTheBoat == false)
            {
                if (goRight)
                {
                    transform.rotation = new Quaternion(0f, 0f, 0f, 1f);
                    // print("turn left toward the boat");
                } else
                {
                    transform.rotation = new Quaternion(0f, 180, 0f, 1f);
                    // print("turn right toward the boat");
                }
            } else
            {
                // print("keep moving foward");
            }
            transform.Rotate(Vector3.back * 30f);

            if (baconSpotScript.hasBacon == false)
            {

                attackBacon = false;
            } else
            {

                attackBacon = true;
            }

        }

        if (Time.time > preAttackCounter)
        {
            if (attackBacon == false)
            {
                currentState = sharkStates.attackPlayer;
                //print("current state is attacking player");
            } else
            {
                currentState = sharkStates.attackBacon;
                //  print("current state is attacking Bacon");
            }
            //print(transform.rotation);
        }
    }
Beispiel #2
0
    void Swim()
    {
        if (animator.GetInteger("shark_int") != 1)
        {

            animator.SetInteger("shark_int", 1);
            int seed1 = Random.Range(1, 200);
            int seed2 = (int)(Time.time * seed1);
            Random.seed = seed2;
            int roll = Random.Range(300, 700);
            float rd = roll / 100;
            swimCounter = Time.time + swimTime + rd;
            towardTheBoat = true;

            if (!goRight)
            {
                transform.rotation = new Quaternion(0f, 180f, 0f, 1f);
            } else
            {
                transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
            }

        }

        int direction = -1;
        if (!goRight)
        {

            direction = -1;
        }

        //newRotation = transform.rotation;
        if (towardTheBoat)
        {

            //newRotation.y = 180f;
            if (goRight)
            {
                gameObject.transform.rotation = new Quaternion(0f, 0f, 0f, 1f);
                //print("toward the boat from right");
            } else
            {
                gameObject.transform.rotation = new Quaternion(0f, 180f, 0f, 1f);
                //print("toward the boat from left");
            }

            transform.Translate(new Vector3(direction * (swimSpeed * Time.deltaTime), 0f, 0f));
        } else
        {

            //Quaternion newRotation = transform.rotation;
            //newRotation.y = 0f;
            if (goRight)
            {
                gameObject.transform.rotation = new Quaternion(0f, 180f, 0f, 1f);
                //print("away from the boat- right");
            } else
            {
                gameObject.transform.rotation = new Quaternion(0f, 0f, 0f, 1f);
                //print("away from the boat- left");
            }
            transform.Translate(new Vector3(direction * (swimSpeed * Time.deltaTime), 0f, 0f));
        }

        rb = getRect(boatEdge);
        rs = getRect(screenEdge);
        rg = getRect(gameObject);

        if (towardTheBoat == true)
        {

            if (Intersect(rb, rg))
            {
                // print ("boat bounds hit");

                towardTheBoat = false;
            }
            //print ("rotation.y towardTheBoat = " + transform.rotation.y);
        } else
        {
            if (Intersect(rs, rg))
            {
                //  print ("screen bound hit");
                towardTheBoat = true;
            }
        }

        //transform.rotation = newRotation;
        if (Time.time > swimCounter)
        {
            currentState = sharkStates.preAttack;
            //print("current state is pre_attack");
        }
    }
Beispiel #3
0
    void LateUpdate()
    {
        frames++;
        if (frames >= interval)
        {
            frames = 0;
            bo = getRect(boatOar);
            rg = getRect(gameObject);
            if ((currentState != sharkStates.hit || currentState != sharkStates.escape) && playerIdle == false)
            {
                if (Intersect(rg, bo))
                {
                    currentState = sharkStates.hit;

                }
            }

            if (gameObject.transform.position.x > 20 || gameObject.transform.position.x < -20 || gameObject.transform.position.y < -10)
            {
                gameObject.SetActive(false);
            }
        }
    }
Beispiel #4
0
    void Alert()
    {
        if (animator.GetInteger("shark_int") != 0)
        {

            animator.SetInteger("shark_int", 0);
            alertCounter = Time.time + alertTime;

            if (!goRight)
            {
                gameObject.transform.rotation = new Quaternion(0f, 180f, 0f, 1f);
            } else
            {
                gameObject.transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
            }

        }

        if (Time.time > alertCounter)
        {
            currentState = sharkStates.swim;
        }
    }
Beispiel #5
0
    public void GetHit(int clearingEnemy = 0)
    {
        if ((hit == false) && (currentState != sharkStates.swim))
        {
            hitTime = Time.time + hitAnimationTime;
            currentState = sharkStates.hit;
            hit = true;
            /*increment shark hit counter*/
            Toolbox.Instance.sharkHitCount += 1;
            if (clearingEnemy == 0)
            {
                SharkHitEvent(boatOar.transform.position);
            }
            else
            {
                SharkHitEvent(gameObject.transform.position);
            }
            SharkPointsEvent(gameObject.transform.position, 25);
            //boatOarClass.fire();
            //print("hit recieved");

            if (goRight)
            {
                transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
            } else
            {
                transform.rotation = new Quaternion(0f, 180f, 0f, 0f);
            }
            animator.SetInteger("shark_int", 5);

        }

        if (Time.time > hitTime)
        {
            currentState = sharkStates.escape;
        }

        //destroyMissile ();
    }
Beispiel #6
0
    public void Fire()
    {
        baconSpotScript = baconSpot.GetComponent<CookingController>();
        thisRenderer = gameObject.GetComponent<SpriteRenderer>();

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player"))
        {
            //float distance = go.transform.position.x - transform.position.x;
            //print("distance = " + distance);
            if ((transform.position.x) < 0)
            {
                goRight = false;
            } else
            {
                goRight = true;
            }

            //float diff = (go.transform.position - transform.position).sqrMagnitude;

        }

        if (transform.localScale.x < 1)
        {

            print("parent of weird one = " + transform.localScale.x);
            Toolbox.Instance.smallCount++;
        }

        //boatEdge = GameObject.Find("touch_zone1");
        //print(boatEdge);
        //screenEdge = GameObject.Find("touch_zone2");

        currentState = sharkStates.alert;
        bite = false;
    }
    public void GetHit()
    {
        if ((hit == false) && (currentState != sharkStates.swim))
        {
            hitTime = Time.time + hitAnimationTime;
            currentState = sharkStates.hit;
            hit = true;
            /*increment shark hit counter*/
            TempVars.mySharks++;
            //print("hit recieved");

            if (goRight)
            {
                transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
            } else
            {
                transform.rotation = new Quaternion(0f, 180f, 0f, 0f);
            }
            animator.SetInteger("shark_int", 7);

        }

        if (Time.time > hitTime)
        {
            currentState = sharkStates.escape;
        }

        //destroyMissile ();
    }