public MainGame() : base("Zeldo") { glClearColor(0, 0, 0, 1); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPrimitiveRestartIndex(Constants.RestartIndex); glfwSetInputMode(window.Address, GLFW_CURSOR, GLFW_CURSOR_DISABLED); Language.Reload(Languages.English); canvas = new Canvas(); sb = new SpriteBatch(); mainTarget = new RenderTarget(Resolution.RenderWidth, Resolution.RenderHeight, RenderTargetFlags.Color | RenderTargetFlags.Depth); mainSprite = new Sprite(mainTarget, null, Alignments.Left | Alignments.Top); mainSprite.Mods = SpriteModifiers.FlipVertical; // The first loop is created manually. Others are created via gamestate messages. currentState = Gamestates.Gameplay; nextState = currentState; activeLoop = CreateLoop(currentState); MessageSystem.Subscribe(this, CoreMessageTypes.Keyboard, (messageType, data, dt) => { ProcessKeyboard((KeyboardData)data); }); MessageSystem.Subscribe(this, CoreMessageTypes.ResizeWindow, (messageType, data, dt) => { mainSprite.ScaleTo(Resolution.WindowWidth, Resolution.WindowHeight); }); MessageSystem.Subscribe(this, CustomMessageTypes.Gamestate, (messageType, data, dt) => { var state = (Gamestates)data; Debug.Assert(state != Gamestates.Splash, "Can't transition to the splash loop."); // This implementation means that if multiple gamestate messages are sent on a single frame, the last // state will take priority (although that should never happen in practice). if (state != currentState) { nextState = state; } }); // Calling this function here is required to ensure that all classes receive initial resize messages. MessageSystem.ProcessChanges(); MessageSystem.Send(CoreMessageTypes.ResizeRender, Resolution.RenderDimensions); MessageSystem.Send(CoreMessageTypes.ResizeWindow, Resolution.WindowDimensions); }
public void Update(float dt) { var mouseData = GetMouseData(); var keyboardData = GetKeyboardData(); FullInputData fullData = new FullInputData(); fullData.Add(InputTypes.Mouse, mouseData); fullData.Add(InputTypes.Keyboard, keyboardData); MessageSystem.Send(CoreMessageTypes.Keyboard, keyboardData, dt); MessageSystem.Send(CoreMessageTypes.Mouse, mouseData, dt); MessageSystem.Send(CoreMessageTypes.Input, fullData, dt); }
// TODO: Add other default commands (like "help" and "commands"). private void AddDefaultCommands() { // Exit command (alias 'quit'). Add((string[] args, out string result) => { result = null; MessageSystem.Send(CoreMessageTypes.Exit); return(true); }, "exit", "quit"); // Property commands. Add("echo", Properties.TryEcho); Add("set", Properties.TryModify); }
public MainGame() : base("Dungeon") { sb = new SpriteBatch(); camera = new Camera3D(); camera.IsOrthographic = true; camera.Orientation *= quat.FromAxisAngle(0, vec3.UnitX); camera.Position = new vec3(0, 0, 1) * camera.Orientation; mainTarget = new RenderTarget(Resolution.RenderWidth, Resolution.RenderHeight, RenderTargetFlags.Color | RenderTargetFlags.Depth); mainSprite = new Sprite(mainTarget, null, Alignments.Left | Alignments.Top); mainSprite.Mods = SpriteModifiers.FlipVertical; Player player = new Player(); player.UnlockSkill(PlayerSkills.Jump); scene = new Scene(); scene.Camera = camera; scene.Add(player); scene.ModelBatch.LightDirection = Utilities.Normalize(new vec3(1, -0.2f, 0)); renderTargetUsers = new List <IRenderTargetUser>(); renderTargetUsers.Add(scene.ModelBatch); physicsTester = new PhysicsTester(); MessageSystem.Subscribe(this, CoreMessageTypes.ResizeWindow, (messageType, data, dt) => { mainSprite.ScaleTo(Resolution.WindowWidth, Resolution.WindowHeight); }); MessageSystem.ProcessChanges(); MessageSystem.Send(CoreMessageTypes.ResizeRender, Resolution.RenderDimensions); MessageSystem.Send(CoreMessageTypes.ResizeWindow, Resolution.WindowDimensions); }
// Code that runs on entering the state. public override void OnEnter() { HHK_FSM_Walking_NPC_Variables npc = Owner.GetComponent <HHK_FSM_Walking_NPC_Variables> (); // play animation via spot npc.role_controller.CrossFade(HHK_Role_Controller.AnimName.die); HHK_Role_Tags tag = Owner.GetComponent <HHK_Role_Tags>(); // force to leave the area if (npc.waiting_point) { npc.waiting_point.Leave_From_This_Place(tag); } if (npc.spot) { npc.spot.Leave_From_This_Place(tag); } npc.agent.Stop(); // send a message MessageSystem.Send(MessageSystem.NPC_Die, npc); }
////////////////////////////////////////////////////////////////////////// public void OnBlockSpawned(Block block) { MessageSystem.Send(BoardEvent.BlockSpawned, block); }
public void OnUnvalidMove(Move move) { MessageSystem.Send(BoardEvent.UnvalidMove, move); }
public void OnGameOver() { MessageSystem.Send(BoardEvent.GameOver); }
public void OnMove(Block block, Move move) { MessageSystem.Send(BoardEvent.Move, block, move); }
public void OnLockBlock(Block block) { MessageSystem.Send(BoardEvent.LockBlock, block); }
public void OnCollapseRows(List <int> rows) { MessageSystem.Send(BoardEvent.CollapseRows, rows); }
////////////////////////////////////////////////////////////////////////// public void Send <T, D>(T key, D data) { MessageSystem.Send(key, data); }
// send email IEnumerator SendEmail() { emailAddress.interactable = false; // active the mission1 MessageSystem.Send(MessageSystem.Mission1, emailAddress.text); // Send email // HHK_EmailSystem.Get().Send(emailAddress.text, // "Digital Walkers say hello to you!", // ("Hello, this message is sent from CS Department of Virtual UMass Boston.\n" + // "Also, you active a mission, please go to room S-03-075 to check it out. " + // "Good Luck!" + // "-- Digital Walkers --")); //yield return new WaitForSeconds(1f); MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(emailAddress.text); // emailAddress.text = "Sending..."; mail.Subject = "Digital Walkers say hello to you!"; mail.Body = "Hello, this message is sent from CS Department of Virtual UMass Boston.\n" + "Also, you active a mission, please go to room S-03-075 to check it out. " + "Good Luck!" + "-- Digital Walkers --"; // mail.Attachments.Add(new Attachment("Screen.png")); SmtpClient smtpServer = new SmtpClient("smtp.gmail.com"); smtpServer.Port = 587; smtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Ab123456.") as ICredentialsByHost; smtpServer.EnableSsl = true; ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; smtpServer.Send(mail); emailAddress.text = ""; // yield return new WaitForSeconds(3f); // emailAddress.interactable = false; // emailAddress.text = "Sending..."; GameObject go = GameObject.FindGameObjectWithTag("Player") as GameObject; FirstPersonController fpc = go.GetComponent <FirstPersonController>(); if (fpc) { // normal mode fpc.m_WalkSpeed = walkspeed; } OVRPlayerController ovr = go.GetComponent <OVRPlayerController>(); if (ovr) { // VR mode ovr.enabled = true; } // disable functional Collider[] colls = gameObject.GetComponentsInChildren <Collider>(); foreach (Collider col in colls) { col.enabled = false; } yield return(new WaitForSeconds(3f)); emailAddress.text = ""; emailAddress.interactable = true; gameObject.SetActive(false); yield return(new WaitForSeconds(0.1f)); }
public void GenerateEvents() { MessageSystem.Send(MessageTypes.Keyboard, GenerateKeyboardData()); MessageSystem.Send(MessageTypes.Mouse, GenerateMouseData()); }
protected Game(string title, Dictionary <TLoopType, Type> loops, TLoopType loopType, int updateTick = 60, int renderTick = 60) { Debug.Assert(updateTick > 0, "Update tick must be positive."); Debug.Assert(renderTick > 0, "Render tick must be positive."); Debug.Assert(loops.ContainsKey(loopType), $"Can't launch into loop type '{loopType}' (no associated " + "class provided)."); Debug.Assert(loops.Values.All(t => typeof(TLoop).IsAssignableFrom(t)), "Invalid type in loop map (all " + $"types must extend {typeof(TLoop).FullName})."); this.loops = loops; dtUpdate = 1f / updateTick; dtRender = 1f / renderTick; RenderTick = renderTick; DeltaTime.Value = dtUpdate; glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); var address = glfwCreateWindow(Resolution.WindowWidth, Resolution.WindowHeight, title, IntPtr.Zero, IntPtr.Zero); if (address == IntPtr.Zero) { glfwTerminate(); return; } window = new Window(Resolution.WindowWidth, Resolution.WindowHeight, address); inputProcessor = InputProcessor.Instance; // TODO: Is glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE) needed? (see the GLFW input guide) glfwMakeContextCurrent(address); glfwSetKeyCallback(address, keyCallback); glfwSetCursorPosCallback(address, cursorPositionCallback); glfwSetMouseButtonCallback(address, mouseButtonCallback); glfwSetWindowFocusCallback(address, focusCallback); glClearColor(0, 0, 0, 1); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPrimitiveRestartIndex(Constants.PrimitiveRestartIndex); camera = new TCamera(); canvas = new Canvas(); sb = new SpriteBatch(); isPauseToggled = new Primitive <bool>(); // The loop itself is created via a call to CreateLoop from parent constructors. currentLoopType = loopType; nextLoopType = loopType; MessageSystem.Subscribe(this, CoreMessageTypes.Exit, data => { glfwSetWindowShouldClose(window.Address, 1); }); MessageSystem.Subscribe(this, CoreMessageTypes.Gamestate, data => { nextLoopType = (TLoopType)data; }); MessageSystem.Send(CoreMessageTypes.ResizeRender, Resolution.RenderDimensions); MessageSystem.Send(CoreMessageTypes.ResizeWindow, Resolution.WindowDimensions); }