Esempio n. 1
0
    // todo: call record and stop from functions, every unity should use it's id for key
    public static void Record(string tag)
    {
        if (recordings.ContainsKey(tag))
        {
            recordings[tag] = Time.realtimeSinceStartup;
        }
        else
        {
            recordings.Add(tag, Time.realtimeSinceStartup);
        }

        if (counted.ContainsKey(tag))
        {
            counted[tag] = counted[tag] + 1;
        }
        else
        {
            counted.Add(tag, 0);
        }
        if (m == null)
        {
            m      = new GameObject().AddComponent <TimeDebug>();
            m.name = "TimeDebugger";
        }
    }
Esempio n. 2
0
        protected override void OnStart()
        {
            var td = new TimeDebug("App.OnStartTimeDebug");

            td.Step("InitializeComponent");

            for (var i = Environment.SpecialFolder.Desktop; i < Environment.SpecialFolder.CDBurning; ++i)
            {
                try
                {
                    Console.WriteLine($"Environment.GetFolderPath({i}):{Environment.GetFolderPath(i)}");
                }
                catch (Exception e)
                {
                    // Console.WriteLine(e);
                }
            }
            try
            {
                var lua = LuaSys.Instance;
                LuaSys.Instance.Init();

                td.Step("lua.AddBuildin");
                lua.DoString(Resource.GetStr("lua/main.lua"));
                td.Step("lua/main");
            }
            catch (Exception e)
            {
                Debug.WriteLine($"lua error: {e.Message}\n {e.StackTrace}");
            }

            mysqlTest();
            td.Step("mysqlTest");
        }
Esempio n. 3
0
 public static void Stop(string tag)
 {
     recordings[tag] = Time.realtimeSinceStartup - recordings[tag];
     if (m == null)
     {
         m = new GameObject().AddComponent <TimeDebug>();
     }
 }
Esempio n. 4
0
 bool FindPointOfInterest()
 {
     TimeDebug.Record("find_point_" + name + "_" + GetInstanceID());
     poiTarget = (SomethingInteresting)GlobalPOI.RandomPOI(transform.position);
     TimeDebug.Stop("find_point_" + name + "_" + GetInstanceID());
     if (poiTarget)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
    public bool WalkToWp()
    {
        TimeDebug.Record("walktowp_" + name + "_" + GetInstanceID());
        if (pathfinder)
        {
            pathfinder.UpdatePathfinder(ref _wp);
        }
        TimeDebug.Stop("walktowp_" + name + "_" + GetInstanceID());

        TimeDebug.Record("checkdist_" + name + "_" + GetInstanceID());
        CheckDistances();
        TimeDebug.Stop("checkdist_" + name + "_" + GetInstanceID());

        if (!walking)
        {
            return(false);         // false: not moving; true: moving
        }
        TimeDebug.Record("move_" + name + "_" + GetInstanceID());

        // get direction fixes that will prevent getting stuck on other npc's
        Vector3 fix = Vector3.zero; // broken when chasing enemies GetFixedDistanceFromCrowd();
        //Vector3 fix2 = GetFixedDistanceFromWalls();

        Vector3 dir = (_wp - t.position).normalized;

        fix = dir;
        if (moveFixing)
        {
            moveFixing.ApplyFix(ref fix, t.position);
        }

        //dir = (dir + fix).normalized;
        dir = fix.normalized;
        rig.MovePosition(t.position + dir * Time.deltaTime * speed);
        //Debug.DrawLine(t.position, _wp, Color.yellow);
        TimeDebug.Stop("move_" + name + "_" + GetInstanceID());

        return(true);
    }
Esempio n. 6
0
 FBStatus WaitAtPointOfInterest()
 {
     TimeDebug.Record("waiting_" + name + "_" + GetInstanceID());
     if (waiting == false)
     {
         waiting = true;
         time    = Time.time + poiTarget.timeInvestment * attentionLevel;
         poiTarget.NewParticipant(this);
     }
     if (waiting)
     {
         if (Time.time < time)
         {
             return(FBStatus.Running);
         }
         poiTarget.LostInterest(this);
         waiting = false;
         TimeDebug.Stop("waiting_" + name + "_" + GetInstanceID());
         return(FBStatus.Success);
     }
     TimeDebug.Stop("waiting_" + name + "_" + GetInstanceID());
     return(FBStatus.Failure);
 }
Esempio n. 7
0
 void Awake()
 {
     m = this;
 }