public TaskHumanShootCover(CoverBase _cover)
	{
		cover = _cover;
	}
Beispiel #2
0
	public void CheckRemoveCover()
	{
		if(CurrentCover != null)
		{
			CurrentCover.Occupant = null;
			CurrentCover = null;
		}
	}
Beispiel #3
0
	public override IEnumerator Run()
	{
		while(true)
		{
			testShooting = false;
			Vector3 playerPosition = EnemyUtils.Player.transform.position;
			
			if(!lastKnownPosition.Seen) //has player been seen recently?
			{
				if(CurrentCover != null) //is in cover?
				{
					//Debug.Log("NEW TASK: leave cover");
					yield return (new TaskHumanLeaveCover()).RunTask(this);
				}
				else
				{
					//Debug.Log("NEW TASK: guard");
					CheckRemoveCover();
					yield return (new TaskHumanGuard()).RunTask(this);	
				}
			}
			else if(CurrentCover != null) //is in cover?
			{
				if(CurrentCover.IsUsefull && CurrentCover.IsSafe) //is player visible from cover? && is cover safe?
				{
					//Debug.Log("NEW TASK: shoot at player from cover");
					testShooting = true;
					yield return (new TaskHumanShootCover(CurrentCover)).RunTask(this);
				}
				else
				{
					//Debug.Log("NEW TASK: leave cover");
					yield return (new TaskHumanLeaveCover()).RunTask(this);
				}
			}
			else if (CanSeePlayer()) //is player visible?
			{
				if((CurrentCover = coverManager.GetNearestCover(transform.position, playerPosition)) != null) //any empty cover nearby?
				{
					//Debug.Log("NEW TASK: Walk to cover");
					CurrentCover.Occupant = Entity;

					if (CurrentCover.GetType() == typeof(CoverWall)) 
					{
						TaskHumanWalkToCover task = new TaskHumanWalkToCover(((CoverWall)CurrentCover).ShootPosition);
						yield return task.RunTask(this);
					} 
					else 
					{
						TaskHumanWalkToCover task = new TaskHumanWalkToCover(CurrentCover.transform.position);
						yield return task.RunTask(this);
					}
				}
				else
				{
					//Debug.Log("NEW TASK: shoot at player");
					testShooting = true;
					CheckRemoveCover();
					yield return (new TaskHumanShoot()).RunTask(this);
				}
			}
			else if(Vector3.Distance(transform.position, playerPosition) < 2f) //is human close to last known position? TODO: or player can see last known position?
			{
				//Debug.Log("NEW TASK: guard");
				CheckRemoveCover();
				yield return (new TaskHumanGuard()).RunTask(this);
			}
			else
			{
				//Debug.Log("NEW TASK: track player");
				CheckRemoveCover();
				yield return (new TaskHumanTrack()).RunTask(this);
			}
			yield return null;
		}
	}
	public void AddCover(CoverBase _cover)
	{
		all.Add(_cover);
	}