コード例 #1
0
        // Token: 0x06000094 RID: 148 RVA: 0x0000490C File Offset: 0x00002B0C
        public void DumpToFile(bool withCurFrame = false)
        {
            bool flag = !this.enable;

            if (!flag)
            {
                string path          = this.dumpPath + "/cur.txt";
                string directoryName = Path.GetDirectoryName(path);
                bool   flag2         = !Directory.Exists(directoryName);
                if (flag2)
                {
                    Directory.CreateDirectory(directoryName);
                }
                StringBuilder stringBuilder  = new StringBuilder();
                StringBuilder stringBuilder2 = new StringBuilder();
                for (int i = 0; i <= base.Tick; i++)
                {
                    stringBuilder2.AppendLine(this._tick2RawFrameData[i].ToString());
                    stringBuilder.AppendLine(this._tick2OverrideFrameData[i].ToString());
                }
                File.WriteAllText(this.dumpPath + "/resume.txt", stringBuilder.ToString());
                File.WriteAllText(this.dumpPath + "/raw.txt", stringBuilder2.ToString());
                if (withCurFrame)
                {
                    this._curSb = this.DumpFrame();
                    int num = this._hashHelper.CalcHash(true);
                    File.WriteAllText(this.dumpPath + "/cur_single.txt", this._curSb.ToString());
                    File.WriteAllText(this.dumpPath + "/raw_single.txt", this._tick2RawFrameData[base.Tick].ToString());
                }
                Debug.Break();
            }
        }
コード例 #2
0
        public static void Assert(Func <bool> assertion, string assertString)
        {
            if (!assertion())
            {
                var myTrace           = new StackTrace(true);
                var myFrame           = myTrace.GetFrame(1);
                var assertInformation = "Filename: " + myFrame.GetFileName()
                                        + "\nMethod: " + myFrame.GetMethod()
                                        + "\nLine: "
                                        + myFrame.GetFileLineNumber();

                // Output message to Unity log window.
                Debug.Log(assertString + "\n" + assertInformation);
                // Break only in play mode.
                if (Application.isPlaying)
                {
                    Debug.Break();
                }
#if UNITY_EDITOR
                if (EditorUtility.DisplayDialog(
                        "Assert!",
                        assertString + "\n" + assertInformation,
                        "Close"))
                {
                }
#endif
            }
        }
コード例 #3
0
 public static void AssertContext(bool value, string message, UnityEngine.Object context)
 {
     if (value)
     {
         Debug.LogError(message, context);
         Debug.Break();
     }
 }
コード例 #4
0
 public static void Assert(bool value, string message)
 {
     if (value)
     {
         Debug.LogError(message);
         Debug.Break();
     }
 }
コード例 #5
0
 public static void That(Expression <Func <bool> > predicate)
 {
     if (!predicate.Compile().Invoke())
     {
         Debug.LogError("Assertion failed!\n" + predicate.Body);
         Debug.Break();
     }
 }
コード例 #6
0
 static public void Break()
 {
     if (EnableLog)
     {
         LogToFile("XLogger Break ");
         Debug.Log("XLogger Break ");
         Debug.Break();
     }
 }
コード例 #7
0
        /// <summary>
        /// Executes the operations in the DebugPacket specified.
        /// </summary>
        /// <param name="debugPacket"></param>
        private void ExecuteOperationsInDebugPacket(DebugPacket debugPacket)
        {
            if (debugPacket != null)
            {
                if (debugPacket.DebugBreak)
                {
                    Debug.Break();
                }

                if (debugPacket.Message != "")
                {
                    string message = "[Graphy] (" + System.DateTime.Now + "): " + debugPacket.Message;

                    switch (debugPacket.MessageType)
                    {
                    case MessageType.Log:
                        Debug.Log(message);
                        break;

                    case MessageType.Warning:
                        Debug.LogWarning(message);
                        break;

                    case MessageType.Error:
                        Debug.LogError(message);
                        break;
                    }
                }

                if (debugPacket.TakeScreenshot)
                {
                    string path = debugPacket.ScreenshotFileName + "_" + System.DateTime.Now + ".png";
                    path = path.Replace("/", "-").Replace(" ", "_").Replace(":", "-");

#if UNITY_2017_1_OR_NEWER
                    ScreenCapture.CaptureScreenshot(path);
#else
                    Application.CaptureScreenshot(path);
#endif
                }

                debugPacket.UnityEvents.Invoke();

                foreach (var callback in debugPacket.Callbacks)
                {
                    if (callback != null)
                    {
                        callback();
                    }
                }

                debugPacket.Executed();
            }
        }
