Beispiel #1
0
	public void AddBird(ABBird readyBird) {
		
		if(_birds.Count == 0)
			readyBird.GetComponent<Rigidbody2D>().gravityScale = 0f;

		if(readyBird != null)
			_birds.Add(readyBird);
	}
Beispiel #2
0
    public GameObject AddBird(GameObject original, Quaternion rotation)
    {
        Vector3 birdsPos = _slingshot.transform.position - ABConstants.SLING_SELECT_POS;

        if (_birds.Count >= 1)
        {
            birdsPos.y = _slingshot.transform.position.y;

            for (int i = 0; i < _birds.Count; i++)
            {
                if ((i + 1) % _birdsAmounInARow == 0)
                {
                    float coin = (Random.value < 0.5f ? 1f : -1);
                    birdsPos.x = _slingshot.transform.position.x + (Random.value * 0.5f * coin);
                }

                birdsPos.x -= ABWorldAssets.BIRDS [original.name].GetComponent <SpriteRenderer> ().bounds.size.x * 1.75f;
            }
        }

        GameObject newGameObject = (GameObject)Instantiate(original, birdsPos, rotation);
        Vector3    scale         = newGameObject.transform.localScale;

        scale.x = original.transform.localScale.x;
        scale.y = original.transform.localScale.y;
        newGameObject.transform.localScale = scale;

        newGameObject.transform.parent = _birdsTransform;
        newGameObject.name             = "bird_" + _birds.Count;

        ABBird bird = newGameObject.GetComponent <ABBird>();

        bird.SendMessage("InitSpecialPower", SendMessageOptions.DontRequireReceiver);

        if (_birds.Count == 0)
        {
            bird.GetComponent <Rigidbody2D>().gravityScale = 0f;
        }

        if (bird != null)
        {
            _birds.Add(bird);
        }

        return(newGameObject);
    }