Class that represent Player properties associated with a direction.
	private void TreatElement(ElementObserver elementObs)
	{
		elementObs.isTreated = true;
		EffectTransformation eTransf = elementObs.ElementDetected.Effect(true);
		if (isJumping || !eTransf.isChangingSomething)
			return;
		TreatmentIfObstacle(eTransf);//Evite Un cas de bug ou on passerait sur un obstacle
		if (eTransf.isWinner)
		{
			OnPlayerWin ();
			return;
		}
		if(eTransf.isStartingJump)
		{
			OnPlayerJump();
		}
		if (eTransf.isWater && playerAssociated!=null)
		{
			playerAssociated.FallInWater();
		}
		if (eTransf.newDirection != null)
		{
			transform.position = CurrentDirection.calculFavoritePos(transform.position);
			CurrentDirection = eTransf.newDirection;
		}
		if (eTransf.newPosition != new Vector3())
		{
			transform.position = CurrentDirection.calculFavoritePos(eTransf.newPosition);
		}
	}
	/// <summary>
	/// 
	/// </summary>
	/// <param name="dir">New direction.</param>
	private void OnPlayerDirectionChanging(DirectionProperties dir)
	{
		if (onPlayerDirectionChanging != null)
			onPlayerDirectionChanging (dir);
		BoxCollider2D bc = obstacleElement.GetComponent<BoxCollider2D>();
		if (bc != null)
			bc.size = dir.posObstacleObserver;
	}
 /// <summary>
 /// Start this instance. Set the player direction to the right
 /// </summary>
 void Start()
 {
     animator = GetComponent<Animator> ();
     animator.SetInteger ("animState", 0);
     startDirection = DirectionsArray[0];
 }
Example #4
0
 /// <summary>
 /// Call when the player direction is changing.
 /// </summary>
 /// <param name="dir">Dir.</param>
 private void OnDirectionChange(DirectionProperties dir)
 {
     setAnimation (dir.animationCode);
 }
 /// <summary>
 /// Raises the mouse up event. The StartDirection is changed and the animation of the Square too
 /// </summary>
 public void OnMouseUp()
 {
     anim = (anim + 1) % 4;
     animator.SetInteger ("animState", anim);
     startDirection = DirectionsArray[anim];
 }