当前位置: 首页>>代码示例>>C#>>正文


C# CSharpAI.Float3类代码示例

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


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

示例1: GetNearestReclaim

 public static Float3 GetNearestReclaim(Float3 mypos, int constructorid)
 {
     if( CSAI.GetInstance().aicallback.GetCurrentFrame() == 0 )// check ticks first, beacuse metal shows as zero at start
     {
         return null;
     }
     LogFile logfile = LogFile.GetInstance();
     IAICallback aicallback = CSAI.GetInstance().aicallback;
     IUnitDef unitdef = UnitController.GetInstance().UnitDefByDeployedId[ constructorid ];
     if (!new UnitDefHelp(aicallback).IsMobile(unitdef))
     {
         return null;
     }
     //Float3 mypos = aicallback.GetUnitPos( constructorid );
     MovementMaps movementmaps = MovementMaps.GetInstance();
     int currentarea = movementmaps.GetArea( unitdef, mypos );
     //double nearestreclaimdistancesquared = 1000000;
     //Float3 nearestreclaimpos = null;
     double bestmetaldistanceratio = 0;
     int bestreclaimid = 0;
     int metalspace = (int)( aicallback.GetMetalStorage() - aicallback.GetMetal() );
     logfile.WriteLine( "available space in metal storage: " + metalspace );
     int[] nearbyfeatures = aicallback.GetFeatures( mypos, maxreclaimradius );
     bool reclaimfound = false;
     foreach( int feature in nearbyfeatures )
     {
         IFeatureDef featuredef = aicallback.GetFeatureDef( feature );
         if( featuredef.metal > 0 && featuredef.metal <= metalspace  )
         {
             Float3 thisfeaturepos = aicallback.GetFeaturePos( feature );
             double thisdistance = Math.Sqrt( Float3Helper.GetSquaredDistance( thisfeaturepos, mypos ) );
             double thismetaldistanceratio = featuredef.metal / thisdistance;
             if( thismetaldistanceratio > bestmetaldistanceratio && movementmaps.GetArea( unitdef, thisfeaturepos ) == currentarea )
             {
                 logfile.WriteLine( "Potential reclaim, distance = " + thisdistance + " metal = " + featuredef.metal + " ratio = " + thismetaldistanceratio );
                 bestmetaldistanceratio = thismetaldistanceratio;
                 bestreclaimid = feature;
        //         nearestreclaimpo
                 reclaimfound = true;
             }
         }
     }
     if( reclaimfound && ( bestmetaldistanceratio > ( 1.0 / ( 100 * reclaimradiusperonehundredmetal ) ) ) )
     {
         Float3 reclaimpos = aicallback.GetFeaturePos( bestreclaimid );
         logfile.WriteLine( "Reclaim found, pos " + reclaimpos.ToString() );
         if( CSAI.GetInstance().DebugOn )
         {
             aicallback.DrawUnit( "ARMMEX", reclaimpos, 0.0f, 200, aicallback.GetMyAllyTeam(), true, true);
         }
         return reclaimpos;
         //aicallback.GiveOrder( constructorid, new Command( Command.CMD_RECLAIM,
         //    new double[]{ reclaimpos.x, reclaimpos.y, reclaimpos.z, 10 } ) );
     }
     else
     {
         //logfile.WriteLine( "No reclaim within parameters" );
         return null;
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:60,代码来源:ReclaimHelper.cs

示例2: Float3

 public static Float3 operator *( double multiplier, Float3 a )
 {
     Float3 result = new Float3();
     result.x = a.x * multiplier;
     result.y = a.y * multiplier;
     result.z = a.z * multiplier;
     return result;
 }
开发者ID:achoum,项目名称:spring,代码行数:8,代码来源:Float3.cs

示例3: Float3

 public static Float3 operator-( Float3 a, Float3 b )
 {
     Float3 result = new Float3();
     result.x = a.x - b.x;
     result.y = a.y - b.y;
     result.z = a.z - b.z;
     return result;
 }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:8,代码来源:Float3.cs

示例4: csai_UnitDamagedEvent

        // cheap hack to respond to enemy shooting us
        void csai_UnitDamagedEvent(int damaged, int attacker, float damage, Float3 dir)
        {
            /*
            if (!EnemyUnitDefByDeployedId.ContainsKey(attacker))
            {
                EnemyUnitDefByDeployedId.Add(attacker, aicallback.GetUnitDef(attacker));
            }
             */
            //if (!EnemyStaticPosByDeployedId.ContainsKey(attacker))
            //{
            Float3 enemypos = aicallback.GetUnitPos(attacker);
            if (enemypos != null &&
                Float3Helper.GetSquaredDistance(enemypos, new Float3(0, 0, 0)) > 10 * 10)
            {
                logfile.WriteLine("unitdamaged, attacker " + attacker + " pos " + enemypos);
                if (!EnemyStaticPosByDeployedId.ContainsKey(attacker))
                {
                    EnemyStaticPosByDeployedId.Add(attacker, enemypos);
                }
                else
                {
                    EnemyStaticPosByDeployedId[attacker] = enemypos;
                }
                if (NewStaticEnemyAddedEvent != null)
                {
                    NewStaticEnemyAddedEvent(attacker, enemypos, null);
                }
            }
            else // else we guess...
            {
                if (FriendlyUnitPositionObserver.GetInstance().PosById.ContainsKey(damaged))
                {
                    Float3 ourunitpos = FriendlyUnitPositionObserver.GetInstance().PosById[damaged];
                    if (ourunitpos != null)
                    {
                        Float3 guessvectortotarget = dir * 300.0;
                        logfile.WriteLine("vectortotarget guess: " + guessvectortotarget.ToString());
                        Float3 possiblepos = ourunitpos + guessvectortotarget;

                        if (!EnemyStaticPosByDeployedId.ContainsKey(attacker))
                        {
                            EnemyStaticPosByDeployedId.Add(attacker, possiblepos);
                        }
                        else
                        {
                            EnemyStaticPosByDeployedId[attacker] = possiblepos;
                        }

                        if (NewStaticEnemyAddedEvent != null)
                        {
                            NewStaticEnemyAddedEvent(attacker, possiblepos, null);
                        }
                        logfile.WriteLine("unitdamaged, attacker " + attacker + " our unit pos " + ourunitpos + " dir " + dir.ToString() + " guess: " + possiblepos.ToString());
                    }
                }
            }
            //}
        }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:59,代码来源:EnemyController.cs

示例5: DrawCircle

 public static void DrawCircle( Float3 pos, double radius )
 {
     IAICallback aicallback = CSAI.GetInstance().aicallback;
     Float3 lastpos = null;
     for( int angle = 0; angle <= 360; angle += 10 )
     {
         int x = (int)( (double)radius * Math.Cos ( (double)angle * Math.PI / 180 ) );
         int y = (int)( (double)radius * Math.Sin ( (double)angle * Math.PI / 180 ) );
         Float3 thispos = new Float3( x, 0, y ) + pos;
         if( lastpos != null )
         {
             aicallback.CreateLineFigure( thispos,lastpos,10,false,200,0);
         }
         lastpos = thispos;
     }
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:16,代码来源:DrawingUtils.cs

示例6: Regroup

 void Regroup( Float3 regouppos )
 {
     //   logfile.WriteLine( "AttackPackCoordinator regrouping to " + regouppos.ToString() );
       //  if( debugon )
     //    {
     //        aicallback.SendTextMsg( "AttackPackCoordinator regrouping to " + regouppos.ToString(), 0 );
      //   }
     MoveTo( regouppos );
 }
开发者ID:achoum,项目名称:spring,代码行数:9,代码来源:AttackPackCoordinatorUseGroup.cs

示例7: GetClosestUnits

 UnitInfo[] GetClosestUnits( Hashtable UnitDefListByDeployedId, Float3 targetpos, int numclosestunits )
 {
     UnitInfo[] closestunits = new UnitInfo[ numclosestunits ];
     double worsttopfivesquareddistance = 0; // got to get better than this to enter the list
     int numclosestunitsfound = 0;
     foreach( DictionaryEntry de in UnitDefListByDeployedId )
     {
         int deployedid = (int)de.Key;
         IUnitDef unitdef = de.Value as IUnitDef;
         Float3 unitpos = aicallback.GetUnitPos( deployedid );
         double unitsquareddistance = Float3Helper.GetSquaredDistance( unitpos, targetpos );
         if( numclosestunitsfound < numclosestunits )
         {
             UnitInfo unitinfo = new UnitInfo( deployedid, unitpos, unitdef, unitsquareddistance );
             InsertIntoArray( closestunits, unitinfo, numclosestunitsfound );
             numclosestunitsfound++;
             worsttopfivesquareddistance = closestunits[ numclosestunitsfound - 1 ].squareddistance;
         }
         else if( unitsquareddistance < worsttopfivesquareddistance )
         {
             UnitInfo unitinfo = new UnitInfo( deployedid, unitpos, unitdef, unitsquareddistance );
             InsertIntoArray( closestunits, unitinfo, numclosestunits );
             worsttopfivesquareddistance = closestunits[ numclosestunits - 1 ].squareddistance;
         }
     }
     return closestunits;
 }
开发者ID:achoum,项目名称:spring,代码行数:27,代码来源:AttackPackCoordinatorUseGroup.cs

示例8: GetRandomDestination

 Float3 GetRandomDestination()
 {
     Float3 destination = new Float3();
     destination.x = random.Next(0, aicallback.GetMapWidth() * MovementMaps.SQUARE_SIZE );
     destination.z = random.Next( 0, aicallback.GetMapHeight() * MovementMaps.SQUARE_SIZE );
     destination.y = aicallback.GetElevation( destination.x, destination.y );
     return destination;
 }
开发者ID:achoum,项目名称:spring,代码行数:8,代码来源:SpreadSearchPackCoordinator.cs

示例9: EnemyDamaged

 //called when an enemy inside los or radar is damaged
 public void EnemyDamaged(int damaged,int attacker,float damage, Float3 dir)
 {
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:4,代码来源:csai.cs

示例10: ExploreWith

 void ExploreWith( int unitid )
 {
     Float3 destination = new Float3();
    // if( PriorityTargets.Count > 0 )
    // {            
   //      destination = PriorityTargets.Dequeue() as Float3;
   //      logfile.WriteLine( "dequeued next destination: " + destination.ToString() );
   //  }
   //  else
   //  {
         destination.x = random.Next(0, aicallback.GetMapWidth() * MovementMaps.SQUARE_SIZE );
         destination.z = random.Next( 0, aicallback.GetMapHeight() * MovementMaps.SQUARE_SIZE );
         destination.y = aicallback.GetElevation( destination.x, destination.y );
         logfile.WriteLine( "mapwidth: " + aicallback.GetMapWidth() + " squaresize: " + MovementMaps.SQUARE_SIZE );
         logfile.WriteLine( "ScoutController sending scout " + unitid + " to " + destination.ToString() );
   //  }
     //aicallback.GiveOrder( unitid, new Command( Command.CMD_MOVE, destination.ToDoubleArray() ) );
     GiveOrderWrapper.GetInstance().MoveTo(unitid, destination);
 }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:19,代码来源:ScoutControllerRaider.cs

示例11: BuildUnit

 public void BuildUnit(int builderid, string targetunitname, Float3 pos)
 {
     int targetunittypeid = BuildTable.GetInstance().UnitDefByName[targetunitname.ToLower()].id;
     GiveOrder( new BuildCommand( builderid, targetunittypeid, pos ) );
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:5,代码来源:GiveOrderWrapper.cs

示例12: MetalSpot

 public MetalSpot( int amount, Float3 pos, bool isoccupied )
 {
     Amount = amount;
     IsOccupied = isoccupied;
     Pos = pos;
 }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:6,代码来源:Metal.cs

示例13: GetNearestMetalSpot

 public Float3 GetNearestMetalSpot( Float3 mypos )
 {
     if( !isMetalMap )
     {
         double closestdistancesquared = 1000000000000;
         Float3 bestpos = null;
         MetalSpot bestspot = null;
         foreach( MetalSpot metalspot in MetalSpots )
         {
             if( !MetalSpotsUsed.Contains( metalspot ) )
             {
                 if( bestpos == null )
                 {
                     bestpos = metalspot.Pos;
                 }
                 double thisdistancesquared = Float3Helper.GetSquaredDistance( mypos, metalspot.Pos );
                 //logfile.WriteLine( "thisdistancesquared = " + thisdistancesquared + " closestdistancesquared= " + closestdistancesquared );
                 if( thisdistancesquared < closestdistancesquared )
                 {
                     closestdistancesquared = thisdistancesquared;
                     bestpos = metalspot.Pos;
                     bestspot = metalspot;
                 }
             }
         }
         return bestspot.Pos;
     }
     else
     {
         return mypos; // if metal map just return passed-in pos
     }
 }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:32,代码来源:Metal.cs

示例14: Reclaim

 public void Reclaim(int unitid, Float3 pos, double radius)
 {
     GiveOrder(new ReclaimCommand(unitid, pos, radius));
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:4,代码来源:GiveOrderWrapper.cs

示例15: Attack

 public void Attack(int unitid, Float3 pos)
 {
     GiveOrder( new AttackCommand( unitid, new PositionTarget( pos ) ) );
 }
开发者ID:hughperkins,项目名称:SpringRTS-CSharpAI,代码行数:4,代码来源:GiveOrderWrapper.cs


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