コード例 #8
0
 void OnPreCull()
 {
     if (isMultithreading == false)
     {
         return;
     }
     if (frame >= maxNumber)
     {
         float totalTime = 0f;
         for (int i = 0; i < maxNumber; i++)
         {
             totalTime += elapsedTime[i];
         }
         Debug.Log("Average Time:" + totalTime / maxNumber);
         Debug.Break();
         return;
     }
     TestMBP.WaitAll();
 }
コード例 #9
0
ファイル: Logger.cs プロジェクト: Avatarchik/OutOfTheBox
 public static void Break()
 {
     Debug.Break();
 }
コード例 #10
0
ファイル: Utility.cs プロジェクト: suntabu/UnityRemoteLogger
 public static void LogBreak(object message, UnityEngine.Object sender = null)
 {
     LogInfo(message, sender);
     Debug.Break();
 }
コード例 #11
0
    public void IntLoadWorldData()
    {
        if (File.Exists(WorldDataPath + "gen_" + SettingWorldName + ".json"))
        {
            string jsonLoadGen = File.ReadAllText(WorldDataPath + "gen_" + SettingWorldName + ".json");
            SaveWorldGenData   = JsonUtility.FromJson <JAWGSaveWorldGenData>(jsonLoadGen);
            SettingWorldSize   = SaveWorldGenData.s_WorldSize;
            SettingWorldOffset = SaveWorldGenData.s_WorldOffset;
            SettingChunkSize   = SaveWorldGenData.s_ChunkSize;
            WorldSeed          = SaveWorldGenData.s_WorldSeed;
            Debug.Log("World_GenData Json Loaded Succesfully");
        }
        else
        {
            Debug.LogError("Missing WorldGenData File at: " + WorldDataPath + "gen_" + SettingWorldName + ".json");
            Debug.Break();
        }

        if (File.Exists(WorldDataPath + "run_" + SettingWorldName + ".json"))
        {
            string jsonLoadRun = File.ReadAllText(WorldDataPath + "run_" + SettingWorldName + ".json");
            SaveWorldRuntimeData      = JsonUtility.FromJson <JAWGSaveWorldRuntimeData>(jsonLoadRun);
            CurrentWorldTimeMinutes   = SaveWorldRuntimeData.s_CurrentMinutes;
            CurrentWorldTimeHours     = SaveWorldRuntimeData.s_CurrentHours;
            CurrentWorldTimeDays      = SaveWorldRuntimeData.s_CurrentDays;
            SettingCycleDayNight      = SaveWorldRuntimeData.s_GameRuleDoDayCycle;
            Player.transform.position = new Vector3(SaveWorldRuntimeData.s_PlayerCoordX, SaveWorldRuntimeData.s_PlayerCoordY, 0);
            Debug.Log("World_RunData Json Loaded Succesfully");
        }
        else
        {
            Debug.LogError("Missing WorldRuntimeData File at: " + WorldDataPath + "run_" + SettingWorldName + ".json");
            Debug.Break();
        }

        if (File.Exists(WorldDataPath + "res_" + SettingWorldName + ".json"))
        {
            string jsonLoadRes = File.ReadAllText(WorldDataPath + "res_" + SettingWorldName + ".json");
            SaveResourceObjectsData = JsonUtility.FromJson <ResourceObject[]>(jsonLoadRes);
            //Load Saved Data using the Saveable Format
            ResourceObject[] ResourceObjectsArray = new ResourceObject[SaveResourceObjectsData.Length];
            for (int res = 0; res < SaveResourceObjectsData.Length; res++)
            {
                ResourceObjectsArray[res].coordX          = SaveResourceObjectsData[res].coordX;
                ResourceObjectsArray[res].coordY          = SaveResourceObjectsData[res].coordY;
                ResourceObjectsArray[res].BiomeID         = SaveResourceObjectsData[res].BiomeID;
                ResourceObjectsArray[res].SurfaceObjectID = SaveResourceObjectsData[res].SurfaceObjectID;
            }

            //Convert Saveable format to the useable format
            WorldResourcesReadable = new GameObject[WorldSizeX, WorldSizeY];

            for (int res = 0; res < ResourceObjectsArray.Length; res++)
            {
                WorldResourcesReadable[ResourceObjectsArray[res].coordX, ResourceObjectsArray[res].coordY] = BiomesList[ResourceObjectsArray[res].BiomeID].SurfaceObjects[ResourceObjectsArray[res].SurfaceObjectID].ResourceObj;
            }

            Debug.Log("World_ResData Json Loaded Succesfully");
        }
        else
        {
            Debug.LogError("Missing WorldResourcesData File at: " + WorldDataPath + "res_" + SettingWorldName + ".json");
            Debug.Break();
        }

        if (File.Exists(WorldMapPath + "map_Landmass.png") && File.Exists(WorldMapPath + "map_Biomes.png"))
        {
            byte[] bytes_Landmass;
            byte[] bytes_Biomes;

            bytes_Landmass = File.ReadAllBytes(WorldMapPath + "map_Landmass.png");
            bytes_Biomes   = File.ReadAllBytes(WorldMapPath + "map_Biomes.png");

            map_Landmass = new Texture2D(2, 2);
            map_Biomes   = new Texture2D(2, 2);

            map_Landmass.LoadImage(bytes_Landmass);
            map_Biomes.LoadImage(bytes_Biomes);

            map_Landmass.filterMode = FilterMode.Point;
            map_Biomes.filterMode   = FilterMode.Point;

            Debug.Log("World_Map png Loaded Succesfully");
        }
        else
        {
            Debug.LogError("Missing WorldGenMap Files at: " + WorldMapPath + "map_Landmass.png" + "\n" + WorldMapPath + "map_Biomes.png");
            Debug.Break();
        }
    }
コード例 #12
0
 public static void Break()
 {
     UnityDebug.Break();
 }
コード例 #13
0
        private void executeDebug(string[] args)
        {
            if (args.Length == 0)
            {
                Debug.Log("");
            }
            else
            {
                string message = string.Join(" ", args, 1, args.Length - 1);
                switch (args[0])
                {
                case "-a":
                    Debug.LogAssertion(message, this);
                    break;

                case "-e":
                    Debug.LogError(message, this);
                    break;

                case "-x":
                    Debug.LogException(new Exception(message), this);
                    break;

                case "-l":
                    Debug.Log(message, this);
                    break;

                case "-w":
                    Debug.LogWarning(message, this);
                    break;

                case "-B":
                    Debug.Break();
                    break;

                case "-V":
                    Debug.Log(Debug.developerConsoleVisible);
                    break;

                case "-C":
                    Debug.ClearDeveloperConsole();
                    break;

                case "-D":
                    Debug.Log(Debug.isDebugBuild);
                    break;

                case "-H":
                    if (args.Length == 1)
                    {
                        Debug.Log(_hideDevConsole);
                    }
                    else if (args.Length == 2)
                    {
                        bool hideDevConsole = Utils.BoolParse(args[1]);
                        _hideDevConsole = hideDevConsole;
                    }
                    else
                    {
                        throw new SyntaxException();
                    }
                    break;

                case "-L":
                    if (args.Length == 3)
                    {
                        if (Utils.TryParseVector3(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 start) &&
                            Utils.TryParseVector3(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 end)
                            )
                        {
                            Debug.DrawLine(start, end, Color.black, 10f, false);
                        }
                        else
                        {
                            Debug.LogError("cannot parse \'" + args[1] + "\' to Vector3");
                        }
                    }
                    else
                    {
                        throw new SyntaxException();
                    }
                    break;

                case "-R":
                    if (args.Length == 3)
                    {
                        if (Utils.TryParseVector3(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 start) &&
                            Utils.TryParseVector3(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 dir)
                            )
                        {
                            Debug.DrawRay(start, dir, Color.black, 10f, false);
                        }
                        else
                        {
                            Debug.LogError("cannot parse \'" + args[1] + "\' to Vector3");
                        }
                    }
                    else
                    {
                        throw new SyntaxException();
                    }
                    break;

                case "-G":
                    int   size      = 64;
                    Color color     = Color.grey;
                    float duration  = 10f;
                    bool  depthTest = false;
                    for (int i = 1 - size; i < size; i++)
                    {
                        Debug.DrawLine(new Vector3(-size, 0f, i), new Vector3(size, 0f, i), color, duration, depthTest);
                        Debug.DrawLine(new Vector3(i, 0f, -size), new Vector3(i, 0f, size), color, duration, depthTest);
                    }
                    break;

                default:
                    Debug.Log(string.Join(" ", args, 0, args.Length));
                    break;
                }
            }
        }
コード例 #14
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (!isServer)
            {
                return;
            }

            if (IsEqualOrChildOfOwner(other.gameObject))
            {
                return;
            }

            Vector2 direction     = transform.up;
            var     perpendicular = Vector2.Perpendicular(direction);

            if (_owner != null)
            {
                Debug.DrawLine(_owner.transform.position, transform.position, Color.yellow, 2);
            }

            var shouldDespawn = false;

            foreach (var castDistance in CastDistances)
            {
                var castStart =
                    (Vector2)transform.position
                    + direction * castDistance
                    + perpendicular * CastWidth / 2;

                var castEnd =
                    (Vector2)transform.position
                    + direction * castDistance
                    - perpendicular * CastWidth / 2;

                Debug.DrawLine(castStart, castEnd, Color.magenta, 2);

                var cast = Physics2D.LinecastAll(castStart, castEnd)
                           .Select(h => h.transform)
                           .Where(h => h != transform && (_owner == null || h != _owner.transform))
                           .Distinct();

                foreach (var hit in cast)
                {
                    var target = hit.GetComponent <AbstractProjectileTarget>();
                    if (target != null)
                    {
                        target.TakeDamage(Damage, _ownerPlayer);
                        shouldDespawn = true;
                    }
                }

                if (shouldDespawn)
                {
                    TryDespawn();
                    break;
                }
            }

            if (!shouldDespawn)
            {
                Debug.LogError("Вроде во что-то врезались, а во что - не понятно: " + other.gameObject.name);
                Debug.Break();
            }
        }
