• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IUnitDef类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IUnitDef的典型用法代码示例。如果您正苦于以下问题:C# IUnitDef类的具体用法?C# IUnitDef怎么用?C# IUnitDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IUnitDef类属于命名空间,在下文中一共展示了IUnitDef类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: IsMex

 public bool IsMex(IUnitDef ud)
 {
     if(ud.type.ToLower() == "metalextractor"){
         return true;
     }
     return false;
 }
开发者ID:achoum,项目名称:spring,代码行数:7,代码来源:UnitDefHelp.cs


示例2: MobileFusionController_UnitAddedEvent

 void MobileFusionController_UnitAddedEvent(int deployedid, IUnitDef unitdef)
 {
     if (unitdef.name.ToLower() == "armmfus")
     {
         mobileunits.Add(deployedid);
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:7,代码来源:MobileFusionController.cs


示例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;
 }
开发者ID:achoum,项目名称:spring,代码行数:7,代码来源:UnitDefHelp.cs


示例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*" );
        }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:29,代码来源:TankController.cs


示例5: IsBoat

 public bool IsBoat( IUnitDef unitdef )
 {
     if( IsMobile( unitdef ) && unitdef.minWaterDepth > 0 )
     {
         return true;
     }
     return false;
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:8,代码来源:UnitDefHelp.cs


示例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;
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:12,代码来源:EnergyController.cs


示例7: UnitDefArrayList

 public UnitDefArrayList( IUnitDef[] array )
 {
     if( array != null )
     {
         foreach( IUnitDef value in array )
         {
             base.Add( value );
         }
     }
 }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:10,代码来源:BuildTable.cs


示例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;
 }
开发者ID:achoum,项目名称:spring,代码行数:11,代码来源:UnitDefHelp.cs


示例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);
         }
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:11,代码来源:Level1ConstructorList.cs


示例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);
         }
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:11,代码来源:HelicopterList.cs


示例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);
         }
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:12,代码来源:CommanderList.cs


示例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;
     */
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:15,代码来源:MetalController.cs


示例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
         }
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:12,代码来源:StartPosition.cs


示例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);
         }
     }
 }
开发者ID:achoum,项目名称:spring,代码行数:13,代码来源:TankList.cs


示例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);
             }
         }
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:15,代码来源:Ownership.cs


示例16: UnitAdded

 public void UnitAdded( int id, IUnitDef unitdef )
 {
     if( !PosById.ContainsKey( id ) )
     {
         PosById.Add( id, aicallback.GetUnitPos( id ) );
         if( unitdefhelp.IsMobile( unitdef ) )
         {
             MobileUnitIds.Add( id );
         }
         else
         {
             StaticUnitIds.Add( id );
         }
     }
 }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:15,代码来源:FriendlyUnitPositions.cs


示例17: 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 )
 {
     // if (csai.DebugOn)
       //  {
       //      aicallback.SendTextMsg("metalcontroller canbuild " + def.humanName + " current metal: " + aicallback.GetMetal() + " cost: " + def.metalCost, 0);
       //  }
     if (aicallback.GetMetal() > def.metalCost)
     {
         return true;
     }
     //return aicallback.GetMetal() > def.metalCost;
     double excessmetalrequired = ( def.metalCost - aicallback.GetMetal() * 8 / 10 ) / def.buildTime;
     double OurIncome = aicallback.GetMetalIncome() - aicallback.GetMetalUsage();
     logfile.WriteLine( "Metal income: " + aicallback.GetMetalIncome() + " metal usage: " + aicallback.GetMetalUsage() );
     bool result = ( excessmetalrequired * 4 ) < OurIncome;
     logfile.WriteLine( "Current metal: " + aicallback.GetMetal() + " itemmetalcost: " + def.metalCost + " buildtime: " + def.buildTime + " excessmetalrequired: " + excessmetalrequired + " our income: " + OurIncome + " overall: " + result );
     return result;
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:21,代码来源:MetalController.cs


示例18: EnemySelector2

        public EnemySelector2(double maxenemyspeed, IUnitDef typicalunitdef)
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            // csai.EnemyEntersLOSEvent += new CSAI.EnemyEntersLOSHandler( EnemyEntersLOS );

            enemycontroller = EnemyController.GetInstance();
            unitdefhelp = new UnitDefHelp(aicallback);

            this.maxenemyspeed = maxenemyspeed;
            this.WaterOk = WaterOk;
            this.BadTerrainOk = BadTerrainOk;

            this.typicalunitdef = typicalunitdef;
            //    startarea = MovementMaps.GetInstance().GetArea(typicalunitdef, startpos);
        }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:18,代码来源:EnemySelector2.cs


示例19: EnemyAdded

 public void EnemyAdded( int id, IUnitDef unitdef )
 {
   //  Float3 enemypos = aicallback.GetUnitPos( id );
   //  for( int i = 0; i < 3; i++ )
   //  {
    //     Float3 randomoffset = new Float3( random.Next( -enemysightedsearchradius, enemysightedsearchradius ), 0, random.Next( -enemysightedsearchradius, enemysightedsearchradius ) );
    //     if( csai.DebugOn )
    //     {
     //        aicallback.DrawUnit("ARMARAD", enemypos + randomoffset, 0.0f, 500, aicallback.GetMyAllyTeam(), true, true);
     //    }
      //   PriorityTargets.Enqueue( enemypos + randomoffset );
   //  }
 }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:13,代码来源:ScoutControllerRaider.cs


示例20: YourRequestWasDestroyedDuringBuilding_Sorry

 // your request got destroyed; new what-to-build negotations round
 public void YourRequestWasDestroyedDuringBuilding_Sorry( IUnitDef unitwearebuilding )
 {
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:4,代码来源:Builder.cs



注:本文中的IUnitDef类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IUnitOfWork类代码示例发布时间:2022-05-24
下一篇:
C# IUnitAction类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap