本文整理汇总了C#中Ship.GetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Ship.GetAttributes方法的具体用法?C# Ship.GetAttributes怎么用?C# Ship.GetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship.GetAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)]);
//.........这里部分代码省略.........
示例2: RequestTargetChange
//TODO: Bug! Doesn't take into account the fleet may no longer exist or have any ships.
//TODO: Make requests for targets limited per second per ship.
public void RequestTargetChange(Ship subject)
{
if (!leader || leader.targetFleet == null || leader.targetFleet.isEmpty)
return;
int count = 0;
int threatLevel = subject.GetAttributes().threatLevel;
float threatHigh = threatLevel * 2;
float threatLow = -5;
if (leader.targetFleet.pFleet.Count > 0)
{
int pcount = leader.targetFleet.pFleet.Count;
subject.SetTargetShip(leader.targetFleet.pFleet[rnd.Next(0, pcount)]);
subject.SetBehavior(new SoloEngage(subject));
subject.behaviorName = subject.GetBehavior().ToString();
return;
}
try
{
subject.target = null;
for (int ndx = 0; ndx < leader.targetFleet.pFleet.Count; ndx++)
{
if (Vector3.Distance(subject.transform.position, leader.targetFleet.pFleet[ndx].transform.position) > subject.attributes.range * 3)
continue;
else
subject.SetTargetShip(leader.targetFleet.pFleet[ndx]);
}
if (subject.target != null)
return;
for (int ndx = 0; ndx < leader.targetFleet.fleet.Count; ndx++)
{
if (Vector3.Distance(subject.transform.position, leader.targetFleet.fleet[ndx].transform.position) > subject.attributes.range * 3)
continue;
else
subject.SetTargetShip(leader.targetFleet.fleet[ndx]);
}
if (subject.target != null)
return;
}
catch
{
if (!subject)
{
//Debug.Log("RTC Subject is Dead");
return;
}
if (!leader)
{
//Debug.Log("RTC Leader is Dead");
return;
}
if (leader.targetFleet == null)
{
//Debug.Log("RTC TargetFleet is Dead");
return;
}
if (leader.targetFleet.fleet.Count < 1)
{
//Debug.Log("RTC TargetFleet Fleet is Empty");
leader.targetFleet = null;
return;
}
}
if (subject.target == null)
{
//Debug.Log("No Potential Targets");
}
}