Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        _pigs           = new List <ABPig>();
        _birds          = new List <ABBird>();
        _birdTrajectory = new List <ABParticle>();

        _levelCleared = false;

        if (!_isSimulation)
        {
            GetComponent <AudioSource>().PlayOneShot(_clips[0]);
            GetComponent <AudioSource>().PlayOneShot(_clips[1]);
        }

        GameObject slingshot = GameObject.Find("Slingshot");

        // If there are objects in the scene, use them to play
        if (_blocksTransform.childCount > 0 || _birdsTransform.childCount > 0 ||
            _plaftformsTransform.childCount > 0 || slingshot != null)
        {
            foreach (Transform bird in _birdsTransform)
            {
                AddBird(bird.GetComponent <ABBird>());
            }

            foreach (Transform block in _blocksTransform)
            {
                ABPig pig = block.GetComponent <ABPig>();
                if (pig != null)
                {
                    _pigs.Add(pig);
                }
            }

            LevelHeight = ABConstants.LEVEL_ORIGINAL_SIZE.y;
            LevelWidth  = ABConstants.LEVEL_ORIGINAL_SIZE.x;

            _slingshot = GameObject.Find("Slingshot");
        }
        else
        {
            ABLevel currentLevel = LevelList.Instance.GetCurrentLevel();

            if (currentLevel != null)
            {
                DecodeLevel(currentLevel);
                AdaptCameraWidthToLevel();

                _levelTimesTried = 0;
            }
        }
        GameObject gameObject = GameObject.Find("slingshot_base");

        if (gameObject)
        {
            _slingshotBaseTransform = gameObject.transform;
        }
    }
Exemplo n.º 2
0
	public GameObject AddPig(GameObject original, Vector3 position, Quaternion rotation, float scale = 1f) {
		
		GameObject newGameObject = AddBlock(original, position, rotation, scale);

		ABPig pig = newGameObject.GetComponent<ABPig>();
		if(pig != null)
			_pigs.Add(pig);

		return newGameObject;
	}
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        _pigs           = new List <ABPig>();
        _birds          = new List <ABBird>();
        _birdTrajectory = new List <ABParticle>();

        _levelCleared = false;

        if (!_isSimulation)
        {
            GetComponent <AudioSource>().PlayOneShot(_clips[0]);
            GetComponent <AudioSource>().PlayOneShot(_clips[1]);
        }

        // If there are objects in the scene, use them to play
        if (_blocksTransform.childCount > 0 || _birdsTransform.childCount > 0)
        {
            foreach (Transform bird in _birdsTransform)
            {
                AddBird(bird.GetComponent <ABBird>());
            }

            foreach (Transform block in _blocksTransform)
            {
                ABPig pig = block.GetComponent <ABPig>();
                if (pig != null)
                {
                    _pigs.Add(pig);
                }
            }
        }
        else
        {
            ABLevel currentLevel = LevelList.Instance.GetCurrentLevel();

            if (currentLevel != null)
            {
                DecodeLevel(currentLevel);
                AdaptCameraWidthToLevel();

                _levelTimesTried = 0;

                _slingshotBaseTransform = GameObject.Find("slingshot_base").transform;
            }
        }
        if (_isSimulation)
        {
            StartCoroutine(SkipSimulationLevel());
        }
    }
