How to create different "pages" in XNA? - c#

(I think I heard this being called a "state-based" game, but I'm not sure...)
Basically what I want to do is have my start screen be one class, and then it passes on control (of the window/drawing/updating) to another class (ie the game class) and I can pass back control to the start screen class from the actual game class.
I want to switch logic control without opening a new window, and closing the original, but just seamlessly transfering to another class.
EDIT: I'm not looking for anyone to tell me exactly how to do this, just please nudge me in the right direction because I couldn't find it on Google...

There's a sample for that: XNA Game State Management sample.

Related

Finding Main Camera in CustomUnityEditor Class

Iam writing a custom editor script in unity. I want to find the MainCamera in the scene for Custom Editor class so it can be directly assigned to the script and I dont have to assign it. I know i can find all cameras in scene and iterate over it through tags but I want to know if weather a direct method like Camera.main is available which brings the MainCamera of the scene in Custom Editor.
PS: I know it is easy to assign directly but still I want to do it by fetching through in custom editor script. Also I dont want to do it at runtime in start as I have some canvas related calculations which needs to be taken care of
OK I know this is embarrassing but here is the answer which was really simple.
You can directly use the code below to get the main camera.
GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
Note:
This will find the first camera with tag like so if your scene has only one main camera then it will get you that and don't have to worry about Camera.main. But my second part of question still remains. When is the Camera.main is assigned?

Unity - chat not on top of everything

So, I've been searching ALOT for this and I feel like I've tried pretty much everything, and still I'm coming up short.
The basic idea is to have a chat and also be able to have things in front of that chat window (lets say a draggable menu of sorts).
As a first thing I setup my chat as a GUI element. It works perfect.. word-wrapping and all, but it's always on top of everything else, so this doesn't really work for what I want to do.
The chat box is also scaling depending on your screen resolution.
I think the main issue is going to get it nicely word wrapped when NOT using GUI and I'm just all out of ideas.
Also wanted to state that the "menu" that's going over the chat is going to be containing gameobjects so it's not going to be another GUI element.
Can this even be done?
use GUI.depth=10 before drawing your chat window, and GUI.depth=5 after everything should appaer on top now.
From the documentation:
Set this to determine ordering when you have different scripts running simultaneously. GUI elements drawn with lower depth values will appear on top of elements with higher values (ie, you can think of the depth as "distance" from the camera).
if you dont want to do this.. determine order of drawing. Whatever gets drawn last is on top.
I understand at this stage it may be hard to do this, but its best to have one OnGUI active in your whole game/app. Having more than one deteriorates performance.
edit: to include scene renders on top of the GUI, you render your scene to a seperate camera (without gui) and have this camera render to texture. this texture can then be used in your gui by using for instance GUI.DrawTexture.

Creating an information table for a game

I am interested in integrating an external project with the game Lineage 2. I do not have developer access.
I envision that my project would have a Form, that show the status of the top 100 Player V Player. I have had some luck with receiving the top 100 list and such that is not my problem
My problem is, how is it possible to get my form, to be overlaid on the game's screen. I would also like for it to be shown but not to receive input.
My experience with overlaying a windows form on top a full-screen application such as a game is going to be a very difficult task to do, but not impossible. You can find an example that was done in the XNA game development forms here: http://www.gamedev.net/topic/367591-mdxc-overlay-sample/

XNA Screen Management

im using this example from the AppHub http://create.msdn.com/en-US/education/catalog/sample/game_state_management
Im using this example to create a menu system for my game. The game is already created and working without any sort of Menu's etc hence why i wish to use the game state management.
I have been looking at the example and it only really says to implement the game code into the GameplayScreen class. However I have problems with this as I cant then load certain game elements at this location for several reasons (One being that this class doesnt inherit the Microsoft.Xna.Framework.Game) So im a bit of a loss how i can load them somewhere else for example and get access to them still. My Game is made up of two pieces primarily, PongSystem Which controls most of the game and PongGame which holds most of the nitty gritty of the game.
If someone could help by explaining how i can implement my game into this example the easiest way that would be appreciated.
My game can be found here - http://min.us/mYZYMgzdC
Thanks for the help :)
If you don't mind a basic winform menu you can always create a menu in windows form and call your game with the Process class.
Process myProcess = new Process();
myProcess.StartInfo.FileName = //You .exe FilePath
myProcess.Start();
If you don't like this approach, someone posted a question like yours here and got a few links.
Good luck with your menu.
Using GameComponent objects you can load everything you need.( http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gamecomponent.aspx ) They are threaded and ideal for handling different sections of logic without cluttering your screens.
Create a main screen and add components to it, then create your main game class and it can refereence your comoponents.
Sorry If I am not explaining this very clearly.
From my past projects, I have found that these tutorials (1-7) are very helpful on using GSM,
first part - http://www.youtube.com/watch?v=-mw6kGYCllI
last part - http://www.youtube.com/watch?v=3fbCZMuPCe0
It will give you a nice base which you can build upon if you follow the tutorials.
Heres a screenshot the latest game menu/game i developed.
http://philipstarritt.com/wave/ironfist
Hope this helps

Timer to appear on Game Screen

I have made a countdown timer using C# on basic form window and i want it to appear on game screen i tried to set form properties but it wont work on game screen.
how would it be done? Any Idea?
If you are looking to draw a timer into an existing DirectX or OpenGL backed game then I suggest you take a look at the following question which offers information about hooking and the ability to intercept calls along with working with the applications draw calls. However I believe this is above the level of complexity you would wish to encounter for adding a timer.
LINK : OpenGL/DirectX Hook - Similar to FRAPS
As you don't indicate if you are using OpenGL, XNA or what I will give you a generic response.
If it is your game
Your splash screen should be part of the game loop. This means that will have an update() and a draw().
In the update method you have to calculate the remaining time and store it in a variable or property of an object.
In the draw method you should paint the remaining time.
My recommendation is that you create a TimeCounter class because seems you are also going to reuse it during game.
If it is not your game
Most games will switch to full-screen direct-render mode. It is not impossible but pretty hard.
If the game is web, then you can wrap it in IFrame or similar and put the counter

Categories