本文整理汇总了C#中Ship.GetTarget方法的典型用法代码示例。如果您正苦于以下问题:C# Ship.GetTarget方法的具体用法?C# Ship.GetTarget怎么用?C# Ship.GetTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship.GetTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetermineBehavior
public void DetermineBehavior(Ship leader, Ship subject)
{
if (subject.behavior == null)
{
//Debug.LogWarning("Behavior for " + subject.name + " is null.");
subject.SetBehavior(new DoNothing(subject));
}
////Debug.Log("Determining Behavior for " + subject.name + " fleet leader: " + subject.isFleetLeader);
// Check if current should stay the same.
if (subject.GetBehavior().KeepBehaviorCheck((AiShip)leader, (AiShip)subject))
return;
////Debug.Log("Passed initial check");
subject.GetBehavior().CallSwitch();
//subject.SetBehavior(new DoNothing(subject));
if (leader.GetBehavior() is Search && !subject.isFleetLeader)
{
Debug.Log("Search Follow");
subject.SetBehavior(new SearchFollow(subject));
Debug.Log("Setting Behavior Name");
subject.behaviorName = subject.GetBehavior().ToString();
return;
}
bool isHealthy = false;
bool hasTarget = false;
bool canSearch = false;
bool canMultiTarget = false;
bool hasAggressors = false;
double health = ((subject.GetAttributes().structureHealth + subject.GetAttributes().armorHealth + subject.GetAttributes().shieldHealth) * 100) / subject.maxHealth;
if (health > 51)
isHealthy = true;
// This is for MultiSoloEngage possiblity. Determine the range later.
/*
if (subject.type is Between certain Range)
canMultiTarget = true;
*/
if (subject.GetTarget() != null)
hasTarget = true;
if (subject.Aggressors.Count > 0)
hasAggressors = true;
if (subject.isFleetLeader == true && !hasAggressors && isHealthy && !hasTarget)
canSearch = true;
// Healthy Behaviors
if (isHealthy)
{
if (leader.GetBehavior() is TeamEngage && leader.target != null)
{
subject.SetBehavior(new TeamEngage(subject));
subject.behaviorName = subject.GetBehavior().ToString();
return;
}
if (leader.targetFleet != null)
counterThreat = RealThreatDeterminer(subject.GetMyFleet(), leader.targetFleet);
else
goto SkipHealthy;
// If target is threatening, Fight with team.
if (hasTarget && counterThreat < 20 && subject.isFleetLeader)
{
////Debug.Log("Team Engaging");
subject.SetBehavior(new TeamEngage(subject));// Team Engage
subject.behaviorName = subject.GetBehavior().ToString();
return;
}
// Solo Engage
if (counterThreat >= 20 )
{
////Debug.Log("Solo Engaging " + subject.gameObject.name);
int count = 0;
int threatLevel = subject.GetAttributes().threatLevel;
float threatHigh = threatLevel * 2;
float threatLow = -5;
// Attacks any players in fleet first.
int pcount = leader.targetFleet.pFleet.Count;
if (leader.targetFleet.pFleet.Count > 0)
{
subject.SetTargetShip(leader.targetFleet.pFleet[rnd.Next(0, pcount - 1)]);
subject.SetBehavior(new SoloEngage(subject));
subject.behaviorName = subject.GetBehavior().ToString();
return;
}
count = 0;
int acount = leader.targetFleet.fleet.Count;
if (acount > 0)
{
subject.SetTargetShip(leader.targetFleet.fleet[rnd.Next(0, acount - 1)]);
//.........这里部分代码省略.........