Ejemplo n.º 1
0
        /// <summary>
        /// Draw standard arrow.
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="dir"></param>
        /// <param name="color"></param>
        /// <param name="length"></param>
        /// <param name="scale"></param>
        protected void DrawArrow(DebugRender dr, Ray pickRay, Vector3 origin, Vector3 dir, Color color)
        {
            var p0 = origin;
            var p1 = p0 + dir * editor.camera.PixelToWorldSize(origin, 90);
            var p2 = p1 + dir * editor.camera.PixelToWorldSize(origin, 20);

            dr.DrawLine(p0, p1, color, color, 2, 2);
            dr.DrawLine(p1, p2, color, color, 9, 1);
        }
Ejemplo n.º 2
0
    public void MoveCharacterController(CharacterControllerProxy char_controller)
    {
        AnimatorStateInfo currentAnimatorStateInfo = this.m_Animator.GetCurrentAnimatorStateInfo(0);

        foreach (AnimatorClipInfo animatorClipInfo in this.m_Animator.GetCurrentAnimatorClipInfo(0))
        {
            if ((double)animatorClipInfo.weight == 1.0)
            {
                float time = currentAnimatorStateInfo.length * (currentAnimatorStateInfo.normalizedTime % 1f);
                float num  = currentAnimatorStateInfo.length * (currentAnimatorStateInfo.normalizedTime % 1f) - Time.deltaTime;
                num = Mathf.Clamp(num, 0f, currentAnimatorStateInfo.length);
                animatorClipInfo.clip.SampleAnimation(this.m_Animator.gameObject, num);
                Vector3    position   = this.m_OffsetHelper.position;
                Quaternion quaternion = Quaternion.Inverse(this.m_OffsetHelper.rotation);
                animatorClipInfo.clip.SampleAnimation(this.m_Animator.gameObject, time);
                Vector3    position2 = this.m_OffsetHelper.position;
                Quaternion rotation  = this.m_OffsetHelper.rotation;
                quaternion *= rotation;
                Vector3 vector = position2 - position;
                char_controller.Move(vector, true);
                char_controller.transform.rotation *= quaternion;
                DebugRender.DrawLine(position2, position2 + vector, Color.blue, 0f);
            }
        }
    }