コード例 #15
0
    public void IntLoadWorldData()
    {
        if (File.Exists(WorldDataPath + "gen_" + SettingWorldName + ".json"))
        {
            string jsonLoad = File.ReadAllText(WorldDataPath + "gen_" + SettingWorldName + ".json");
            SaveWorldGenData   = JsonUtility.FromJson <JAWGSaveWorldGenData>(jsonLoad);
            SettingWorldSize   = SaveWorldGenData.s_WorldSize;
            SettingWorldOffset = SaveWorldGenData.s_WorldOffset;
            SettingChunkSize   = SaveWorldGenData.s_ChunkSize;
            WorldSeed          = SaveWorldGenData.s_WorldSeed;
            Debug.Log("World_GenData Json Loaded Succesfully");
        }
        else
        {
            Debug.LogError("Missing WorldGenData File at: " + WorldDataPath + "gen_" + SettingWorldName + ".json");
            Debug.Break();
        }

        if (File.Exists(WorldDataPath + "run_" + SettingWorldName + ".json"))
        {
            string jsonLoad = File.ReadAllText(WorldDataPath + "run_" + SettingWorldName + ".json");
            SaveWorldRuntimeData      = JsonUtility.FromJson <JAWGSaveWorldRuntimeData>(jsonLoad);
            CurrentWorldTimeMinutes   = SaveWorldRuntimeData.s_CurrentMinutes;
            CurrentWorldTimeHours     = SaveWorldRuntimeData.s_CurrentHours;
            CurrentWorldTimeDays      = SaveWorldRuntimeData.s_CurrentDays;
            SettingCycleDayNight      = SaveWorldRuntimeData.s_GameRuleDoDayCycle;
            Player.transform.position = new Vector3(SaveWorldRuntimeData.s_PlayerCoordX, SaveWorldRuntimeData.s_PlayerCoordY, 0);
            Debug.Log("World_RunData Json Loaded Succesfully");
        }
        else
        {
            Debug.LogError("Missing WorldRuntimeData File at: " + WorldDataPath + "run_" + SettingWorldName + ".json");
            Debug.Break();
        }

        if (File.Exists(WorldMapPath + "map_Landmass.png") && File.Exists(WorldMapPath + "map_Biomes.png") && File.Exists(WorldMapPath + "map_Resources.png"))
        {
            byte[] bytes_Landmass;
            byte[] bytes_Biomes;
            byte[] bytes_Resources;

            bytes_Landmass  = File.ReadAllBytes(WorldMapPath + "map_Landmass.png");
            bytes_Biomes    = File.ReadAllBytes(WorldMapPath + "map_Biomes.png");
            bytes_Resources = File.ReadAllBytes(WorldMapPath + "map_Resources.png");

            map_Landmass  = new Texture2D(2, 2);
            map_Biomes    = new Texture2D(2, 2);
            map_Resources = new Texture2D(2, 2);

            map_Landmass.LoadImage(bytes_Landmass);
            map_Biomes.LoadImage(bytes_Biomes);
            map_Resources.LoadImage(bytes_Resources);

            map_Landmass.filterMode  = FilterMode.Point;
            map_Biomes.filterMode    = FilterMode.Point;
            map_Resources.filterMode = FilterMode.Point;

            Debug.Log("World_Map png Loaded Succesfully");
        }
        else
        {
            Debug.LogError("Missing WorldGenMap Files at: " + WorldMapPath + "map_Landmass.png" + "\n" + WorldMapPath + "map_Biomes.png" + "\n" + WorldMapPath + "map_Resources.png");
            Debug.Break();
        }
    }
