void Update()
        {
            var eManager = World.DefaultGameObjectInjectionWorld.EntityManager;

            if (m_rotating)
            {
                float timePassed      = (Time.realtimeSinceStartup % m_360RotationTime);
                float rotationPercent = timePassed / m_360RotationTime;
                var   angle           = 360.0f * rotationPercent;
                var   rot             = quaternion.RotateZ(angle);

                eManager.SetComponentData(Sprite, new Rotation {
                    Value = rot
                });
            }

            if (!m_moving)
            {
                return;
            }

            float  percent = (Time.realtimeSinceStartup % 1.0f);
            float2 offset  = new float2(1) * ((percent * m_speed) - m_speed / 2);
            float3 pos     = m_startPosition + new float3(offset, 0);

            eManager.SetComponentData(Sprite, new Translation {
                Value = pos
            });
            DebugExtensions.LogVar(new
            {
                pos,
                trans = eManager.GetComponentData <Translation>(Sprite).Value
            });
        }
    public void CheckBlocking(ref Vector2 original, HashSet <Tile> tilesToMove)
    {
        Vector2 largestValidMoveAmount = original;
        Vector2 norm = original.normalized;

        RaycastHit2D[] hits = Physics2D.BoxCastAll(
            transform.position,
            size - Vector2.one * 2 * skinWidth,
            transform.eulerAngles.z,
            original.normalized,
            original.magnitude + skinWidth,
            passengerMask
            );

        DebugExtensions.DrawBoxCast2D(
            transform.position,
            (size - Vector2.one * 2 * skinWidth),
            transform.eulerAngles.z,
            original.normalized,
            original.magnitude + skinWidth,
            Color.cyan
            );

        foreach (RaycastHit2D hit in hits)
        {
            IPlatformMoveBlocker pass = hit.collider.GetComponent <IPlatformMoveBlocker>();
            if (pass != null)
            {
                Vector2 passMoveAmount = original - norm * (hit.distance - skinWidth);
                pass.CheckBlocking(ref passMoveAmount, tilesToMove);
                original = passMoveAmount + norm * (hit.distance - skinWidth);
            }
        }
    }
Beispiel #3
0
    /*public float randAmount = 0.03f;
     * private void Start () {
     *      myRandomOffset = new Vector3(Random.Range(-randAmount, randAmount), Random.Range(-randAmount, randAmount), 0);
     * }
     *
     *
     * public void DestroyItem () {
     *      Destroy(gameObject);
     * }*/

    public void DebugDraw()
    {
        if (mySlot != null)
        {
            DebugExtensions.DrawSquare(mySlot.position + myRandomOffset, new Vector3(0.05f, 0.05f, 0.05f), Color.blue, false);
        }
    }
Beispiel #4
0
            public void Parse(T parentAttr)
            {
                DeclaredAttribute = parentAttr;

                if (!IsValid)
                {
                    return;
                }
                var xml  = ExtractXmlContent();
                var xdoc = XDocument.Parse(xml);
                var xr   = xdoc.Root;

                try
                {
                    var dateAttribute = xr != null?xr.Attribute("Date") : null;

                    GenerateDate = dateAttribute != null?Convert.ToDateTime(xr.Attribute("Date").Value) : (DateTime?)null;

                    FoundTag = new T();
                    FoundTag.CopyPropertyFromTag(xr);
                }
                catch (Exception ex)
                {
                    DebugExtensions.DebugHere();
                }
            }
 protected internal override void OnEditorTick(float dt)
 {
     base.OnEditorTick(dt);
     if (!MBEditor.IsEntitySelected(this.GameEntity))
     {
         return;
     }
     DebugExtensions.RenderDebugCircleOnTerrain(this.Scene, this.GameEntity.GetGlobalFrame(), 4f, 2852192000U);
     DebugExtensions.RenderDebugCircleOnTerrain(this.Scene, this.GameEntity.GetGlobalFrame(), 6f, 2868838400U);
 }
