コード例 #1
0
 public void Alert()
 {
     if (animator.GetInteger("octopus_int") != 0)
     {
         //print ("animator var first time = " + animator.GetInteger("octopus_int"));
         animator.SetInteger("octopus_int", 0);
         //print ("animator var after time = " + animator.GetInteger("octopus_int"));
         AlertCounter = Time.time + AlertTimer;
     }
     //print("T = " + Time.time + "| ac = " + alertCounter);
     if (Time.time > AlertCounter)
     {
         currentState = octopusStates.swimming;
     }
 }
コード例 #2
0
    public void Swim()
    {
        if (animator.GetInteger("octopus_int") != 1)
        {
            //print ("animator var first time = " + animator.GetInteger("octopus_int"));
            animator.SetInteger("octopus_int", 1);
            //print ("animator var after time = " + animator.GetInteger("octopus_int"));
            SwimCounter = Time.time + SwimTimer;

            if(goRight)
            {
                p2dControl.flip = true;
            }
            else
            {
                p2dControl.flip = false;
            }

        }

        if(goRight)
        {
            transform.Translate(new Vector3(1 * 0.1f, 0f, 0f));
        }
        else
        {
            transform.Translate(new Vector3(1 * 0.1f, 0f, 0f));
        }

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

        if (rb.Overlaps(rg))
        {
            currentState = octopusStates.preAttack;
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale == 1.0f)
        {
            //print("update fram");

            switch (currentState)
            {
                case octopusStates.alert:
                    //call function to handle alert actions
                    Alert();
                    break;

                case octopusStates.swimming:
                    //call function to handle flying actions
                    Swim();
                    break;

                case octopusStates.preAttack:
                    PreAttack();
                    break;

                case octopusStates.grabbing:
                    Grab();
                    //call function to handle gabbing actions
                    break;
                case octopusStates.attacking:
                    Attack();
                    break;

                case octopusStates.escaping:
                    //call function to handle escaping actions
                    Escaping();
                    break;

                case octopusStates.swatted:
                    GetHit();
                    break;

            }

            bo =  getRect(boatOar);
            rg = getRect(gameObject);
            rt = getRect(tentecleCollider);
            if ((currentState != octopusStates.swatted || currentState != octopusStates.escaping) && playerIdle == false)
            {
                if(Intersect(rg, bo) || (Intersect(rt,bo)))
                {
                    currentState = octopusStates.swatted;
                }
            }

        }
    }
コード例 #4
0
    public void PreAttack()
    {
        if (animator.GetInteger("octopus_int") != 2)
        {
            //print ("animator var first time = " + animator.GetInteger("octopus_int"));
            animator.SetInteger("octopus_int", 2);
            //print ("animator var after time = " + animator.GetInteger("octopus_int"));
            PreAttackCounter = Time.time + PreAttackTimer;

            if (baconSpotScript.hasBacon == false)
            {
                attackBacon = false;
            }
            else
            {
                attackBacon = true;
            }
        }
        //print("T = " + Time.time + "| ac = " + alertCounter);
        if (Time.time > PreAttackCounter)
        {
            if(attackBacon)
            {
                currentState = octopusStates.grabbing;
            }
            else
            {
                currentState = octopusStates.attacking;

            }

        }
    }
コード例 #5
0
    public void Grab()
    {
        if (animator.GetInteger("octopus_int") != 3)
        {
            animator.SetInteger("octopus_int", 3);

            //transform.Translate(0f, -0.35f, 0f);
            //transform.Rotate(0f, 0f, 120f);

            GrabCounter = Time.time + GrabTimer;

        }
        //hit test

        rg = getRect(tentecleCollider);
        rbs = getRect(baconGO);

        if (rbs.Overlaps(rg))
        {
            if(!grabBacon)
            {
                grabBaconEvent(baconSpot.name);
                grabBacon = true;
            }

        }

        if (Time.time > GrabCounter)
        {
            currentState = octopusStates.escaping;
        }
    }
コード例 #6
0
    public void GetHit(int clearingEnemy = 0)
    {
        if (hit == false)
        {
            hitTime = Time.time + hitAnimationTime;
            currentState = octopusStates.swatted;
            hit = true;
            print("hit recieved");
            animator.SetInteger("octopus_int", 2);
        }

        if (Time.time > hitTime)
        {
            currentState = octopusStates.escaping;
        }

        //destroyMissile ();

        if (animator.GetInteger("octopus_int") != 6)
        {
            animator.SetInteger("octopus_int", 6);
        }
    }
コード例 #7
0
    public void Fire()
    {
        baconSpotScript = baconSpot.GetComponent<CookingController>();
        thisRenderer = gameObject.GetComponent<SpriteRenderer>();

        if ((transform.position.x) < 0)
        {
            goRight = false;
            //p2dControl.flip = false;
            FlipGameObject(false);
        }
        else
        {
            goRight = true;
            //p2dControl.flip = true;
            FlipGameObject(true);
        }

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

        currentState = octopusStates.alert;
    }
コード例 #8
0
    public void Attack()
    {
        if (animator.GetInteger("octopus_int") != 4)
        {
            animator.SetInteger("octopus_int", 4);
            transform.Translate(0f, -0.5f, 0f);
            transform.Rotate(0f, 0f, 180f);

            AttackCounter = Time.time + AttackTimer;

        }
        //hit test
        rb = getRect(playerHitArea);
        rs = getRect(screenEdge);
        rg = getRect(tentecleCollider);

        //if (towardTheBoat == true)
        //{

        if (rb.Overlaps(rg))
        {
            if(!playerAttacked)
            {
                OctopusHitEvent(12f);
                playerAttacked = true;
            }

        }

        if (Time.time > AttackCounter)
        {
            currentState = octopusStates.escaping;
        }
    }