Exemplo n.º 4
0
    public void KillPig(ABPig pig)
    {
        _pigs.Remove(pig);

        if (_pigs.Count == 0)
        {
            // Check if player won the game
            if (!_isSimulation)
            {
                _levelCleared = true;
                Invoke("ShowLevelClearedBanner", _timeToResetLevel);
            }

            return;
        }
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        //_isSimulation = RatingSystem.IsGenerating;
        if (RatingSystem.IsGenerating)
        {
            //Debug.Log("In level " + LevelList.Instance.CurrentIndex);
            HideViewCam.GetCamera().enabled = true;
            hudObject.SetActive(false);
            stabilityCounter = 0.3f;
            timeToStable     = 0f;
            GameplayCam.GetCamera().backgroundColor = new Color(0, 0, 0);
        }
        else
        {
            //Debug.Log("Not generating screenshots for level " + LevelList.Instance.CurrentIndex);
            //HideViewCam.GetCamera().enabled = false;
            HideViewCam.gameObject.SetActive(false);
            hudObject.SetActive(true);
        }

        _pigs           = new List <ABPig>();
        _birds          = new List <ABBird>();
        _birdTrajectory = new List <ABParticle>();

        _levelCleared = false;

        if (!_isSimulation)
        {
            GetComponent <AudioSource>().PlayOneShot(_clips[0]);
            GetComponent <AudioSource>().PlayOneShot(_clips[1]);
        }

        GameObject slingshot = GameObject.Find("Slingshot");

        // If there are objects in the scene, use them to play
        if (_blocksTransform.childCount > 0 || _birdsTransform.childCount > 0 ||
            _plaftformsTransform.childCount > 0 || slingshot != null)
        {
            foreach (Transform bird in _birdsTransform)
            {
                AddBird(bird.GetComponent <ABBird>());
            }

            foreach (Transform block in _blocksTransform)
            {
                ABPig pig = block.GetComponent <ABPig>();
                if (pig != null)
                {
                    _pigs.Add(pig);
                }
            }

            LevelHeight = ABConstants.LEVEL_ORIGINAL_SIZE.y;
            LevelWidth  = ABConstants.LEVEL_ORIGINAL_SIZE.x;

            _slingshot = GameObject.Find("Slingshot");
        }
        else
        {
            ABLevel currentLevel = LevelList.Instance.GetCurrentLevel();

            if (currentLevel != null)
            {
                DecodeLevel(currentLevel);
                AdaptCameraWidthToLevel();

                _levelTimesTried = 0;
            }
        }

        _slingshotBaseTransform = GameObject.Find("slingshot_base").transform;
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        _pigs           = new List <ABPig>();
        _birds          = new List <ABBird>();
        _birdTrajectory = new List <ABParticle>();
        _levelCleared   = false;
        CurrentLevel    = LevelList.Instance.GetCurrentLevel();
        _levelLoader    = new LevelLoader();
        trajectory      = new List <ObjTrack>();
//		subsetList = new Dictionary<int,SubsetInfo> ();



        if (!_isSimulation)
        {
            GetComponent <AudioSource>().PlayOneShot(_clips[0]);
            GetComponent <AudioSource>().PlayOneShot(_clips[1]);
        }

        // If there are objects in the scene, use them to play
        if (_blocksTransform.childCount > 0 || _birdsTransform.childCount > 0)
        {
            foreach (Transform bird in _birdsTransform)
            {
                AddBird(bird.GetComponent <ABBird>());
            }

            foreach (Transform block in _blocksTransform)
            {
                ABPig pig = block.GetComponent <ABPig>();
                if (pig != null)
                {
                    _pigs.Add(pig);
                }
            }
        }
        else
        {
//            ABLevel currentLevel = LevelList.Instance.GetCurrentLevel();


            //ABLG!!
            //Randomize first subset position
            if (LevelSimulator.generateLevel)
            {
//				LevelSimulator.ChangeSubsetPosition (currentLevel, UnityEngine.Random.Range (-2f, 2f), UnityEngine.Random.Range (-1f, 2f));
                Vector2 temp = new Vector2(-4f, 1f);
                LevelSimulator.ChangeSubsetPosition(CurrentLevel, temp.x, temp.y);
                AddSubsetIntoList(0, CurrentLevel, temp);
            }
            //


            if (CurrentLevel != null)
            {
                DecodeLevel(CurrentLevel);
                AdaptCameraWidthToLevel();
                _levelTimesTried        = 0;
                _slingshotBaseTransform = GameObject.Find("slingshot_base").transform;
            }
        }

        if (_isSimulation)
        {
            Time.timeScale = 2;
        }
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        _pigs           = new List <ABPig>();
        _birds          = new List <ABBird>();
        _birdTrajectory = new List <ABParticle>();
        _levelLoader    = new LevelLoader();
        _levelCleared   = false;
        CurrentLevel    = LevelList.Instance.GetCurrentLevel();
        levelLoader     = new LevelLoader();

        positions       = new List <Vector2>();
        positionSubsets = new List <Vector2>();
        levelSubsets    = new List <int>();
        groundIndex     = new List <int>();


        if (!_isSimulation)
        {
            GetComponent <AudioSource>().PlayOneShot(_clips[0]);
            GetComponent <AudioSource>().PlayOneShot(_clips[1]);
        }

        // If there are objects in the scene, use them to play
        if (_blocksTransform.childCount > 0 || _birdsTransform.childCount > 0)
        {
            foreach (Transform bird in _birdsTransform)
            {
                AddBird(bird.GetComponent <ABBird>());
            }

            foreach (Transform block in _blocksTransform)
            {
                ABPig pig = block.GetComponent <ABPig>();
                if (pig != null)
                {
                    _pigs.Add(pig);
                }
            }
        }
        else
        {
            ABLevel currentLevel = LevelList.Instance.GetCurrentLevel();


            //ABLG!!
            //Randomize first subset position
            if (LevelSimulator.generateLevel)
            {
                LevelSimulator.ChangeSubsetPosition(currentLevel, UnityEngine.Random.Range(-2, 2), UnityEngine.Random.Range(-3, 2));
            }
            //


            if (currentLevel != null)
            {
                DecodeLevel(currentLevel);

                //ABLG!!
                //generateLevel
                if (LevelSimulator.generateLevel)
                {
                    GenerateLevel();
                }
                //

                AdaptCameraWidthToLevel();
                _levelTimesTried        = 0;
                _slingshotBaseTransform = GameObject.Find("slingshot_base").transform;
            }
        }

        if (_isSimulation)
        {
            Time.timeScale = 100;
        }
    }