Beispiel #6
0
        public void DebugView()
        {
            DebugExtensions.EnableDebugViews();
            using (var p = Pipeline.Create())
            {
                var name = Generators.Sequence(p, new[] { 1, 2, 3 }).DebugView();
                Assert.IsNotNull(name);
            }

            DebugExtensions.DisableDebugViews();
        }
 /// <summary>
 /// Returns a <see cref="System.String" /> that represents this instance.
 /// </summary>
 /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
 public override string ToString()
 {
     return(string.Format(
                "{0}: Type: {1}; Options: {2}; CapClient:{5}{3}{5}XML:{5}{4}{5}",
                Function,
                ObjectType,
                Options,
                Capabilities,
                DebugExtensions.Format(Xml),
                Environment.NewLine));
 }
 void DisplayTrajectory()
 {
     try
     {
         AffineTransform worldRootTransform = AffineTransform.Create(targetJoints[0].position, targetJoints[0].rotation);
         DebugExtensions.DebugDrawTrajectory(worldRootTransform, sampleTrajectory, assetSampleRate, trajectoryColor, trajectoryColor);
     }
     catch (MissingReferenceException)
     {
         PreviewInvalidated?.Invoke();
     }
 }
Beispiel #9
0
        /// <summary>Draws the button to toggle debug logging.</summary>
        /// <param name="guiCoordinates">The screen coordinates of the main GUI dialogue window.</param>
        private void DrawDebugButton(Rect guiCoordinates)
        {
            var style = (DebugExtensions.DebugIsOn) ? _elementStyles.HighlightedButton : _elementStyles.SelectedButton;

            if (GUI.Button(
                    new Rect(0, guiCoordinates.height - 10, 10, 10), "*", style))
            {
                $"Debugging messages are being turned OFF".Debug();
                DebugExtensions.SetDebug(!DebugExtensions.DebugIsOn);
                $"Debugging messages have been turned ON".Debug();
                var state = (DebugExtensions.DebugIsOn) ? "ON" : "OFF";
                ScreenMessages.PostScreenMessage(new ScreenMessage($"WalkAbout debugging is {state}", 4.0f, ScreenMessageStyle.UPPER_LEFT));
            }
        }
Beispiel #10
0
        public virtual IEnumerator MakeRoutine()
        {
            Terrain[] terrains = FindObjectsOfType <Terrain>();
            for (int i = 0; i < terrains.Length; i++)
            {
                if (terrains[i].canBeErased && Contains(terrains[i]))
                {
                    terrains[i].gameObject.SetActive(false);
                }
            }
            if (surroundWithTerrains)
            {
                Vector2 currentPoint;
                do
                {
                    currentPoint = (Vector2)rootAreaPathNode.trs.position + (Random.insideUnitCircle.normalized * (rootAreaPathNode.radius + distToNodeForFirstTerrain));
                    yield return(new WaitForEndOfFrame());
                } while (Contains(currentPoint));
                yield return(EditorCoroutineUtility.StartCoroutine(MakeTerrainRoutine(currentPoint), this));

                AreaPathNode[] uncheckedAreaPathNodes = new AreaPathNode[1] {
                    rootAreaPathNode
                };
                AreaPathNode[] deadEndAreaPathNodes = new AreaPathNode[0];
                while (uncheckedAreaPathNodes.Length > 0)
                {
                    if (uncheckedAreaPathNodes[0].gameObject.activeInHierarchy)
                    {
                        uncheckedAreaPathNodes = uncheckedAreaPathNodes.AddRange(uncheckedAreaPathNodes[0].children);
                        if (uncheckedAreaPathNodes[0].children.Length == 0)
                        {
                            deadEndAreaPathNodes = deadEndAreaPathNodes.Add(uncheckedAreaPathNodes[0]);
                        }
                    }
                    uncheckedAreaPathNodes = uncheckedAreaPathNodes.RemoveAt(0);
                }
                float normalizedTraversedDistance = 0;
                foreach (AreaPathNode deadEndAreaPathNode in deadEndAreaPathNodes)
                {
                    do
                    {
                        currentPoint = GetPointAlongCenterPath(deadEndAreaPathNode, normalizedTraversedDistance + normalizedTraverseRate);
                        DebugExtensions.DrawPoint(currentPoint, 10, Color.red, .1f);
                        normalizedTraversedDistance = GetNormalizedDistanceOfClosestPointAlongCenterPath(deadEndAreaPathNode, currentPoint);
                        yield return(new WaitForEndOfFrame());
                    } while (normalizedTraversedDistance < 1);
                }
            }
        }
