Ejemplo n.º 1
0
 void OnTriggerExit2D(Collider2D other)
 {
     justArrived = null;
     Debug.Log("Vamos a salir de >>> " + this.transform.position);
     Debug.Log(justArrived);
     Debug.Log(this.transform.name);
     this.nextDirection = IreneSwipe.Direccion.None;
     Debug.Log("Ha salido de " + this.transform.name);
 }
Ejemplo n.º 2
0
    void ReceiveObject(Rigidbody2D obj, IreneSwipe.Direccion direction)
    {
        teleporPosition = new Vector3(transform.position.x, transform.position.y, 0);
        objectRecived   = obj;
        DOTween.Kill(objectRecived.gameObject.transform);
        canTeleport        = true;
        this.nextDirection = direction;

        objectRecived.gameObject.transform.position = this.transform.position;
        Debug.Log("Posicion delobjeto >>> " + obj.transform.position);
        Debug.Log("Posicion del teleport >>> " + transform.position);
        justArrived = obj;
    }
Ejemplo n.º 3
0
    public void MovePlayer(IreneSwipe.Direccion direction)
    {
        float distance = 0f;

        Debug.Log("Entramos");
        Debug.Log(direction);
        /*if(rb.velocity == Vector2.zero){*/
        if (direction == IreneSwipe.Direccion.Este)
        {
            distance = GetDistance(this.transform, Vector2Int.left);
            if (distance != 0)
            {
                myAnim.SetBool("MoveR", true);
                GameManager.instance.gmCanMove = false;
                this.transform.DOMoveX((this.transform.position.x + distance), distance / m_MoveSpeed).OnComplete(() => FinishMove("MoveR")).SetEase(Ease.Linear);
                myDirection = "Izquierda";
            }
//				Debug.Log(this.transform.position);
        }
        else if (direction == IreneSwipe.Direccion.Oeste)
        {
            distance = GetDistance(this.transform, Vector2Int.right);
            if (distance != 0)
            {
                myAnim.SetBool("MoveL", true);
                GameManager.instance.gmCanMove = false;
                this.transform.DOMoveX((this.transform.position.x - distance), distance / m_MoveSpeed).OnComplete(() => FinishMove("MoveL")).SetEase(Ease.Linear);
                myDirection = "Derecha";
            }
//				Debug.Log(this.transform.position);
        }
        else if (direction == IreneSwipe.Direccion.Sur)
        {
            distance = GetDistance(this.transform, Vector2Int.up);
            if (distance != 0)
            {
                myAnim.SetBool("MoveD", true);
                GameManager.instance.gmCanMove = false;
                this.transform.DOMoveY((this.transform.position.y - distance), distance / m_MoveSpeed).OnComplete(() => FinishMove("MoveD")).SetEase(Ease.Linear);
                myDirection = "Arriba";
            }

//				Debug.Log(this.transform.position);
        }
        else if (direction == IreneSwipe.Direccion.Norte)
        {
            distance = GetDistance(this.transform, Vector2Int.down);
            if (distance != 0)
            {
                myAnim.SetBool("MoveU", true);
                GameManager.instance.gmCanMove = false;
                this.transform.DOMoveY((this.transform.position.y + distance), distance / m_MoveSpeed).OnComplete(() => FinishMove("MoveU")).SetEase(Ease.Linear);
                myDirection = "Abajo";
            }
//				Debug.Log(this.transform.position);
/*			}*/

            //rb.velocity = Vector3.ClampMagnitude(tryMove, 1f) * m_MoveSpeed;
            //dashCooldown = Mathf.MoveTowards(dashCooldown, 0f, Time.deltaTime);
        }
    }
Ejemplo n.º 4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Rigidbody2D rb = other.attachedRigidbody;

        auxRB       = rb;
        rb.velocity = new Vector2(0, 0);

/*        Vector3 direction = new Vector3(0,0,0);
 *      direction.x = other.transform.position.x - transform.position.x;
 *      direction.y = other.transform.position.y - transform.position.y;
 *      Debug.Log(direction);*/
        if (this.nextDirection == IreneSwipe.Direccion.None)
        {
            if (other.transform.position.x < transform.position.x)
            {
                Debug.Log("Entra por izq");
                Debug.Log(other.transform.position.x);
                nextDirection = IreneSwipe.Direccion.Oeste;
            }
            else if (other.transform.position.x > transform.position.x)
            {
                Debug.Log("Entra por dcha");
                Debug.Log(other.transform.position.x);
                nextDirection = IreneSwipe.Direccion.Este;
            }
            else if (other.transform.position.y < transform.position.y)
            {
                Debug.Log("Entra por abajo");
                Debug.Log(other.transform.position.y);
                nextDirection = IreneSwipe.Direccion.Sur;
            }
            else if (other.transform.position.y > transform.position.y)
            {
                Debug.Log("Entra por arriba");
                Debug.Log(other.transform.position.y);
                nextDirection = IreneSwipe.Direccion.Norte;
            }
            myAnim.SetBool("SplashIn", true);
        }


        if (rb == justArrived)
        {
            justArrived = null;
            Debug.Log(justArrived);
            Debug.Log(this.transform.name);
            canTeleport = false;



            //StartCoroutine("WaitAfterTeleport");

            switch (this.nextDirection)
            {
            case IreneSwipe.Direccion.Norte:
                player.transform.position = new Vector3(player.transform.position.x, player.transform.position.y - 1f, 0);
                this.nextDirection        = IreneSwipe.Direccion.Sur;
                break;

            case IreneSwipe.Direccion.Sur:
                player.transform.position = new Vector3(player.transform.position.x, player.transform.position.y + 1f, 0);
                this.nextDirection        = IreneSwipe.Direccion.Norte;
                break;

            case IreneSwipe.Direccion.Este:
                player.transform.position = new Vector3(player.transform.position.x - 1f, player.transform.position.y, 0);
                this.nextDirection        = IreneSwipe.Direccion.Oeste;
                break;

            case IreneSwipe.Direccion.Oeste:
                player.transform.position = new Vector3(player.transform.position.x + 1f, player.transform.position.y, 0);
                this.nextDirection        = IreneSwipe.Direccion.Este;
                break;
            }

            player.MovePlayer(this.nextDirection);
            Debug.Log("Direction >>> " + this.nextDirection);
            this.nextDirection = IreneSwipe.Direccion.None;

            return;
        }
        StartCoroutine("WaitUntilTeleport");
    }