本文整理汇总了C#中IUnitDef类的典型用法代码示例。如果您正苦于以下问题:C# IUnitDef类的具体用法?C# IUnitDef怎么用?C# IUnitDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IUnitDef类属于命名空间,在下文中一共展示了IUnitDef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMex
public bool IsMex(IUnitDef ud)
{
if(ud.type.ToLower() == "metalextractor"){
return true;
}
return false;
}
示例2: MobileFusionController_UnitAddedEvent
void MobileFusionController_UnitAddedEvent(int deployedid, IUnitDef unitdef)
{
if (unitdef.name.ToLower() == "armmfus")
{
mobileunits.Add(deployedid);
}
}
示例3: IsAirCraft
public bool IsAirCraft(IUnitDef ud)
{
if(ud.type.ToLower() == "fighter") return true;
if(ud.type.ToLower() == "bomber") return true;
if(ud.canfly&&(ud.movedata == null)) return true;
return false;
}
示例4: TankController
public TankController( Dictionary< int,IUnitDef>UnitDefsById, IUnitDef typicalunitdef)
{
csai = CSAI.GetInstance();
aicallback = csai.aicallback;
logfile = LogFile.GetInstance();
this.DefsById = UnitDefsById;
this.typicalunitdef = typicalunitdef;
unitcontroller = UnitController.GetInstance();
enemycontroller = EnemyController.GetInstance();
buildtable = BuildTable.GetInstance();
enemyselector = new EnemySelector2( typicalunitdef.speed * 2, typicalunitdef );
// speed here is experimental
attackpackcoordinator = new AttackPackCoordinator(DefsById);
spreadsearchpackcoordinator = new SpreadSearchPackCoordinator(DefsById);
movetopackcoordinator = new MoveToPackCoordinator(DefsById);
guardpackcoordinator = new GuardPackCoordinator(DefsById);
packcoordinatorselector = new PackCoordinatorSelector();
packcoordinatorselector.LoadCoordinator( attackpackcoordinator );
packcoordinatorselector.LoadCoordinator( spreadsearchpackcoordinator );
packcoordinatorselector.LoadCoordinator( movetopackcoordinator );
packcoordinatorselector.LoadCoordinator( guardpackcoordinator );
logfile.WriteLine( "*TankController Initialized*" );
}
示例5: IsBoat
public bool IsBoat( IUnitDef unitdef )
{
if( IsMobile( unitdef ) && unitdef.minWaterDepth > 0 )
{
return true;
}
return false;
}
示例6: CanBuild
// looks at current power usage, and requirements for unit, and decides if we can build it without stalling
// assumes nothing else suddenly starting at same time...
// do something more elegant later
public bool CanBuild( IUnitDef def )
{
double excesspowerrequired = ( def.energyCost - aicallback.GetEnergy() ) / def.buildTime;
double oursurplus = aicallback.GetEnergyIncome() - aicallback.GetEnergyUsage();
// logfile.WriteLine( "Out income: " + aicallback.GetEnergyIncome() + " usage: " + aicallback.GetEnergyUsage() + " surplus: " + oursurplus );
bool result = excesspowerrequired < oursurplus;
//logfile.WriteLine( "Current energy: " + aicallback.GetEnergy() + " itemenergycost: " + def.energyCost + " buildtime: " + def.buildTime + " Excesspowerrequired: " + excesspowerrequired + " overall: " + result );
return result;
}
示例7: UnitDefArrayList
public UnitDefArrayList( IUnitDef[] array )
{
if( array != null )
{
foreach( IUnitDef value in array )
{
base.Add( value );
}
}
}
示例8: IsEnergy
public bool IsEnergy(IUnitDef ud)
{
if(ud.needGeo){
return false;
}
if(ud.energyUpkeep<-1) return true;
if((ud.windGenerator>0)&&(aicallback.GetMaxWind()>9)) return true;
if(ud.tidalGenerator>0) return true;
if(ud.energyMake>5) return true;
return false;
}
示例9: Level1ConstructorList_UnitAddedEvent
void Level1ConstructorList_UnitAddedEvent(int deployedid, IUnitDef unitdef)
{
if (!defbyid.ContainsKey(deployedid))
{
string name = unitdef.name.ToLower();
if (constructorunitnames.Contains(name))
{
defbyid.Add(deployedid, unitdef);
}
}
}
示例10: UnitAddedEvent
void UnitAddedEvent(int deployedid, IUnitDef unitdef)
{
if (!defbyid.ContainsKey(deployedid))
{
string name = unitdef.name.ToLower();
if (unitnames.Contains(name))
{
defbyid.Add(deployedid, unitdef);
}
}
}
示例11: UnitAddedEvent
void UnitAddedEvent(int deployedid, IUnitDef unitdef)
{
if (!defbyid.ContainsKey(deployedid))
{
string name = unitdef.name.ToLower();
if (commandernames.Contains(name))
{
LogFile.GetInstance().WriteLine("commanderlist unitaddedevent " + deployedid + " " + unitdef.humanName);
defbyid.Add(deployedid, unitdef);
}
}
}
示例12: CanBuild
// looks at current power usage, and requirements for unit, and decides if we can build it without stalling
// assumes nothing else suddenly starting at same time...
// do something more elegant later
public bool CanBuild( IUnitDef def )
{
return aicallback.GetMetal() > def.metalCost;
/*
double excessmetalrequired = ( def.metalCost - aicallback.GetMetal() ) / def.buildTime;
double OurIncome = aicallback.GetMetalIncome() - aicallback.GetMetalUsage();
logfile.WriteLine( "Metal income: " + aicallback.GetMetalIncome() + " metal usage: " + aicallback.GetMetalUsage() );
bool result = excessmetalrequired < OurIncome;
logfile.WriteLine( "Current metal: " + aicallback.GetMetal() + " itemmetalcost: " + def.metalCost + " buildtime: " + def.buildTime + " excessmetalrequired: " + excessmetalrequired + " our income: " + OurIncome + " overall: " + result );
return result;
*/
}
示例13: UnitCreatedEvent
void UnitCreatedEvent(int deployedunitid, IUnitDef unitdef)
{
IAICallback aicallback = CSAI.GetInstance().aicallback;
if (aicallback.GetCurrentFrame() <= 1)
{
if (unitdef.isCommander)
{
startposition = aicallback.GetUnitPos(deployedunitid);
//aicallback.get
}
}
}
示例14: UnitAddedEvent
void UnitAddedEvent(int deployedid, IUnitDef unitdef)
{
LogFile.GetInstance().WriteLine("TankList.UnitAddedEvent " + deployedid + " " + unitdef.humanName);
if (!defbyid.ContainsKey(deployedid))
{
string name = unitdef.name.ToLower();
if (unitnames.Contains(name))
{
LogFile.GetInstance().WriteLine("TankList.UnitAddedEvent " + deployedid + " " + unitdef.humanName + " ACCEPTED");
defbyid.Add(deployedid, unitdef);
}
}
}
示例15: csai_UnitCreatedEvent
void csai_UnitCreatedEvent(int deployedunitid, IUnitDef unitdef)
{
foreach (Order order in orders)
{
if (order.orderedunit.id == unitdef.id)
{
Float3 createdunitpos = aicallback.GetUnitPos( deployedunitid );
if (Float3Helper.GetSquaredDistance(createdunitpos, order.pos) < maxdistanceconsideredsame * maxdistanceconsideredsame)
{
order.unitdeployedid = deployedunitid;
order.factorycontroller.UnitCreated(order, deployedunitid);
}
}
}
}