コード例 #16
0
    private void Break(ContactPoint impact)
    {
        //Align Fracture Pattern
        // var colliders = Pattern.GetComponentsInChildren<Collider>();
        // Bounds bounds = colliders[0].bounds;
        // foreach(var c in colliders) bounds.Encapsulate(c.bounds);
        //
        // var szA = GetComponent<Collider>().bounds.size;
        // var szB = bounds.size;
        // var scale = new Vector3(szA.x / szB.x, szA.y / szB.y, szA.z / szB.z);
        // Pattern.transform.localScale = scale;
        var patternGO = Instantiate(Pattern, impact.point, transform.rotation);



        Debug.Break();
        //Intersection: Clip Convex against all planes of cell of fracture pattern

        // foreach (var convex in GetComponentsInChildren<MeshCollider>())
        // {



        foreach (var cell in patternGO.GetComponentsInChildren <MeshCollider>())
        {
            Vector3 direction;
            float   distance;
            // if (Physics.ComputePenetration(convex, convex.gameObject.transform.position, convex.gameObject.transform.rotation, cell, cell.gameObject.transform.position,
            //     cell.gameObject.transform.rotation, out direction, out distance))
            {
                // var hulls = new List<SlicedHull>();
                // var triangleCount = cell.sharedMesh.triangles.Length / 3;
                //
                // //Get Planes
                // for (int i = 0; i < triangleCount; i++)
                // {
                //     var sharedMesh = cell.sharedMesh;
                //     Vector3 V1 = sharedMesh.vertices[sharedMesh.triangles[i * 3]];
                //     Vector3 V2 = sharedMesh.vertices[sharedMesh.triangles[i * 3 + 1]];
                //     Vector3 V3 = sharedMesh.vertices[sharedMesh.triangles[i * 3 + 2]];
                //
                //     var plane = new Plane(V1, V2, V3);
                //
                //     if (!planes.Contains(plane)) planes.Add(plane);
                // }



                // var convexvertices = clonedMesh.vertices.ToList();
                // var cellVertices = cell.sharedMesh.vertices.ToList();
                // var newMesh = new MyMesh("Fractured");
                // var newVertices = SutherlandHodgman.ClipPolygon(convexvertices, cellVertices);
                // var newTriangles = TriangulateConvexPolygon(newVertices);
                //
                // newMesh.vertices = newVertices;
                // foreach (var triangle in newTriangles)
                // {
                // }
                //
                // clonedMesh.Clear();
                // clonedMesh.vertices = newVertices.ToArray();
                // clonedMesh.triangles = newTriangles.
                // convex.sharedMesh = clonedMesh;



                // foreach (var plane in planes)
                // {
                //     var hull = convex.gameObject.Slice(plane, fillMaterial);
                //     if(hull != null) hulls.Add(hull);
                // }
                //
                //
                // foreach (var slicedHull in hulls)
                // {
                //     slicedHull.CreateLowerHull(convex.gameObject, fillMaterial);
                //     slicedHull.CreateUpperHull(convex.gameObject, fillMaterial);
                //
                // }
                // convex.gameObject.SetActive(false);
                //Debug.Break();
                //
                //     if (hull != null)
                //     {
                //         hulls.Add(hull);
                //
                //         var go = hull.CreateLowerHull(convex.gameObject, fillMaterial);
                //         var rb = go.AddComponent<Rigidbody>();
                //         rb.velocity = GetComponent<Rigidbody>().velocity;
                //         var newCollider = go.AddComponent<MeshCollider>();
                //         newCollider.convex = true;
                //
                //         go = hull.CreateUpperHull(convex.gameObject, fillMaterial);
                //         rb = go.AddComponent<Rigidbody>();
                //         rb.velocity = GetComponent<Rigidbody>().velocity;
                //         newCollider = go.AddComponent<MeshCollider>();
                //         newCollider.convex = true;
                //     }
                // }
                // intersections.Add(hulls);
            }
        }
        //}


        // var hull = gameObject.Slice(transform.position, transform.up, fillMaterial);
        //
        // if (hull != null)
        // {
        //     _sw.Start();
        //     // var go = hull.CreateLowerHull(gameObject, fillMaterial);
        //     // var rb = go.AddComponent<Rigidbody>();
        //     // rb.velocity = GetComponent<Rigidbody>().velocity;
        //     // var newCollider = go.AddComponent<MeshCollider>();
        //     // newCollider.convex = true;
        //     // var patternScript= go.AddComponent<FracturePattern>();
        //     // patternScript.fillMaterial = fillMaterial;
        //     //
        //     //
        //     // go = hull.CreateUpperHull(gameObject, fillMaterial);
        //     // rb = go.AddComponent<Rigidbody>();
        //     // rb.velocity = GetComponent<Rigidbody>().velocity;
        //     // newCollider = go.AddComponent<MeshCollider>();
        //     // newCollider.convex = true;
        //     // patternScript= go.AddComponent<FracturePattern>();
        //     // patternScript.fillMaterial = fillMaterial;
        //
        //
        //     var lower = Instantiate(this);
        //     lower.GetComponent<MeshFilter>().mesh = hull.lowerHull;
        //     lower.GetComponent<MeshCollider>().sharedMesh = hull.lowerHull;
        //     lower.GetComponent<Rigidbody>().AddForce(_rb.velocity);
        //     Destroy(lower.GetComponent<FracturePattern>());
        //
        //     var upper = Instantiate(this);
        //     upper.GetComponent<MeshFilter>().mesh = hull.upperHull;
        //     upper.GetComponent<MeshCollider>().sharedMesh = hull.upperHull;
        //     upper.GetComponent<Rigidbody>().AddForce(_rb.velocity);
        //     Destroy(upper.GetComponent<FracturePattern>());
        //
        //
        //     gameObject.SetActive(false);
        //     _sw.Stop();
        //     Debug.Log("Instantiate took " + _sw.Elapsed);
        // }
        //Destroy(patternGO);
    }
