Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!Game.Data.Mecha.aiming)
        {
            Collider2D[] res   = Physics2D.OverlapCircleAll(this.transform.position, 14, enemyLayer);
            GameObject   close = null;
            foreach (Collider2D each in res)
            {
                if (each.transform.position.x > Game.Data.Mecha.Root.transform.position.x + 1)
                {
                    if (close == null)
                    {
                        close = each.gameObject;
                    }
                    else
                    {
                        Vector3 close_pos = close.gameObject.transform.position;
                        Vector3 each_pos  = each.gameObject.transform.position;
                        Vector3 pos       = this.gameObject.transform.position;
                        if (Vector3.Distance(pos, each_pos) < Vector3.Distance(pos, close_pos))
                        {
                            close = each.gameObject;
                        }
                    }
                }
            }

            if (close != null)
            {
                GameObject  clone = Game.Spawn(miraObj, close.transform.position, Quaternion.identity);
                mira_script mir   = clone.gameObject.GetComponent <mira_script>();
                if (mir != null)
                {
                    mir.target = close.gameObject;
                }
                Game.Data.Mecha.aiming = true;
            }
        }
    }
Ejemplo n.º 2
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Game.Data.Mecha.invencible = true;
        animator.SetBool("Charging", false);
        animator.SetBool("Charging1", false);
        animator.SetBool("Charging2", false);
        animator.SetBool("Charging3", false);
        GameObject mira = GameObject.FindGameObjectWithTag("mira");

        if (mira != null)
        {
            mira_script mir = mira.GetComponent <mira_script>();
            if (mir != null)
            {
                target = mir.target;
            }
            Game.Data.Mecha.target = target;
        }
        else
        {
            animator.SetBool("Break", true);
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        distToGround = transform.position.y - groundCheck.transform.position.y;
        bool ground = isGrounded();

        Game.Data.Mecha.Animator.SetBool("Grounded", ground);
        if (!ground && !Game.Data.Paused && !Game.Data.bullet)
        {
            Game.Data.Mecha.RigidBody.AddForce(Physics2D.gravity * Game.Data.globalSpeed);
        }

        if (Game.Data.Mecha.aiming)
        {
            if (Input.touchCount > 0)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    if (!Game.Data.bullet)
                    {
                        if (Input.GetTouch(0).position.x > Screen.width / 2)
                        {
                            GameObject target = null;

                            GameObject mira = GameObject.FindGameObjectWithTag("mira");
                            if (mira != null)
                            {
                                mira_script mir = mira.GetComponent <mira_script>();
                                if (mir != null)
                                {
                                    target = mir.target;
                                }
                            }

                            if (target != null)
                            {
                                if (Game.Data.Mecha.timeToResetCombo > 0)
                                {
                                    if (Game.Data.Mecha.combo == 2)
                                    {
                                        Game.Data.Mecha.Animator.SetBool("Charging3", true);
                                        Game.Data.Mecha.wasGrounded      = ground;
                                        Game.Data.Mecha.timeToResetCombo = 1;
                                        Game.Data.shake = 0.2f;
                                    }
                                    else if (target.transform.position.y > Game.Data.Mecha.Root.transform.position.y)
                                    {
                                        Game.Data.Mecha.Animator.SetBool("Charging1", true);
                                        Game.Data.Mecha.wasGrounded      = ground;
                                        Game.Data.Mecha.timeToResetCombo = 1;
                                    }
                                    else
                                    {
                                        Game.Data.Mecha.Animator.SetBool("Charging2", true);
                                        Game.Data.Mecha.wasGrounded      = ground;
                                        Game.Data.Mecha.timeToResetCombo = 1;
                                    }
                                }
                                else
                                {
                                    Game.Data.Mecha.Animator.SetBool("Charging", true);
                                    Game.Data.Mecha.wasGrounded      = ground;
                                    Game.Data.Mecha.timeToResetCombo = 1;
                                }
                            }
                        }
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.Z))
            {
                GameObject target = null;

                GameObject mira = GameObject.FindGameObjectWithTag("mira");
                if (mira != null)
                {
                    mira_script mir = mira.GetComponent <mira_script>();
                    if (mir != null)
                    {
                        target = mir.target;
                    }
                }

                if (target != null)
                {
                    if (Game.Data.Mecha.timeToResetCombo > 0)
                    {
                        if (Game.Data.Mecha.combo == 2)
                        {
                            Game.Data.Mecha.Animator.SetBool("Charging3", true);
                            Game.Data.Mecha.wasGrounded      = ground;
                            Game.Data.Mecha.timeToResetCombo = 1;
                            Game.Data.shake = 0.2f;
                        }
                        else if (target.transform.position.y > Game.Data.Mecha.Root.transform.position.y)
                        {
                            Game.Data.Mecha.Animator.SetBool("Charging1", true);
                            Game.Data.Mecha.wasGrounded      = ground;
                            Game.Data.Mecha.timeToResetCombo = 1;
                        }
                        else
                        {
                            Game.Data.Mecha.Animator.SetBool("Charging2", true);
                            Game.Data.Mecha.wasGrounded      = ground;
                            Game.Data.Mecha.timeToResetCombo = 1;
                        }
                    }
                    else
                    {
                        Game.Data.Mecha.Animator.SetBool("Charging", true);
                        Game.Data.Mecha.wasGrounded      = ground;
                        Game.Data.Mecha.timeToResetCombo = 1;
                    }
                }
            }
        }

        if (Game.Data.Mecha.recovery)
        {
            SpriteRenderer ren = Game.Data.Mecha.Root.gameObject.GetComponent <SpriteRenderer>();
            if (ren != null)
            {
                Color col = ren.color;
                col.a     = 0.5f;
                ren.color = col;
            }
        }
        else
        {
            SpriteRenderer ren = Game.Data.Mecha.Root.gameObject.GetComponent <SpriteRenderer>();
            if (ren != null)
            {
                Color col = ren.color;
                col.a     = 1;
                ren.color = col;
            }
        }
    }