Ejemplo n.º 3
0
        public override void DrawNode(GameWorld world, DebugRender dr, Color color, bool selected)
        {
            dr.DrawBasis(WorldMatrix, 1);
            Factory.Draw(dr, WorldMatrix, color);

            if (selected)
            {
                if (Entity != null)
                {
                    var targets = world.GetTargets(Factory.Target);

                    if (targets.Any())
                    {
                        dr.DrawBox(new BoundingBox(0.5f, 0.5f, 0.5f), WorldMatrix, Color.Yellow);
                    }

                    foreach (var target in targets)
                    {
                        var dir  = target.Position - Entity.Position;
                        var len  = dir.Length();
                        var dirn = dir.Normalized();

                        var p0 = Entity.Position;
                        var p1 = target.Position;

                        dr.DrawLine(p0, p1, Color.Yellow, Color.Yellow, 1, 1);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="pickRay"></param>
        /// <param name="origin"></param>
        /// <param name="axisA"></param>
        /// <param name="axisB"></param>
        /// <param name="color"></param>
        protected void DrawRing(DebugRender dr, Ray pickRay, Vector3 origin, Vector3 axis, Color color)
        {
            axis = Vector3.Normalize(axis);
            var axisA = Vector3.Cross(axis, Vector3.Up);

            if (axisA.LengthSquared() < 0.001f)
            {
                axisA = Vector3.Cross(axis, Vector3.Right);
            }

            var axisB = Vector3.Cross(axisA, axis);

            int N = 64;

            Vector3[] points = new Vector3[N + 1];

            var radius = editor.camera.PixelToWorldSize(origin, 90);

            for (int i = 0; i <= N; i++)
            {
                var p = origin;
                p        += axisA * radius * (float)Math.Cos(Math.PI * 2 * i / N);
                p        += axisB * radius * (float)Math.Sin(Math.PI * 2 * i / N);
                points[i] = p;
            }

            for (int i = 0; i < N; i++)
            {
                dr.DrawLine(points[i], points[i + 1], color, color, 2, 2);
            }
        }
Ejemplo n.º 5
0
        public override void DrawNode(GameWorld world, DebugRender dr, Color color, bool selected)
        {
            var transform = WorldMatrix;

            var c = transform.TranslationVector
                    + transform.Left * Width * 0.40f
                    + transform.Up * Height * 0.40f;

            float len = Math.Min(Width, Height) / 6;

            var x = transform.Right * len;
            var y = transform.Down * len;

            var p0 = Vector3.TransformCoordinate(new Vector3(Width / 2, Height / 2, 0), transform);
            var p1 = Vector3.TransformCoordinate(new Vector3(-Width / 2, Height / 2, 0), transform);
            var p2 = Vector3.TransformCoordinate(new Vector3(-Width / 2, -Height / 2, 0), transform);
            var p3 = Vector3.TransformCoordinate(new Vector3(Width / 2, -Height / 2, 0), transform);

            var p4 = Vector3.TransformCoordinate(new Vector3(0, 0, Depth), transform);
            var p5 = Vector3.TransformCoordinate(new Vector3(0, 0, -Depth), transform);

            dr.DrawLine(p0, p1, color, color, 1, 1);
            dr.DrawLine(p1, p2, color, color, 1, 1);
            dr.DrawLine(p2, p3, color, color, 1, 1);
            dr.DrawLine(p3, p0, color, color, 1, 1);

            dr.DrawLine(c, c + x, Color.Red, Color.Red, 2, 2);
            dr.DrawLine(c, c + y, Color.Lime, Color.Lime, 2, 2);

            dr.DrawLine(p4, p5, color, color, 2, 2);
        }
Ejemplo n.º 6
0
        public override void Draw(DebugRender dr, Matrix transform, Color color)
        {
            var p0 = transform.TranslationVector;
            var p1 = transform.TranslationVector + Vector3.Up * 2;
            var pf = transform.TranslationVector + transform.Forward;


            dr.DrawRing(p0, 0.50f, color, 16);
            dr.DrawRing(p1, 0.50f, color, 16);
            dr.DrawLine(p0, pf, color, color, 5, 1);
        }
Ejemplo n.º 7
0
        public void DrawNavigationMeshDebug(DebugRender dr)
        {
            if (SourceNavigationMesh != null)
            {
                var srcNavMesh = SourceNavigationMesh;
                foreach (var p in srcNavMesh.Vertices)
                {
                    //dr.DrawPoint( p, 0.1f, Color.Yellow );
                }
            }


            if (navIndices == null)
            {
                return;
            }


            foreach (var p in navVertices)
            {
                dr.DrawPoint(p, 0.1f, Color.Yellow);
            }

            var color = Color.Yellow;

            for (int i = 0; i < navIndices.Length / 3; i++)
            {
                var p0 = navVertices[navIndices[i * 3 + 0]];
                var p1 = navVertices[navIndices[i * 3 + 1]];
                var p2 = navVertices[navIndices[i * 3 + 2]];

                dr.DrawLine(p0, p1, color, color, 2, 2);
                dr.DrawLine(p1, p2, color, color, 2, 2);
                dr.DrawLine(p2, p0, color, color, 2, 2);
            }
        }
 private void FixedUpdate()
 {
     if (this.m_RigidBody == null)
     {
         base.GetComponents <Rigidbody>(this.m_TempList);
         if (this.m_TempList.Count > 0)
         {
             this.m_RigidBody = this.m_TempList[0];
         }
     }
     if (this.m_RigidBody != null && this.m_AddAngularVelOnStart && Time.time - this.m_StartTime < this.m_AddAngularVelocityOnStartDuration)
     {
         this.m_RigidBody.isKinematic = false;
         this.m_RigidBody.AddTorque(this.m_AngularVelocityOnStart * 1f, ForceMode.Acceleration);
         DebugRender.DrawLine(base.transform.position, base.transform.position + this.m_AngularVelocityOnStart, default(Color), 0f);
     }
 }
Ejemplo n.º 9
0
 private bool CheckCornerInAir(Vector3 corner)
 {
     corner.y += this.m_RayCheckUpOffset;
     RaycastHit[] array = Physics.RaycastAll(corner, Vector3.down, this.m_RayCheckLength);
     for (int i = 0; i < array.Length; i++)
     {
         if (!(array[i].collider == this.m_BoxCollider))
         {
             if (array[i].collider.GetType() == typeof(TerrainCollider))
             {
                 DebugRender.DrawLine(corner, corner + Vector3.down * this.m_RayCheckLength, Color.green, 0f);
                 return(false);
             }
         }
     }
     DebugRender.DrawLine(corner, corner + Vector3.down * this.m_RayCheckLength, Color.red, 0f);
     return(true);
 }
Ejemplo n.º 10
0
    public void DrawDebug()
    {
        bool flag  = false;
        bool flag2 = true;
        bool flag3 = true;

        for (int i = 0; i < this.m_NumCellsX; i++)
        {
            for (int j = 0; j < this.m_NumCellsY; j++)
            {
                QuadTreeStaticObjectsCell quadTreeStaticObjectsCell = this.m_Cells[i, j];
                if (flag || (flag3 && quadTreeStaticObjectsCell.m_Objects.Count > 0))
                {
                    Vector3 zero = Vector3.zero;
                    zero.x = quadTreeStaticObjectsCell.m_Pos.x;
                    zero.z = quadTreeStaticObjectsCell.m_Pos.y;
                    Vector3 end = zero;
                    end.x += quadTreeStaticObjectsCell.m_Size.x;
                    DebugRender.DrawLine(zero, end, Color.white, 0f);
                    end    = zero;
                    end.z += quadTreeStaticObjectsCell.m_Size.y;
                    DebugRender.DrawLine(zero, end, Color.white, 0f);
                }
                if (flag2)
                {
                    for (int k = 0; k < quadTreeStaticObjectsCell.m_Objects.Count; k++)
                    {
                        GameObject gameObject = quadTreeStaticObjectsCell.m_Objects[k].m_GameObject;
                        if (gameObject)
                        {
                            DebugRender.DrawPoint(gameObject.transform.position, gameObject.activeSelf ? Color.red : Color.green, 0.3f, 0f);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 11
0
    public void DrawDebug()
    {
        bool flag  = false;
        bool flag2 = true;
        bool flag3 = true;

        for (int i = 0; i < this.m_NumCellsX; i++)
        {
            for (int j = 0; j < this.m_NumCellsY; j++)
            {
                QuadTreeCellBalanceSystem quadTreeCellBalanceSystem = this.m_Cells[i, j];
                if (flag || (flag3 && quadTreeCellBalanceSystem.m_Objects.Count > 0))
                {
                    Vector3 zero = Vector3.zero;
                    zero.x = quadTreeCellBalanceSystem.m_Pos.x;
                    zero.z = quadTreeCellBalanceSystem.m_Pos.y;
                    Vector3 end = zero;
                    end.x += quadTreeCellBalanceSystem.m_Size.x;
                    DebugRender.DrawLine(zero, end, Color.white, 0f);
                    end    = zero;
                    end.z += quadTreeCellBalanceSystem.m_Size.y;
                    DebugRender.DrawLine(zero, end, Color.white, 0f);
                }
                if (flag2)
                {
                    for (int k = 0; k < quadTreeCellBalanceSystem.m_Objects.Count; k++)
                    {
                        BalanceSystemObject balanceSystemObject = quadTreeCellBalanceSystem.m_Objects[k];
                        if (balanceSystemObject.m_GameObject != null)
                        {
                            DebugRender.DrawPoint(balanceSystemObject.m_GameObject.transform.position, (!balanceSystemObject.m_GameObject.activeSelf) ? Color.green : Color.red, 0.3f, 0f);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 12
0
 private void UpdateDebug()
 {
     if (Input.GetKeyDown(KeyCode.Alpha0) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo = new DamageInfo();
         damageInfo.m_Damage = 10f;
         damageInfo.m_HitDir = base.transform.up * -1f;
         Player.Get().TakeDamage(damageInfo);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo.m_HitDir, Color.cyan, 50f);
     }
     if (Input.GetKeyDown(KeyCode.Alpha1) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo2 = new DamageInfo();
         damageInfo2.m_Damage  = 10f;
         damageInfo2.m_HitDir  = base.transform.up * -1f;
         damageInfo2.m_HitDir += base.transform.right * 1f;
         damageInfo2.m_HitDir.Normalize();
         Player.Get().TakeDamage(damageInfo2);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo2.m_HitDir, Color.cyan, 50f);
     }
     if (Input.GetKeyDown(KeyCode.Alpha2) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo3 = new DamageInfo();
         damageInfo3.m_Damage = 10f;
         damageInfo3.m_HitDir = base.transform.right * 1f;
         damageInfo3.m_HitDir.Normalize();
         Player.Get().TakeDamage(damageInfo3);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo3.m_HitDir, Color.cyan, 50f);
     }
     if (Input.GetKeyDown(KeyCode.Alpha3) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo4 = new DamageInfo();
         damageInfo4.m_Damage  = 10f;
         damageInfo4.m_HitDir  = base.transform.right * 1f;
         damageInfo4.m_HitDir += base.transform.up * 1.3f;
         damageInfo4.m_HitDir.Normalize();
         Player.Get().TakeDamage(damageInfo4);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo4.m_HitDir, Color.cyan, 50f);
     }
     if (Input.GetKeyDown(KeyCode.Alpha4) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo5 = new DamageInfo();
         damageInfo5.m_Damage = 10f;
         damageInfo5.m_HitDir = base.transform.up;
         damageInfo5.m_HitDir.Normalize();
         Player.Get().TakeDamage(damageInfo5);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo5.m_HitDir, Color.cyan, 50f);
     }
     if (Input.GetKeyDown(KeyCode.Alpha5) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo6 = new DamageInfo();
         damageInfo6.m_Damage  = 10f;
         damageInfo6.m_HitDir  = base.transform.up * 1.2f;
         damageInfo6.m_HitDir += base.transform.right * -1f;
         damageInfo6.m_HitDir.Normalize();
         Player.Get().TakeDamage(damageInfo6);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo6.m_HitDir, Color.cyan, 50f);
     }
     if (Input.GetKeyDown(KeyCode.Alpha6) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo7 = new DamageInfo();
         damageInfo7.m_Damage = 10f;
         damageInfo7.m_HitDir = base.transform.right * -1f;
         damageInfo7.m_HitDir.Normalize();
         Player.Get().TakeDamage(damageInfo7);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo7.m_HitDir, Color.cyan, 50f);
     }
     if (Input.GetKeyDown(KeyCode.Alpha7) && Input.GetKey(KeyCode.LeftAlt))
     {
         DamageInfo damageInfo8 = new DamageInfo();
         damageInfo8.m_Damage  = 10f;
         damageInfo8.m_HitDir  = base.transform.up * -1f;
         damageInfo8.m_HitDir += base.transform.right * -1f;
         damageInfo8.m_HitDir.Normalize();
         Player.Get().TakeDamage(damageInfo8);
         DebugRender.DrawLine(base.transform.position, base.transform.position + damageInfo8.m_HitDir, Color.cyan, 50f);
     }
 }
Ejemplo n.º 13
0
        public override void DrawNode(GameWorld world, DebugRender dr, Color color, bool selected)
        {
            var transform = WorldMatrix;

            var lightColor = LightPresetColor.GetColor(LightPreset, Intensity);;

            var max = Math.Max(Math.Max(lightColor.Red, lightColor.Green), Math.Max(lightColor.Blue, 1));

            var dispColor = new Color((byte)(lightColor.Red / max * 255), (byte)(lightColor.Green / max * 255), (byte)(lightColor.Blue / max * 255), (byte)255);

            dr.DrawPoint(transform.TranslationVector, 1, color, 2);

            if (selected)
            {
                var frustum = new BoundingFrustum(SpotView * SpotProjection);

                var points = frustum.GetCorners();

                dr.DrawLine(points[0], points[1], color);
                dr.DrawLine(points[1], points[2], color);
                dr.DrawLine(points[2], points[3], color);
                dr.DrawLine(points[3], points[0], color);

                dr.DrawLine(points[4], points[5], color);
                dr.DrawLine(points[5], points[6], color);
                dr.DrawLine(points[6], points[7], color);
                dr.DrawLine(points[7], points[4], color);

                dr.DrawLine(points[0], points[4], color);
                dr.DrawLine(points[1], points[5], color);
                dr.DrawLine(points[2], points[6], color);
                dr.DrawLine(points[3], points[7], color);
            }
            else
            {
            }
        }