Esempio n. 1
0
        private void DrawObj(Pen pen, TestSpaceObject obj)
        {
            obj.GetCollideShape().Transform(obj.GetPosition(), obj.CosDir, obj.SinDir);
            Circle c = obj.GetCollideShape() as Circle;

            if (c != null)
            {
                DrawCircel(pen, c);
                DrawFace(pen, c, obj.GetFaceDirection());
                DrawGun(pen, obj, gun_start_pos_, gun_end_pos_);
            }
        }
Esempio n. 2
0
        private double GetRotateDegree(TestSpaceObject obj, Vector3 gun_word_end, float mouse_x, float mouse_y)
        {
            Vector3 center            = obj.GetPosition();
            Vector3 mouse_center_vect = new Vector3(mouse_x - center.X, 0, mouse_y - center.Z);

            Vector3 gun_word_start       = GetGunStartPos(center, gun_word_end, obj.GetFaceDirection());
            float   rotate_circle_radius = DashFire.Geometry.GetMod(new Vector3(mouse_x - center.X, 0, mouse_y - center.Z));
            Vector3 hit_point;

            if (!DashFire.Geometry.GetRayWithCircleFirstHitPoint(gun_word_start,
                                                                 DashFire.Geometry.GetVectorFromDir(obj.GetFaceDirection()),
                                                                 center, rotate_circle_radius,
                                                                 out hit_point))
            {
                return(obj.GetFaceDirection());
            }
            Vector3 hit_vect      = new Vector3(hit_point.X - center.X, 0, hit_point.Z - center.Z);
            float   rotate_degree = DashFire.Geometry.GetVectorAngle(mouse_center_vect, hit_vect);

            double judge_gun_dir = Math.Atan2(mouse_x - gun_word_end.X, mouse_y - gun_word_end.Z);
            double degree        = (judge_gun_dir - obj.GetFaceDirection()) % (2 * Math.PI);

            if (Math.Abs(degree) > Math.PI)
            {
                if (degree > 0)
                {
                    return(obj.GetFaceDirection() - rotate_degree);
                }
                else
                {
                    return(obj.GetFaceDirection() + rotate_degree);
                }
            }
            else
            {
                if (degree > 0)
                {
                    return(obj.GetFaceDirection() + rotate_degree);
                }
                else
                {
                    return(obj.GetFaceDirection() - rotate_degree);
                }
            }
        }