Exemple #1
0
	public void ThrowBird(Bird currentBird, Pig targetPig, Vector2 slingPos)
	{
		if(_lastTargetPig)
			_lastTargetPig.GetComponent<SpriteRenderer>().material.color = Color.white;

		IsThrowingBird = true;
		
		_throwTimer = 0f;
		_currentBird = currentBird;

		// Highlight the target
		if(!GameWorld.Instance._isSimulation)
			targetPig.GetComponent<SpriteRenderer>().material.color = Color.red;

		_nextShot = Solve(currentBird, targetPig, slingPos);
		currentBird.SelectBird();
	}
Exemple #2
0
	// Update is called once per frame
	void Update () {
		
		if(_isZoomingIn)
		{
			CameraZoom(-0.5f);
			return;
		}
		
		if(_isZoomingOut)
		{
			CameraZoom(0.5f);
			return;
		}

        if(Input.GetMouseButtonDown(0))
        {
			_dragOrigin = Input.mousePosition;

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);

            if(hit)
            {
                if(hit.transform.tag == "Bird")
                {
					_selecetdBird = hit.transform.gameObject.GetComponent<Bird>();
					if(_selecetdBird && !_selecetdBird.IsSelected && _selecetdBird == GameWorld.Instance.GetCurrentBird())
                    {
						_selecetdBird.SelectBird();
                    }
                }
            }
        }
        else if(Input.GetMouseButton(0))
        {
            if(_selecetdBird)
            {
				if(!_selecetdBird.IsFlying && _selecetdBird == GameWorld.Instance.GetCurrentBird())
				{
                	Vector3 dragPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
					dragPosition = new Vector3(dragPosition.x, dragPosition.y, _selecetdBird.transform.position.z);

					_selecetdBird.DragBird(dragPosition);
				}
            }
			else
			{
				Vector3 dragPosition = Input.mousePosition - _dragOrigin;
				GameWorld.Instance._camera.DragCamera(dragPosition * _dragSpeed * Time.fixedDeltaTime);
			}
        }
        else if(Input.GetMouseButtonUp(0))
        {
			if(_selecetdBird && !_selecetdBird.IsFlying && _selecetdBird == GameWorld.Instance.GetCurrentBird())
            {
                _selecetdBird.LaunchBird();
                _selecetdBird = null;
            }
        }
		
		if(Input.GetAxis("Mouse ScrollWheel") != 0f)
		{
			float scrollDirection = Input.GetAxis("Mouse ScrollWheel");
			CameraZoom(scrollDirection);
		}
	}