private void MouseAction()
    {
        // Just 1 tap.
        if (Input.GetButton("Fire1"))
        {
            Vector2 mousePosition = mainCamera.ScreenToWorldPoint(Input.mousePosition);

            Movement(mousePosition);
        }
        else
        {
            movementSide = MovementSide.NONE;
        }
    }
 private void Movement(Vector2 position)
 {
     if (position.x < transform.position.x)
     {
         movementSide = MovementSide.LEFTorDOWN;
     }
     else if (position.x > transform.position.x)
     {
         movementSide = MovementSide.RIGHTorUP;
     }
     else
     {
         movementSide = MovementSide.NONE;
     }
 }
    public void SpawnEnemyFromPool(Vector2 position, MovementSide side)
    {
        GameObject enemy = GetObjectFromPool(position);

        if (enemy != null)
        {
            if (side == MovementSide.LEFTorDOWN)
            {
                enemy.GetComponent<Enemy>().side = MovementSide.RIGHTorUP;
                enemy.transform.localScale = new Vector2(-1, 1);
            }
            else if (side == MovementSide.RIGHTorUP)
            {
                enemy.GetComponent<Enemy>().side = MovementSide.LEFTorDOWN;
                enemy.transform.localScale = new Vector2(1, 1);
            }

            enemy.renderer.sortingLayerName = "Foreground";
            enemy.renderer.sortingOrder = 1;
        }
    }
Пример #4
0
    public void SpawnEnemyFromPool(Vector2 position, MovementSide side)
    {
        GameObject enemy = GetObjectFromPool(position);

        if (enemy != null)
        {
            if (side == MovementSide.LEFTorDOWN)
            {
                enemy.GetComponent <Enemy>().side = MovementSide.RIGHTorUP;
                enemy.transform.localScale        = new Vector2(-1, 1);
            }
            else if (side == MovementSide.RIGHTorUP)
            {
                enemy.GetComponent <Enemy>().side = MovementSide.LEFTorDOWN;
                enemy.transform.localScale        = new Vector2(1, 1);
            }

            enemy.renderer.sortingLayerName = "Foreground";
            enemy.renderer.sortingOrder     = 1;
        }
    }
    private void TouchAction()
    {
        // Just 1 tap.
        if (Input.touchCount == 1)
        {
            Touch   touch         = Input.GetTouch(0);
            Vector2 touchPosition = mainCamera.ScreenToWorldPoint(touch.position);

            if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
            {
                movementSide = MovementSide.NONE;
            }
            else
            {
                Movement(touchPosition);
            }
        }
        else
        {
            movementSide = MovementSide.NONE;
        }
    }
    public GameObject SpawnFriendAirplaneFromPool(Vector2 position, MovementSide side)
    {
        GameObject shot = GetObjectFromPool(position);

        if (shot != null)
        {
            if (side == MovementSide.LEFTorDOWN)
            {
                shot.GetComponent <FriendAirplane>().side = MovementSide.RIGHTorUP;
                shot.transform.localScale = new Vector2(1, 1);
            }
            else if (side == MovementSide.RIGHTorUP)
            {
                shot.GetComponent <FriendAirplane>().side = MovementSide.LEFTorDOWN;
                shot.transform.localScale = new Vector2(-1, 1);
            }

            shot.renderer.sortingLayerName = "Foreground";
            shot.renderer.sortingOrder     = 2;
        }

        return(shot);
    }