public void Initialize(string name, int level, int furType, CharacterSelectScreen characterSelectScreen) { this.level = level; this.characterSelectScreen = characterSelectScreen; this.furType = furType; nameText.text = characterName = name; levelText.text = "L" + level.ToString(); }
public SelectScreenPlayerController(int deviceIndex, UIInputManager playerUIInputManager, CharacterSelectScreen characterSelectScreen) { this.deviceIndex = deviceIndex; this.characterSelectScreen = characterSelectScreen; this.playerUIInputManager = playerUIInputManager; this.playerActive = false; //Subscribe(); }
protected virtual SinglePlayerInputs GetInputs(CharacterSelectScreen gameState) { SinglePlayerInputs inputs = new SinglePlayerInputs(); timeSinceLastPress += Time.deltaTime; if (timeSinceLastPress > timeBetweenPresses) { timeSinceLastPress = 0; inputs.A = true; } return(inputs); }
//[Command] public void CmdLoadCharacter(byte[] data) { if (data == null) { players.Remove(this); localPlayer = null; return; } CharacterSelectScreen.DeserializeCharacter(data); CharacterSelectScreen.loadedCharacter.ConvertTo(gameObject); var au = GetComponent <AbilityUser>(); au.AddPassive(au.soulGemPassive); MonsterScaler.ScaleToLevel(); }
/* The PokemonEngine() constructor initializes all of the important parts of the engine, including managers and screens. */ public PokemonEngine() { /* The GraphicsDeviceManager is initialized, and the PreferredBackBuffer properties are set to the constants screenWidth and screenHeight. * This means that the engine window will have these dimensions, if possible. * The ScreenRectangle is also initialized with a position of zero and the screen width and height. */ graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; ScreenRectangle = new Rectangle(0, 0, screenWidth, screenHeight); /* The two vital components of the engine, the InputHandler and the GameStateManager, are initialized and added to the engine's master component list. * Whenever base.Update() and base.Draw() are called from this class, everything on the component list is updated and drawn. * Since these classes contain all code for handling input and for drawing the game states, everything will now be updated and drawn properly. */ Components.Add(new InputHandler(this)); stateManager = new GameStateManager(this); Components.Add(stateManager); /* Every screen is initialized. Each has a reference to the engine and the state manager passed in. */ SplashScreen = new SplashScreen(this, stateManager); StartScreen = new StartScreen(this, stateManager); WorldScreen = new WorldScreen(this, stateManager); CharacterSelectScreen = new CharacterSelectScreen(this, stateManager); LoadGameScreen = new LoadGameScreen(this, stateManager); StarterSelectScreen = new StarterSelectScreen(this, stateManager); InventoryScreen = new InventoryScreen(this, stateManager); BattleScreen = new BattleScreen(this, stateManager); SwitchScreen = new SwitchScreen(this, stateManager); /* The state stack is reset and the SplashScreen is pushed on. This means the first thing to appear when the engine is run will be the SplashScreen. */ stateManager.ChangeState(SplashScreen); /* The content root directory is set to the "/Content/" folder, meaning every filename string passed to Content.Load<T>() will start in this folder. */ Content.RootDirectory = "Content"; /* Type matchups are initialized in the PkmnUtils class, which creates the type advantage lookup table. */ PkmnUtils.InitTypeMatchups(); /* These two settings make the game run as many times per second as it can. * They could be changed later depending on how well the engine performs. */ IsFixedTimeStep = false; graphics.SynchronizeWithVerticalRetrace = false; }
public override void Update(GameTime gameTime) { switch (ScreenState) { case ScreenStates.TransitionIn: if (!IsTransitionDone(gameTime.TotalGameTime, TransitionInTime)) { } else { ScreenState = ScreenStates.Active; } break; case ScreenStates.TransitionOut: if (!IsTransitionDone(gameTime.TotalGameTime, TransitionOutTime)) { alpha += 127 / (float) (TransitionOutTime.TotalMilliseconds / gameTime.ElapsedGameTime.TotalMilliseconds); } else { ScreenManager.RemoveScreen(this); ScreenManager.AddScreen(NextScreen); } break; default: if (InputManager.GetMenuActionState(PlayerIndex.One, MenuActions.Start) == ActionStates.Pressed) { NextScreen = new CharacterSelectScreen(ContentManager.ServiceProvider, ContentManager.RootDirectory, InputManager, ScreenManager, PlayerManager); TransitionStartTime = gameTime.TotalGameTime; ScreenState = ScreenStates.TransitionOut; } break; } }
public override void Update(Inputs _inputs) { var comsFromOpponent = NetworkManager.Instance.GetUnreadCommunications(); if (!_initializedNetworkManager) { _initializedNetworkManager = true; NetworkManager.Instance.StartListening(); } switch (_currentOnlineState) { case OnlineMatchState.WaitingForGuest: //wait for message from guest containing his IP so we can begin synchronizing foreach (var oppCom in comsFromOpponent) { if (oppCom.Communication_Type == Communication.CommunicationType.ClientConnectingToHost) { //get opponent info ConnectToHostMessage msg = JsonUtility.FromJson(oppCom.Message, typeof(ConnectToHostMessage)) as ConnectToHostMessage; GameManager.Instance.NetplayState.OpponentIp = msg.MyIP; m_setData.InitData.P2_Character = CharacterSelectScreen.GetCharacterFromString(msg.MyCharacter); _currentOnlineState = OnlineMatchState.Synchronizing; _preMatchSyncCountdown = _preMatchSyncMax; //send ready ConnectToGuestMessage toGuest = new ConnectToGuestMessage() { MyCharacter = CharacterSelectScreen.GetMatchingCharacterName(m_setData.InitData.P1_Character) }; Communication comToGuest = new Communication() { Communication_Type = Communication.CommunicationType.ReadyToBeginSync, Message = JsonUtility.ToJson(toGuest) }; comToGuest.Send(); break; } } break; case OnlineMatchState.WaitingForHost: //keep spamming host until we get his reply that he got our ip (and therefore is ready to sync) Communication.CreateGuestFirstContact(CharacterSelectScreen.GetMatchingCharacterName(m_setData.InitData.P1_Character)).Send(); foreach (var oppCom in comsFromOpponent) { if (oppCom.Communication_Type == Communication.CommunicationType.ReadyToBeginSync) { _currentOnlineState = OnlineMatchState.Synchronizing; _preMatchSyncCountdown = _preMatchSyncMax; break; } } break; case OnlineMatchState.Synchronizing: SendSyncMessage(_preMatchSyncCountdown); var syncMessages = comsFromOpponent.Where(o => o.Communication_Type == Communication.CommunicationType.Synchronization).Select(o => o.Message).ToList(); Synchronize(syncMessages); _preMatchSyncCountdown--; if (_preMatchSyncCountdown < 0) { InitGameplay(); } break; case OnlineMatchState.Gameplay: //estimate that opponent's inputs are the same as previous inputs var currentInputs = SingleFrameInputValidation.CreateNextInputs(_inputHistory.Last()); currentInputs.P1_Inputs = _inputs.P1_Inputs; _inputHistory.Add(currentInputs); //serialize input history var serializedInputHistory = CreateInputSerializedString(); //send inputs to other player Communication latstInputsHistory = new Communication() { Message = serializedInputHistory, Communication_Type = Communication.CommunicationType.InputHistory }; latstInputsHistory.Send(); //handle opponent inputs foreach (var inputComFromOpponent in comsFromOpponent.Where(o => o.Communication_Type == Communication.CommunicationType.InputHistory)) { var inputHistoryFromOpponentStr = JsonHelper.FromJson <string>(inputComFromOpponent.Message); var inputHistoryFromOpponent = new List <SingleFrameInputValidation>(); foreach (var v in inputHistoryFromOpponentStr) { var opponentInputInfo = JsonUtility.FromJson(v, typeof(SingleFrameInputValidation)) as SingleFrameInputValidation; //if both are same side, switch opponent info if (currentInputs.P1_Source == opponentInputInfo.P1_Source) { var temp = opponentInputInfo.P2_Inputs; opponentInputInfo.P2_Inputs = opponentInputInfo.P1_Inputs; opponentInputInfo.P1_Inputs = temp; opponentInputInfo.P1_Source = !opponentInputInfo.P1_Source; } inputHistoryFromOpponent.Add(opponentInputInfo); } AdjustStateForNetplay(inputHistoryFromOpponent); } //gameplay proceeds as usual base.Update(_inputs); break; case OnlineMatchState.MatchOver: break; } }
public void SetCharacterSelectScreen(Match.SetData _setData) { SetCurrentApplicationState(CharacterSelectScreen.GetCharacterSelectScreen(_setData, m_renderers.CharacterSelectR)); GameManager.Instance.SoundManager.SetMenuAudio(); }