Example #1
0
        // when the program launches, Grid will check that all the needed elements are in place
        // that's exactly what you do in the static constructor here:
        static Grid()
        {
            GameObject g;

            g = safeFind("Map");
            map = (Map)SafeComponent(g,"Map");

            g = safeFind("Controller");
            controller = (Controller)SafeComponent(g,"Controller");

            g = safeFind("Camera");
            camera = (Camera)SafeComponent(g,"Camera");

            g = safeFind("Turn Manager");
            turnManager = (TurnManager)SafeComponent(g,"TurnManager");

            g = safeFind("Game State");
            gameState = (GameState)SafeComponent(g,"GameState");

            g = safeFind("Prefab Loader");
            prefabLoader = (PrefabLoader)SafeComponent(g,"PrefabLoader");

            // PS. annoying arcane technical note - remember that really, in c# static constructors do not run
            // until the FIRST TIME YOU USE THEM.  almost certainly in any large project like this, Grid
            // would be called zillions of times by all the Awake (etc etc) code everywhere, so it is
            // a non-issue. but if you're just testing or something, it may be confusing that (for example)
            // the wake-up alert only appears just before you happen to use Grid, rather than "when you hit play"
            // you may want to call "SayHello" from the GeneralOperations.cs, just to decisively start this script.
        }
Example #2
0
 public Skill(Unit u)
 {
     unit = u;
     unit.addSkill(this);
     activates = new List<string>();
     gameState = Grid.gameState;
 }
Example #3
0
 public void ChangeGameState(GameState newState)
 {
     GameRequest request = new GameRequest ();
                 request.type = GameRequest.Type.ChangeGameStateRequest;
                 request.newGameState = newState;
                 mRequestQueue.Enqueue (request);
 }
Example #4
0
		public int sendGameState(GameState state){
			List<float> myFloats = state.getFloatList ();

			int numElems = myFloats.Count;
			int width = sizeof(float);
			byte[] data = new byte[myFloats.Count * width+1];

			int i = 0;
			foreach (float f in myFloats)
			{
				
				byte[] converted = BitConverter.GetBytes(f);

				if (BitConverter.IsLittleEndian)
				{
					Array.Reverse(converted);
				}

				for (int j = 0; j < width; ++j)
				{
					data[i * width + j] = converted[j];
				}
				i++;
			}
			data[numElems*width] = state.getFlags(); 

			return clientGameState.SendTo(data, myFloats.Count * width+1, SocketFlags.None, endpt);	
		}
Example #5
0
 void IMenuObserver.notify(GameState gameState)
 {
     ChangeGameState (gameState);
 }
Example #6
0
        private void HandleChangeGameStateRequest(GameRequest request)
        {
            UnityEngine.Debug.Log (" currentGameState: " + mCurrentGameState.ToString () + " request.newGameState: " + request.newGameState.ToString ());
                        if (request.newGameState == AssemblyCSharp.GameState.Running &&
                                ((mCurrentGameState & (AssemblyCSharp.GameState.None | AssemblyCSharp.GameState.Ended)) != 0)) {
                                mScene.Initialize (24, 8, SHAPE_RULESET_OPTION); //start new game
                        }
                        if (request.newGameState == AssemblyCSharp.GameState.Ended) {
                                mLeaderboard.AddHighScore (mScene.GetCurrentScore ());
                                mScene.Cleanup (); //cleanup game
                        }

                        mCurrentGameState = request.newGameState;
        }
        public static void loadGame(String gameName)
        {
            setLastPlayedGame(gameName);

            instance = null;
            filePath = getFilePathForName(gameName);
            if (new FileInfo(filePath).Exists) {
                StreamReader r = File.OpenText(filePath);
              		String info = r.ReadToEnd();
              		r.Close();
                SerializableDictionary<String, object> loadedData =
                    (SerializableDictionary<String, object>) DeserializeObject(info);
                if (loadedData != null) {
                    instance = new GameState(loadedData);
                }
            }

            if (instance == null) {
                instance = new GameState();
            }
        }
 public static void startNewGame(String gameName)
 {
     filePath = getFilePathForName(gameName);
     setLastPlayedGame(gameName);
     instance = new GameState();
 }