Beispiel #11
0
        public void PauseSong(string name)
        {
            Sound song;

            if (!soundDict.TryGetValue(name, out song))
            {
                DebugExtensions.LogNotFound(this, name);
                return;
            }

            if (song.audioSource.isPlaying)
            {
                song.audioSource.Pause();
            }
        }
Beispiel #12
0
        public void Play(string name)
        {
            Sound sound;

            if (!soundDict.TryGetValue(name, out sound))
            {
                DebugExtensions.LogNotFound(this, name);
                return;
            }

            if (sound.dontStackSounds && sound.audioSource.isPlaying)
            {
                return;
            }

            sound.audioSource.Play();
        }
    /// <summary>
    /// The entry point of our application.
    /// </summary>
    /// <param name="args">Possibly specified command line arguments.</param>
    public static void Main(string[] args)
    {
        Player t = new Player();

        t.Name   = "Chuck Norris";
        t.Health = int.MaxValue;     // Becaus it's Chuck Norris ;-)
        // Add the object to the debug list.
        DebugExtensions.DebugList.Add(t);
        // Print all properties marked with the "DebugMePlease" attribute.
        DebugExtensions.Print();
        // Change something.
        t.Health = 0;

        // Print again and hopefully be happy.
        DebugExtensions.Print();
        Console.ReadLine();
    }
Beispiel #14
0
    void CheckIfUnderSomething()
    {
        if (playerCamera != null)
        {
            var currentPos = this.transform.position;

            var checkPos = currentPos.South();

            Rect r = new Rect(checkPos.x, checkPos.y, 1f, 1f);

            DebugExtensions.DrawRect(r, -8f);

            var result = InstanceManager.instances.Within(r).Where(p => p.Value.transform.position.z < currentPos.z);

            if (result.Count() > 0)
            {
                bool  isCovered   = false;
                float coverHeight = -100f;

                foreach (var res in result)
                {
                    Vector3 compare = new Vector3(currentPos.x, currentPos.y, res.Value.transform.position.z);
                    if (res.Value.spriteRenderer.bounds.Contains(compare))
                    {
                        isCovered = true;
                        if (compare.z > coverHeight)
                        {
                            coverHeight = compare.z;
                        }
                    }
                }

                if (isCovered)
                {
                    isCovered = false;
                    FloorRenderer.SetVisibleFloors(coverHeight + 1, true);
                    coverHeight = -100f;
                }
            }
            else
            {
                FloorRenderer.SetVisibleFloors(refreshHeight, true);
            }
        }
    }
Beispiel #15
0
    public void DebugDraw()
    {
        // Draw a yellow cube at the transform position
        if (coreDraw)
        {
            DebugExtensions.DrawSquare(position, new Vector3(0.08f, 0.08f, 0.08f), Color.black);

            /*foreach (BeltItemSlot connection in outsideConnections)
             *      DebugExtensions.DrawArrow(position, Vector3.Lerp(position, connection.position, 0.5f), Color.green);
             */
            foreach (BeltItemSlot connection in insideConnections)
            {
                DebugExtensions.DrawArrow(Vector3.Lerp(position, connection.position, 0.5f), position, Color.red);
            }
        }
        if (numberDraw)
        {
            DebugExtensions.DrawNumber(position, index);
        }
    }
Beispiel #16
0
    private List <Vector3> PointsAroundCircle(int points, float radius, Vector3 center)
    {
        List <Vector3> retVal = new List <Vector3>();

        if (!Application.isPlaying)
        {
            DebugExtensions.DebugPoint(center, Color.red, .1f, 1);
        }

        float slice = 2 * Mathf.PI / points;

        for (int i = 0; i < points; i++)
        {
            float angle = slice * i;
            float x     = (radius * Mathf.Cos(angle) + center.x);
            float z     = (radius * Mathf.Sin(angle) + center.z);
            retVal.Add(new Vector3(x, 0, z));
        }

        return(retVal);
    }
Beispiel #17
0
    private void DetectObjectCollision()
    {
        var collisions = Physics.OverlapSphere(transform.position, 1.5f, grabbiesLayerMask);

        DebugExtensions.DebugWireSphere(transform.position, Color.black, 1.5f, 2f);

        if (collisions.Length == 0)
        {
            return;
        }

        var mergeableObject = collisions[0].GetComponentInParent <MergeableObject>();

        if (currentMergeableObject == null)
        {
            currentMergeableObject = mergeableObject;
            mergeableObject.transform.SetParent(grabbyPoint);
            mergeableObject.transform.localPosition = Vector3.zero;
            mergeableObject.transform.localRotation = Quaternion.identity;
            mergeableObject.transform.localScale    = Vector3.one;
            collisions[0].enabled = false;
            mergeableObject.GetComponent <FakeGravity>().enabled = false;

            AudioManager.Instance.PlayCombineSuccess();
            //Close hands
        }
        else
        {
            if (currentMergeableObject.UpgradeObjectByAddition(mergeableObject.VectorMaterial))
            {
                AudioManager.Instance.PlayCombineSuccess();
                Destroy(mergeableObject.gameObject);
            }
            else
            {
                AudioManager.Instance.PlayCombineFail();
            }
        }
    }
    void ExplodeAround(Vector2Int center, int radius)
    {
        for (int x = -radius; x < radius; x++)
        {
            for (int y = -radius; y < radius; y++)
            {
                Vector2Int currentPos = new Vector2Int(x, y) + center;
                DebugExtensions.DrawCircle(currentPos * new Vector2(1, _yDistanceBetweenCircles), .4f, Color.blue, .1f);
                if (!IsInsideBoard(currentPos))
                {
                    continue;
                }
                BubbleBehaviour bubble = GetBubbleAtPosition(currentPos);

                if (bubble != null)
                {
                    score.AddToScore(bubble._exponent);
                    DestroyBubble(currentPos, true);
                }
            }
        }
    }
        /// <summary>
        /// Raises the given <see cref="TaggedException"/>
        /// </summary>
        /// <typeparam name="T">The type related to the exception.</typeparam>
        /// <param name="exception">The <see cref="System.Exception"/> which occured.</param>
        /// <param name="breakForResume">Indicates if the function should attach the debugger.</param>
        public static void RaiseAndAttachIfUnhandled <T>(this TaggedException <T> exception, bool breakForResume = true)
        {
            //If not attaching then fall back to TryRaise which hides the exception and return.
            if (false.Equals(breakForResume))
            {
                exception.TryRaise();

                return;
            }

            //Raise the exception
            try { exception.Raise(); }
            catch //Handle it
            {
                //If the debugger is not attached and it cannot be then return
                if (false.Equals(DebugExtensions.Attach()))
                {
                    return;
                }

                //Break if still attached
                DebugExtensions.BreakIfAttached();
            }
        }
Beispiel #20
0
 public void DebugDraw()
 {
     // Draw a yellow cube at the transform position
     DebugExtensions.DrawSquare(transform.position, new Vector3(0.05f, 0.05f, 0.05f), Color.blue);
 }
Beispiel #21
0
    public Mesh[] DoSlice()
    {
        DebugExtensions.DrawPlane(cuttingPlane.distance * cuttingPlane.normal, cuttingPlane.normal, 10, Color.blue, Color.cyan);

        for (int i = 0; i < meshTriangles.Count; i += 3)
        {
            var t1 = meshTriangles[i];
            var t2 = meshTriangles[i + 1];
            var t3 = meshTriangles[i + 2];

            var v1 = meshVertices[t1];
            var v2 = meshVertices[t2];
            var v3 = meshVertices[t3];

            var uv1 = meshUv[t1];
            var uv2 = meshUv[t2];
            var uv3 = meshUv[t3];

            bool v1Side = cuttingPlane.GetDistanceToPoint(v1) > 0;
            bool v2Side = cuttingPlane.GetDistanceToPoint(v2) > 0;
            bool v3Side = cuttingPlane.GetDistanceToPoint(v3) > 0;

            // if all vertices are on the same side of the cutting plane, add them to the corresponding data
            if (v1Side == v2Side && v1Side == v3Side)
            {
                AddTriangleToSide(v1Side, v1, v2, v3, uv1, uv2, uv3);
            }
            else
            {
                Vector3 intersection1;
                Vector3 intersection2;

                // if v1 and v2 are on the same side
                if (v1Side == v2Side)
                {
                    GetIntersectionVertexOnPlane(v2, v3, uv2, uv3, cuttingPlane, out intersection1, out Vector2 intersection1Uv);
                    GetIntersectionVertexOnPlane(v3, v1, uv3, uv1, cuttingPlane, out intersection2, out Vector2 intersection2Uv);

                    // add triangles to first side
                    AddTriangleToSide(v1Side, v1, v2, intersection2, uv1, uv2, intersection2Uv);
                    AddTriangleToSide(v1Side, v2, intersection1, intersection2, uv2, intersection1Uv, intersection2Uv);

                    // add triangles to second side
                    AddTriangleToSide(v3Side, intersection2, intersection1, v3, intersection2Uv, intersection1Uv, uv3);
                }
                // if v1 and v3 are on the same side
                else if (v1Side == v3Side)
                {
                    GetIntersectionVertexOnPlane(v1, v2, uv1, uv2, cuttingPlane, out intersection1, out Vector2 intersection1Uv);
                    GetIntersectionVertexOnPlane(v2, v3, uv2, uv3, cuttingPlane, out intersection2, out Vector2 intersection2Uv);

                    // add triangles to first side
                    AddTriangleToSide(v1Side, v1, intersection1, v3, uv1, intersection1Uv, uv3);
                    AddTriangleToSide(v1Side, v3, intersection1, intersection2, uv3, intersection1Uv, intersection2Uv);

                    // add triangles to second side
                    AddTriangleToSide(v2Side, intersection1, v2, intersection2, intersection1Uv, uv2, intersection2Uv);
                }
                // if v1 is the only one on its side
                else //if (v2Side == v3Side)
                {
                    GetIntersectionVertexOnPlane(v1, v2, uv1, uv2, cuttingPlane, out intersection1, out Vector2 intersection1Uv);
                    GetIntersectionVertexOnPlane(v1, v3, uv1, uv3, cuttingPlane, out intersection2, out Vector2 intersection2Uv);

                    // add triangles to first side
                    AddTriangleToSide(v1Side, v1, intersection1, intersection2, uv1, intersection1Uv, intersection2Uv);

                    // add triangles to second side
                    AddTriangleToSide(v2Side, intersection1, v2, v3, intersection1Uv, uv2, uv3);
                    AddTriangleToSide(v2Side, intersection1, v3, intersection2, intersection1Uv, uv3, intersection2Uv);
                }

                IntersectionPoints.AddMultiple(intersection1, intersection2);
            }
        }

        // add faces along the plane to make solid meshes
        FillCutFaces();

        Mesh m1 = new Mesh();

        m1.vertices  = vertices1.ToArray();
        m1.uv        = uvs1.ToArray();
        m1.triangles = triangles1.ToArray();

        Mesh m2 = new Mesh();

        m2.vertices  = vertices2.ToArray();
        m2.uv        = uvs2.ToArray();
        m2.triangles = triangles2.ToArray();
        return(new Mesh[] { m1, m2 });
    }
