本文整理汇总了C#中Attack.SetTimes方法的典型用法代码示例。如果您正苦于以下问题:C# Attack.SetTimes方法的具体用法?C# Attack.SetTimes怎么用?C# Attack.SetTimes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attack
的用法示例。
在下文中一共展示了Attack.SetTimes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CancelEngagement
private void CancelEngagement(SimulationEvent e)
{
string targetObjectId = ((StringValue)e["TargetObjectID"]).value;
string attackingObjectId = ((StringValue)e["AttackingObjectID"]).value;
string capabilityName = ((StringValue)e["CapabilityName"]).value;
for (int x = 0; x < this.currentAttacks.Count; x++)
{
if (currentAttacks[x].attacker == attackingObjectId && currentAttacks[x].target == targetObjectId && currentAttacks[x].capabilityName == capabilityName)
{
currentAttacks.RemoveAt(x);
Attack tmp = new Attack(attackingObjectId, targetObjectId, capabilityName);
tmp.SetTimes(currentAttacks[x].startTime,0); //remove in client view with tmp
SendAttackEvent(tmp);
return;
}
}
}
示例2: SelfDefenseAttackStarted
/// <summary>
///
/// </summary>
/// <param name="e"></param>
private void SelfDefenseAttackStarted(SimulationEvent e)
{
string attacker = ((StringValue)e["AttackerObjectID"]).value;
string target = ((StringValue)e["TargetObjectID"]).value;
if (DoesAttackListContainThisPair(attacker, target))
return;
SimulationObjectProxy obj = objectProxies[attacker];
AttackCollectionValue attCV = (AttackCollectionValue)obj["CurrentAttacks"].GetDataValue();
List<AttackCollectionValue.AttackValue> selfDefenses = attCV.GetCurrentSelfDefenseAttacks();
AttackCollectionValue.AttackValue attackValue = null;
if (selfDefenses.Count > 1)
{
Console.WriteLine("SelfDefenseAttackStarted, attacker contains more than one active self defense attack. -> " + selfDefenses.Count.ToString());
foreach (AttackCollectionValue.AttackValue av in selfDefenses)
{
if (av.attackingObjectId == attacker && av.targetObjectId == target)
{
attackValue = av;
}
}
}
else if(selfDefenses.Count == 1)
{
attackValue = selfDefenses[0];
}
if (selfDefenses.Count == 0 || attackValue == null)
return; //self defense not found
int attackStart = attackValue.attackStartTime;
int attackLength = attackValue.attackTimeWindow;
Attack at = new Attack(attacker, target, attackValue.capabilityName);
at.SetTimes(attackStart, attackLength);
currentAttacks.Add(at);
}
示例3: AttackObject
/// <summary>
/// Add the given object to the CurrentAttacks list. At time ticks, ViewProAttackUpdates
/// are sent out to clients using the attacks on the attack list.
/// </summary>
/// <param name="e">Incoming event</param>
private void AttackObject(SimulationEvent e)
{
string attackingID = ((StringValue)e["ObjectID"]).value;
string targetID = ((StringValue)e["TargetObjectID"]).value;
string capabilityName = ((StringValue)e["CapabilityName"]).value;
//int timeStart = ((IntegerValue)e["Time"]).value;
SimulationObjectProxy obj = objectProxies[attackingID];
AttackCollectionValue attCV = (AttackCollectionValue)obj["CurrentAttacks"].GetDataValue();
AttackCollectionValue.AttackValue thisAttack = null;
foreach (AttackCollectionValue.AttackValue av in attCV.GetCurrentAttacks())
{
if (av.attackingObjectId == attackingID && av.capabilityName == capabilityName && av.targetObjectId == targetID)
{ //ignore time for now.
thisAttack = av;
}
}
if (thisAttack != null)
{
int timeStart = thisAttack.attackStartTime;
int duration = thisAttack.attackTimeWindow;
Attack theAttack = new Attack(attackingID, targetID, thisAttack.capabilityName);
theAttack.SetTimes(timeStart, duration);
currentAttacks.Add(theAttack);
}
else
{
//this is bad.
}
}