Ignore:
Timestamp:
2013-08-29 21:35:13 (7 years ago)
Author:
dezhidki
Message:
  • Muokattu AStarin debuggausta
  • Väritetty pelaajien pelinappuloita
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Ai/AStar.cs

    r4646 r4752  
    55using CastleMaster.World; 
    66using CastleMaster.Units.Mobs; 
     7using System.Diagnostics; 
    78 
    89namespace IsometricEngineTest.Ai 
     
    2627 
    2728#if DEBUG 
    28         private TimeSpan totalTime = TimeSpan.Zero; 
     29        private Stopwatch timer; 
    2930#endif 
    3031 
     
    3738 
    3839            TIRE_FIX = (1.0 + (MOVE_STRAIGHT / 1000.0)); 
     40 
     41#if DEBUG 
     42            timer = new Stopwatch(); 
     43#endif 
    3944        } 
    4045 
     
    6772 
    6873#if DEBUG 
    69             totalTime = TimeSpan.Zero; 
     74            timer.Reset(); 
    7075            Console.WriteLine("[START] From: [ " + xStart + ", " + zStart + " ] to : [ " + xEnd + ", " + zEnd + "]."); 
    7176#endif 
     
    121126        { 
    122127#if DEBUG 
    123             DateTime startTime = DateTime.Now; 
     128            TimeSpan lastTime = timer.Elapsed; 
     129            timer.Start(); 
    124130#endif 
    125131            calls++; 
     
    133139                { 
    134140#if DEBUG 
    135                     totalTime += DateTime.Now - startTime; 
    136                     Console.WriteLine("[PAUSE] Calls so far: " + calls + ". Time spent: " + ((DateTime.Now - startTime).TotalMilliseconds) + " ms."); 
     141                    timer.Stop(); 
     142                    Console.WriteLine("[PAUSE] Calls so far: " + calls + ". Time spent: " + ((timer.Elapsed - lastTime).TotalMilliseconds) + " ms."); 
    137143#endif 
    138144                    return; 
     
    143149                { 
    144150#if DEBUG 
    145                     totalTime += DateTime.Now - startTime; 
    146                     Console.WriteLine("[FAIL] No more open nodes! Calls: " + calls + ". Total time: " + totalTime.TotalMilliseconds + " ms."); 
     151                    timer.Stop(); 
     152                    Console.WriteLine("[FAIL] No more open nodes! Calls: " + calls + ". Total time: " + timer.Elapsed.TotalMilliseconds + " ms."); 
    147153#endif 
    148154                    canPathFind = false; 
     
    190196 
    191197#if DEBUG 
    192             totalTime += DateTime.Now - startTime; 
    193             Console.WriteLine("[FINISH] Calls: " + calls + ". Total time: " + totalTime.TotalMilliseconds + " ms."); 
     198            timer.Stop(); 
     199            Console.WriteLine("[FINISH] Calls: " + calls + ". Total time: " + timer.Elapsed.TotalMilliseconds + " ms."); 
    194200#endif 
    195201 
Note: See TracChangeset for help on using the changeset viewer.