Beispiel #22
0
    public override void OnInspectorGUI()
    {
        targetObj.Update();

        gridSystem.transform.localEulerAngles = Vector3.zero;
        gridSystem.transform.localScale       = Vector3.one;

        EditorGUILayout.PropertyField(size);
        EditorGUILayout.PropertyField(axis1);
        EditorGUILayout.PropertyField(axis2);


        EditorGUILayout.Space();


        EditorGUILayout.BeginHorizontal();

        if (!gridSystem.IsAlongAxis(GridAxes.x))
        {
            testValue.With(gridSystem.transform.position.x);
        }
        if (!gridSystem.IsAlongAxis(GridAxes.y))
        {
            testValue.With(null, gridSystem.transform.position.y);
        }
        if (!gridSystem.IsAlongAxis(GridAxes.z))
        {
            testValue.With(null, null, gridSystem.transform.position.z);
        }

        testValue = EditorGUILayout.Vector3Field("Test Point", testValue);

        GUIStyle horizontalButtonStyles = new GUIStyle(EditorStyles.miniButton);

        horizontalButtonStyles.margin    = new RectOffset(6, 6, 18, 0);
        horizontalButtonStyles.fontStyle = FontStyle.Bold;

        if (GUILayout.Button("Test Point On Grid", horizontalButtonStyles))
        {
            Vector3 gridPoint = gridSystem.GetNearestPointOnGrid(testValue);
            Debug.Log("Test Value: " + testValue);
            Debug.Log("Grid Value: " + gridPoint);
            DebugExtensions.DrawCube(gridPoint, size.floatValue, gizmoColor.colorValue, 5f, true);
        }

        EditorGUILayout.EndHorizontal();


        EditorGUILayout.Space();


        GUIStyle gizmoStyles = new GUIStyle(EditorStyles.foldout);

        gizmoStyles.fontStyle = FontStyle.Bold;

        showGizmoSettings = EditorGUILayout.Foldout(showGizmoSettings, "Gizmo Settings", true, gizmoStyles);

        if (showGizmoSettings)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(gizmoColor);
            EditorGUILayout.PropertyField(alpha);
            EditorGUILayout.PropertyField(gizmoSize);
            EditorGUILayout.PropertyField(gizmoLength);
            EditorGUI.indentLevel--;
        }

        targetObj.ApplyModifiedProperties();
    }
Beispiel #23
0
        /// <summary>
        /// Finds all types in all loaded assemblies which are a subclass of RtcpPacket and adds those types to either the InstanceMap or the AbstractionBag
        /// </summary>
        internal protected static void MapDerivedImplementations(AppDomain domain = null, bool breakOnError = false)
        {
            System.Type[] Types;

            //Get all loaded assemblies in the current application domain
            foreach (System.Reflection.Assembly assembly in (domain ?? AppDomain.CurrentDomain).GetAssemblies())
            {
                try { Types = assembly.GetTypes(); }
                catch { if (breakOnError)
                        {
                            DebugExtensions.BreakIfAttached();
                        }
                        continue; }

                //Iterate each derived type which is a SubClassOf RtcpPacket.
                foreach (System.Type derivedType in Types.Where(t => t.IsSubclassOf(RtcpPacketType)))
                {
                    //If the derivedType is an abstraction then add to the AbstractionBag and continue
                    if (derivedType.IsAbstract)
                    {
                        Abstractions.Add(derivedType);

                        continue;
                    }

                    //Get the TypeInfo
                    System.Reflection.TypeInfo typeInfo = System.Reflection.IntrospectionExtensions.GetTypeInfo(derivedType);

                    //Enumerate the fields of the typeInfo
                    foreach (System.Reflection.FieldInfo field in typeInfo.DeclaredFields)
                    {
                        //Obtain the field mapped to the derviedType which corresponds to the PayloadTypeField defined by the RtcpPacket implementation.
                        switch (field.Name)
                        {
                        default: continue;

                        case PayloadTypeField:
                        {
                            //Unbox the payloadType from an integer to a byte via reflection
                            byte payloadType = (byte)((int)field.GetValue(derivedType));

                            //if the mapping was not successful and the debbuger is attached break.
                            if (false == TryMapImplementation(payloadType, derivedType) && System.Diagnostics.Debugger.IsAttached)
                            {
                                //Another type was already mapped to the given payloadTypeField
                                System.Diagnostics.Debugger.Break();
                            }

                            //Finished
                            goto Continue;
                        }
                        }
                    }

                    Continue:
                    continue;
                }
            }

            Types = null;
        }