Esempio n. 1
0
		/// <summary>
		/// Does set brittle references.
		/// 
		/// NOTE: For simplicity, this brittle approach is used instead of alternatives;
		/// 		* public transform references, set via dragging from hierarchy items
		/// 		* Inversion Of Control (StrangeIoC) where less GameObject-to-GameObject references are needed.
		/// 		* Manager dynamically spawning via Instantiate()
		/// 		* Etc...
		/// 
		/// 
		/// NOTE: We could shift this code to a newly created GUIManager. For now its fine.
		/// 
		/// 
		/// </summary>
		private void _doSetBrittleReferences()
		{
			//
			_startWaypoint_gameobject 	= _doThrowErrorIfNull (GameObject.Find (MainConstants.StartWaypoint)) as GameObject;
			_player_gameobject 			= _doThrowErrorIfNull (GameObject.Find (MainConstants.PlayerUnPrefab)) as GameObject;

			//
			_playerInputComponent = _player_gameobject.GetComponent<PlayerInputComponent>();
			_characterController2D = _player_gameobject.GetComponent<CharacterController2D>();

		}
		// PUBLIC STATIC
		
		// PRIVATE
		/// <summary>
		/// Does trigger waypoing.
		/// 
		/// NOTE: We crudely evaluate victory here. Todo: More checks could be added (player velocity.y)
		/// 
		/// </summary>
		private void _doTriggerCollisionWithPlayer (PlayerInputComponent aPlayerInputComponent)
		{

			//FLAG THE COLLISION
			_wasTriggered = true;
			//
			if (aPlayerInputComponent.isVulnerableToEnemy) {
				SimpleGameManager.Instance.audioManager.doPlaySound (AudioClipType.ENEMY_KILLS_PLAYER);
				aPlayerInputComponent.doKnockOut();
				//BUT REFRESH QUICKLY COLLISION FLAG FOR ANY SUBSEQUENT INTERACTION
				Invoke ("doRefreshEnemy", 1f);
			} else {
				SimpleGameManager.Instance.audioManager.doPlaySound (AudioClipType.PLAYER_KILLS_ENEMY);
				_enemyAIComponent.doKnockOut();
			}
			
		}