コード例 #1
0
        private static void CreateTouchElement(TrainManager.ElementsGroup Group, Vector3 Position, Vector3 Size, int ScreenIndex, int SoundIndex, Translations.Command Command, int CommandOption)
        {
            Vertex t0 = new Vertex(Size.X, Size.Y, -Size.Z);
            Vertex t1 = new Vertex(Size.X, -Size.Y, -Size.Z);
            Vertex t2 = new Vertex(-Size.X, -Size.Y, -Size.Z);
            Vertex t3 = new Vertex(-Size.X, Size.Y, -Size.Z);
            Vertex t4 = new Vertex(Size.X, Size.Y, Size.Z);
            Vertex t5 = new Vertex(Size.X, -Size.Y, Size.Z);
            Vertex t6 = new Vertex(-Size.X, -Size.Y, Size.Z);
            Vertex t7 = new Vertex(-Size.X, Size.Y, Size.Z);

            ObjectManager.StaticObject Object = new ObjectManager.StaticObject();
            Object.Mesh.Vertices                      = new VertexTemplate[] { t0, t1, t2, t3, t4, t5, t6, t7 };
            Object.Mesh.Faces                         = new MeshFace[] { new MeshFace(new int[] { 0, 1, 2, 3 }), new MeshFace(new int[] { 0, 4, 5, 1 }), new MeshFace(new int[] { 0, 3, 7, 4 }), new MeshFace(new int[] { 6, 5, 4, 7 }), new MeshFace(new int[] { 6, 7, 3, 2 }), new MeshFace(new int[] { 6, 2, 1, 5 }) };
            Object.Mesh.Materials                     = new MeshMaterial[1];
            Object.Mesh.Materials[0].Flags            = 0;
            Object.Mesh.Materials[0].Color            = Color32.White;
            Object.Mesh.Materials[0].TransparentColor = Color24.Blue;
            Object.Mesh.Materials[0].DaytimeTexture   = null;
            Object.Mesh.Materials[0].NighttimeTexture = null;
            Object.Dynamic = true;
            if (Group.TouchElements == null)
            {
                Group.TouchElements = new TrainManager.TouchElement[0];
            }
            int n = Group.TouchElements.Length;

            Array.Resize(ref Group.TouchElements, n + 1);
            Group.TouchElements[n] = new TrainManager.TouchElement
            {
                Element         = new ObjectManager.AnimatedObject(),
                JumpScreenIndex = ScreenIndex,
                SoundIndex      = SoundIndex,
                Command         = Command,
                CommandOption   = CommandOption
            };
            Group.TouchElements[n].Element.States             = new ObjectManager.AnimatedObjectState[1];
            Group.TouchElements[n].Element.States[0].Position = Position;
            Group.TouchElements[n].Element.States[0].Object   = Object;
            Group.TouchElements[n].Element.CurrentState       = 0;
            Group.TouchElements[n].Element.ObjectIndex        = ObjectManager.CreateDynamicObject();
            ObjectManager.Objects[Group.TouchElements[n].Element.ObjectIndex] = Object.Clone();
            int m = Interface.CurrentControls.Length;

            Array.Resize(ref Interface.CurrentControls, m + 1);
            Interface.CurrentControls[m].Command = Command;
            Interface.CurrentControls[m].Method  = Interface.ControlMethod.Touch;
            Interface.CurrentControls[m].Option  = CommandOption;
        }
コード例 #2
0
 /// <summary>Creates a mirrored copy of the prototype object</summary>
 /// <param name="Prototype">The prototype</param>
 /// <returns>The mirrored copy</returns>
 private static ObjectManager.StaticObject GetMirroredStaticObject(ObjectManager.StaticObject Prototype)
 {
     ObjectManager.StaticObject Result = Prototype.Clone();
     for (int i = 0; i < Result.Mesh.Vertices.Length; i++)
     {
         Result.Mesh.Vertices[i].Coordinates.X = -Result.Mesh.Vertices[i].Coordinates.X;
     }
     for (int i = 0; i < Result.Mesh.Faces.Length; i++)
     {
         for (int k = 0; k < Result.Mesh.Faces[i].Vertices.Length; k++)
         {
             Result.Mesh.Faces[i].Vertices[k].Normal.X = -Result.Mesh.Faces[i].Vertices[k].Normal.X;
         }
         Result.Mesh.Faces[i].Flip();
     }
     return(Result);
 }
コード例 #3
0
        /// <summary>Creates a transformed copy of the provided prototype object (e.g. Platform top, roof etc.)</summary>
        /// <param name="Prototype">The prototype</param>
        /// /// <param name="NearDistance">The object's width at the start of the block</param>
        /// /// <param name="FarDistance">The object's width at the end of the block</param>
        /// <returns>The transformed copy</returns>
        private static ObjectManager.StaticObject GetTransformedStaticObject(ObjectManager.StaticObject Prototype, double NearDistance, double FarDistance)
        {
            ObjectManager.StaticObject Result = Prototype.Clone();
            int    n = 0;
            double x2 = 0.0, x3 = 0.0, x6 = 0.0, x7 = 0.0;

            for (int i = 0; i < Result.Mesh.Vertices.Length; i++)
            {
                if (n == 2)
                {
                    x2 = Result.Mesh.Vertices[i].Coordinates.X;
                }
                else if (n == 3)
                {
                    x3 = Result.Mesh.Vertices[i].Coordinates.X;
                }
                else if (n == 6)
                {
                    x6 = Result.Mesh.Vertices[i].Coordinates.X;
                }
                else if (n == 7)
                {
                    x7 = Result.Mesh.Vertices[i].Coordinates.X;
                }
                n++;
                if (n == 8)
                {
                    break;
                }
            }
            if (n >= 4)
            {
                int m = 0;
                for (int i = 0; i < Result.Mesh.Vertices.Length; i++)
                {
                    if (m == 0)
                    {
                        Result.Mesh.Vertices[i].Coordinates.X = NearDistance - x3;
                    }
                    else if (m == 1)
                    {
                        Result.Mesh.Vertices[i].Coordinates.X = FarDistance - x2;
                        if (n < 8)
                        {
                            m = 8;
                            break;
                        }
                    }
                    else if (m == 4)
                    {
                        Result.Mesh.Vertices[i].Coordinates.X = NearDistance - x7;
                    }
                    else if (m == 5)
                    {
                        Result.Mesh.Vertices[i].Coordinates.X = NearDistance - x6;
                        m = 8;
                        break;
                    }
                    m++;
                    if (m == 8)
                    {
                        break;
                    }
                }
            }
            return(Result);
        }