예제 #1
0
	public void DropFood()
	{
		//lets use the number on screen to dont instantiate another variable.
		//if dont have any food in pack, do nothing. 
		if(HUDManager.Instance.GetPackFoodQuantity <= 0) { return; }

		//else, change anim to Drop.
		CurrentAnimation = EnumNpcAnims.Drop;

		//Instantiate new Food prefab at same location, "default" rotation.
		Instantiate(foodPrefab, this.transform.localPosition, this.transform.localRotation);

		//tell to hud to subtract dropped food.
		HUDManager.Instance.ReduceFood();
	}
예제 #2
0
	/// <summary>
	/// Indicate to NPC to stop because level has ended.
	/// </summary>
	public void StopEndLevel()
	{
		playable = false; // this will cancel update methods.
		CurrentAnimation = EnumNpcAnims.Dumb; //dumb is a animation that NPC just round your eyes.
	}
예제 #3
0
	/// <summary>
	/// Changes the animation.
	/// </summary>
	/// <param name="newAnim">New animation.</param>
	public void ChangeAnim(EnumNpcAnims newAnim)
	{
		//dont wast time trying to change to same current anim.
		if(_currentAnim == newAnim) {return;}

		//else, set new anim using Property at begining.
		_currentAnim = newAnim;

		Animator anim = this.GetComponent<Animator>();

		//align property with real anim occurring.
		anim.SetInteger("CurrentAnimation", (int)CurrentAnimation);
	}
예제 #4
0
	public void DoWalk()
	{
		//just assurance, if char are dont doing drop anim, correct it to walk.
		//may be caused for another unfinished anim when we set drop anim. So correct it now.
		if(CurrentAnimation == EnumNpcAnims.Drop) { CurrentAnimation = EnumNpcAnims.Walk;}

		//if no side selected, then do nothing, just return.
		if(CurrentAnimation != EnumNpcAnims.Walk) { return; }
		if (anim.GetCurrentAnimatorStateInfo(0).IsName("NpcDrop")) { return; }

		//gets NPC velocity for temporary use.
		//this way we never do changes directly to current velocity.
		velocTemp = rigidBod2d.velocity;

		//check side to walk. To Left velocity is negative because X comes to zero.
		if(SideWalk == EnumSide.Left)
		{
			velocTemp.x  = velocity * -1;
			this.FlipSide(lookLeft); // use that vector variable we defined at Awake method.
		}
		else
		{
			velocTemp.x  = velocity;
			FlipSide(lookRight);	// use that vector  variable we defined at Awake method.
		}

		//set new changed velocity to our NPC rigidbody.
		rigidBod2d.velocity = velocTemp;
	}