コード例 #17
0
    void Step()
    {
        Profiler.BeginSample("Clear Lists");
        allNeighbors.Clear();
        neighborCounts.Clear();
        Profiler.EndSample();

        Profiler.BeginSample("Calculating all the neighbors");
        try
        {
            for (int i = 0; i < particles.Count; i++)
            {
                List <Particle> neighbors = CalculateNeighbors(particles[i], i);
                neighborCounts.Add(neighbors.Count);
                allNeighbors.AddRange(neighbors);
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
            Debug.Break();
        }
        Profiler.EndSample();

        if (!GPU)
        {
            int start = 0;
            Profiler.BeginSample("NeighborRecalculation");
            for (int i = 0; i < particles.Count; i++)
            {
                for (int j = 0; j < neighborCounts[i]; j++)
                {
                    try
                    {
                        particles[i].Density = Mathf.Max(ParticleDensity(particles[i], distances[i][j]), restingDensity);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("Particle count: " + particles.Count);
                        Debug.Log("All Neighbors: " + allNeighbors.Count);
                        Debug.Log("Start Index: " + start);
                        Debug.Log("Index: " + j);
                        Debug.Log("End Index: " + (start + neighborCounts[i]));
                        throw e;
                    }
                }
                particles[i].Pressure = Mathf.Max(gasConstant * (particles[i].Density - restingDensity), 0);
            }
            Profiler.EndSample();

            Profiler.BeginSample("ForceCalculation");
            ForceCalculation();
            Profiler.EndSample();
        }
        else
        {
            if (particles.Count > 0)
            {
            }
        }
        Profiler.BeginSample("ParticleMovement");
        ParticleMovement();
        Profiler.EndSample();
    }
コード例 #18
0
        void Update()
        {
            switch (_state)
            {
            case State.Waiting: {
                if (Time.realtimeSinceStartup > StartDelay)
                {
                    _state = State.Create;
                }
            }
            break;

            case State.Create: {
                Profiler.BeginSample("Create");
                Create();
                Profiler.EndSample();
                _state = State.Init;
            }
            break;

            case State.Init: {
                Profiler.BeginSample("Init");
                Init();
                Profiler.EndSample();
                _state = State.Update;
            }
            break;

            case State.Update: {
                Profiler.BeginSample("UpdateFrames");
                UpdateFrames();
                Profiler.EndSample();
            }
            break;

            case State.Finish: {
                if (!_isFinished)
                {
                    _isFinished = true;
                    WriteResults();
                }
                if (Time.realtimeSinceStartup > (_endTime + EndDelay))
                {
                    _state = State.Disable;
                }
            }
            break;

            case State.Disable: {
                _state  = State.Disable;
                enabled = false;
                if (ShowCacheCounts)
                {
                    DebugCacheCounts();
                }
                Debug.Break();
                Application.Quit();
            }
            break;
            }
        }
コード例 #19
0
    // get the next road coming up
    public void SetNextRoad()
    {
        Dictionary <String, Transform> dict;

        dict = CompareTag("firebrigade") ? _currentRoad.GetComponent <WaypointPath>().GetNextRandomWaypointPathForFirebrigade() : _currentRoad.GetComponent <WaypointPath>().GetNextRandomWaypointPath();
        String[] roadChoice = dict.Keys.ToArray();
        NextRoad                  = dict[roadChoice[0]];
        LeftCross                 = false;
        RightCross                = false;
        LeftJunctionJoin          = false;
        RightJunctionJoin         = false;
        LeftJunctionLeave         = false;
        RightJunctionCrossing     = false;
        IsGoingStraightAtCross    = false;
        IsGoingStraightAtJunction = false;
        IsUnableToMove            = false;
        switch (roadChoice[0])
        {
        case "straight-cross":
            IsGoingStraightAtCross = true;
            break;

        case "left-cross":
            LeftCross = true;
            break;

        case "right-cross":
            RightCross = true;
            break;

        case "straight-junction":
            IsGoingStraightAtJunction = true;
            break;

        case "left-junction-join":
            LeftJunctionJoin = true;
            break;

        case "right-junction-join":
            RightJunctionJoin = true;
            break;

        case "left-junction-leave":
            LeftJunctionLeave = true;
            break;

        case "right-junction-crossing":
            RightJunctionCrossing = true;
            break;

        case "despawn":
            GetComponentInParent <TrafficDensity>().Despawn(gameObject);
            break;

        case "cant-move":
            IsUnableToMove = true;
            break;

        default:
            print("SetNextRoad switch statement:\t" + gameObject.name);
            Debug.Break();
            break;
        }
    }