//--------------------------------------------------------------- /// <summary> /// Initialization /// </summary> public void Intitialize(TGraphicEngine GraphicEngine) { // 1. Let's initialize the engine. Render, camera and data entry GameBase = new TGameBase(GraphicEngine); // 2. Initializing content Content = new TContent(GameBase); }
/// <summary> /// Read the response as a JSON string & deserialize /// </summary> public TContent GetBodyAsJson <TContent>() where TContent : class { TContent result = null; // if we got a valid memory stream if ((this.MemStream != null) // not empty && (this.MemStream.Length > 0)) { try { // reset stream position this.MemStream.Position = 0; // deserialize result = SerializerForJson.Deserialize <TContent>(this.MemStream); // if none if (result == null) { // add an error this.AddErrorMessage("Unexpected result : response has a body, JSON deserialization did not fail, but no content has been deserialized"); } } catch (Exception exc) { // add an error this.AddErrorMessage("Could not deserialize response body as JSON - " + exc); } } return(result); }
//------------------------------------------------------------------------------------ /// <summary> /// Executing a script in a loop 16 ms /// </summary> /// <param name="ID">Unique script identifier</param> /// <param name="Part">Content item</param> /// <param name="Content">All content</param> /// <param name="Values">External variables, transmitted by the programmer</param> public void Update(int ID, TContentPart Part, TContent Content, Dictionary <string, string> Values) { // We rotate the object that came to the universal script by // the value of the variable given to Test.xml to My3DTextureAnimatedObject Part.ToTexture3D().Rotation = new Vector3(0, 0, Part.ToTexture3D().Rotation.Z + Content["My3DTextureAnimatedObject"].ToInt("MyTestVariable")); }
//-------------------------------------------------------------------------- /// <summary> /// Load start logic (game scripts) /// </summary> /// <param name="Content">Ссылка на контент</param> public void LoadLogic(TContent Content) { // Load start logic (game scripts) // The application is built through content and scripts. // Each script is a state machine that performs a simple action. // The content contains a single list of universal parts. // Each part can be geometry, interface, any data and their copies // Content.ScriptProcessor.Add(new TScript_LoadGame()); }
internal void CopyFrom (TContent alias) { if (alias.NotNull ()) { Cleanup (); Registration.CopyFrom (alias.Registration); foreach (var id in alias.IdCollection) { IdCollection.Add (id); } foreach (var gadgetTest in alias.TestCollection) { TestCollection.Add (gadgetTest.Clone ()); } } }
public void CopyFrom (TContent alias) { if (alias.NotNull ()) { Cleanup (); foreach (var id in alias.IdCollection) { IdCollection.Add (id); } foreach (var gadgetTest in alias.TestCollection) { TestCollection.Add (gadgetTest.Clone ()); } foreach (var gadgetTarget in alias.TargetCollection) { TargetCollection.Add (gadgetTarget.Clone ()); } } }
//-------------------------------------------------------------------------- /// <summary> /// Applying game settings for the current game /// </summary> private void GameOptions_OnApplyOption(TContent Content, TContentPart Options) { // Camera // Resetting the basic settings Camera.ClearControl(); // Set position camera Camera.PositionCamera = new Vector3(0, 0, 1000); // Enable perspective camera Camera.Content.ViewCamera3D = AstraEngine.Camera.EViewCamera3D.Perspective; // Linear move on mouse Camera.ControlMouse.SetControllerLinearMove(new AstraEngine.Camera.SButtonMoveMouse { ButtonIncreamenDown = EButtonMouse.ScrollUpButton, ButtonIncreamenUp = EButtonMouse.ScrollDownButton, ButtonMoveInPlane = EButtonMouse.MiddleButton, SensitiveIncreamenDown = 25, SensitiveIncreamenUp = 25, SensitiveMoveInPlaneX = 25, SensitiveMoveInPlaneY = 25 }); // Move to keyboard Camera.ControlKeybord.SetControllerLinearMove(new AstraEngine.Camera.SButtonMoveKeyboard { ButtonLeft = Keys.A, ButtonRight = Keys.D, ButtonUp = Keys.Q, ButtonDown = Keys.E, ButtonBackward = Keys.S, ButtonForward = Keys.W, SensitiveDown = 25, SensitiveLeft = 25, SensitiveRight = 25, SensitiveUp = 25, SensitiveAcceleration = 2 }); }
//-------------------------------------------------------------------------- /// <summary> /// Load start events /// </summary> /// <param name="Content">Link to content</param> public void LoadEvents(TContent Content) { // 1. We indicate how the game settings will be applied in this game Content.GameOptions.OnApplyOption += GameOptions_OnApplyOption; }
//------------------------------------------------------------------------------------ /// <summary> /// Executed when the script is registered in the system (Here we write what should be executed once) /// </summary> public void Initialize(int ID, TContentPart Part, TContent Content) { }