public Shop(GameForm gameForm, GameManager gameManager, GameNetworkManager gameNetworkManager) { this.gameManager = gameManager; this.gameNetworkManager = gameNetworkManager; SelectedCharacterView = new ShopUIPanel(gameForm, gameManager) { Visible = false }; skillShop = new SpellShopPopUP(gameForm, gameManager, this, gameNetworkManager); SpellShopView = new SpellShopUIPanel(gameForm, this) { Visible = false }; btn_sellChar = new Button { Text = "Sell", Padding = new Padding(0, 0, 0, 5), Dock = DockStyle.Bottom, Height = 50 }; btn_sellChar.MouseClick += sellChar_click; SelectedCharacterView.Controls.Add(btn_sellChar); mainButtonPanel = new FlowLayoutPanel { Padding = new Padding(10, 5, 10, 0), Location = new Point(btn_sellChar.Location.X, btn_sellChar.Location.Y - btn_sellChar.Height - 20), Size = new Size(btn_sellChar.Width, btn_sellChar.Height + 10) }; SelectedCharacterView.Controls.Add(mainButtonPanel); btn_showSpells = new Button { Text = "Spells", Size = new Size(btn_sellChar.Width / 2 - 20, btn_sellChar.Height) }; btn_showSpells.MouseClick += showSpells_click; mainButtonPanel.Controls.Add(btn_showSpells); btn_levelUp = new Button { Text = "Level UP", Size = new Size(btn_sellChar.Width / 2 - 20, btn_sellChar.Height) }; btn_levelUp.MouseClick += levelUp_click; btn_levelUp.MouseHover += (sender, e) => SelectedCharacterView.ShowStatsChanges(); btn_levelUp.MouseLeave += (sender, e) => SelectedCharacterView.HideChanges(); mainButtonPanel.Controls.Add(btn_levelUp); btn_hideSkillShop = new Button { Text = "Back", Location = new Point(skillShop.Width - 90, 5) }; btn_hideSkillShop.MouseClick += (sender, e) => skillShop.Visible = false; skillShop.Controls.Add(btn_hideSkillShop); }
// Update is called once per frame void Update() { var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f; var z = Input.GetAxis("Vertical") * Time.deltaTime * 150.0f; transform.Rotate(0, x, 0); transform.Translate(0, 0, z); currentPosition = transform.position; currentrotation = transform.rotation; if (currentPosition != oldposition) { GameNetworkManager.CammandMove(transform.position); oldposition = currentPosition; } if (currentrotation != oldrotation) { GameNetworkManager.CammandRotate(transform.rotation); Debug.Log("currentrotaiton " + transform.rotation); oldrotation = currentrotation; } if (Input.GetKeyDown(KeyCode.Space)) { GameNetworkManager.CammandFire(); sm.Fire(); } }
void Awake() { if (!singleton) { singleton = this; } }
/// <summary> /// Awake is called before Start /// </summary> private void Awake() { if (Instance == null) { Instance = this; } }
private void OnEnable() { if (instance == null) { instance = this; } }
void Start() { vars = GetComponentInParent <BasePlayerVariables>(); hitPlayerId = vars.playerId; gameController = FindObjectOfType <GameManager>(); gameNetworkManager = FindObjectOfType <GameNetworkManager>(); }
private void SetObjectId(string id) { _manager = GameNetworkManager.Singleton; ObjectId = id; gameObject.name = id; _manager.RegisterObject(id, this); UpdateDebugText(); }
void Start() { m_userNameText = GetDefaultUsername(); m_badTickets = new List<string>(); m_metagame = GetComponent<MetagameClient>(); m_netManager = GetComponent<GameNetworkManager>(); StartCoroutine(Connect()); }
// Join a local game, go to lobby. private void Join() { GameNetworkManager networkManager = GameObject.FindObjectOfType <GameNetworkManager>(); networkManager.networkAddress = hostIP; networkManager.StartClient(); SceneManager.LoadScene("LobbyScene"); }
// Set name and register with manager private void UpdateName(string id) { _manager = GameNetworkManager.Singleton; PlayerId = id; gameObject.name = id; _manager.RegisterPlayer(id, this); UpdateDebugText(); }
public InactiveSpell(Character character, List <Spells[]> spells, GameNetworkManager gameNetworkManager) { this.gameNetworkManager = gameNetworkManager; BackColor = Color.White; this.character = character; offsetY = -Tile.HALF_HEIGHT - 1 * BACK_HEIGHT + HEX_OFFSET_Y; backOffsetY = offsetY - (BACK_OFFSET_Y / 2f); refreshPanel(spells); }
/// <summary> /// Initialise le script /// </summary> private void Start() { GameNetworkManager.Instance = this; this._inProgressGVR = false; this._inProgressHololens = false; this._timeGVR = 0f; this._timeHololens = 0f; }
private void InputManager_Update(On.InputManager.orig_Update orig, InputManager self) { KeyCode key = (KeyCode)Enum.Parse(typeof(KeyCode), (mod.settings as PingSettings).Key); if (Input.GetKeyDown(key)) { // First, find the mouse position as a unity vector // Next, spawn something there that lasts for x seconds // Finally, remove it after those seconds pass IGameCameraService gameCameraManager = Services.GetService <IGameCameraService>(); GameNetworkManager net = GameObject.FindObjectOfType <GameNetworkManager>(); IMessageBox msgBox = new DynData <GameNetworkManager>(net).Get <IMessageBox>("messageBox"); RaycastHit[] array = Physics.RaycastAll(gameCameraManager.ScreenPointToRay(Input.mousePosition), float.PositiveInfinity); Array.Sort <RaycastHit>(array, (RaycastHit hitInfo1, RaycastHit hitInfo2) => hitInfo1.distance.CompareTo(hitInfo2.distance)); // In theory the first raycast hit should be the best? // Not sure if this is the case... Vector3 mousePos = array[0].point; mod.Log("Raycast hits:"); foreach (RaycastHit ra in array) { mod.Log("Dist: " + ra.distance + " with pos: " + ra.point); } mod.Log("Mouse pos: " + mousePos.ToString()); bool assert = (bool)typeof(GameNetworkManager).GetMethod("AssertMessageBoxIsSet", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(net, new object[0]); if (assert && msgBox != null && net != null) { PingMessage pm = new PingMessage(); pm.SetPos(mousePos); Message m = pm as Message; mod.Log("Assertion: " + assert); mod.Log("Net: " + net.name); mod.Log("MSG BOX: " + msgBox.ToString()); EP2PSend temp = msgBox.SteamNetworkingSendMode; msgBox.SteamNetworkingSendMode = EP2PSend.k_EP2PSendReliable; msgBox.SendMessage(ref m, net.GetLobbyPlayerIDs()); msgBox.SteamNetworkingSendMode = temp; mod.Log("Attempting to display!"); } else { GameObject obj = new GameObject("PING OBJECT"); PingScript p = obj.AddComponent <PingScript>(); p.pos = mousePos; mod.Log("It seems the game is not in multiplayer, attempting to create a local ping!"); } } orig(self); }
// Close the game and return to the main menu. private void CloseGame() { GameNetworkManager networkManager = GameObject.FindObjectOfType <GameNetworkManager>(); if (networkManager.isNetworkActive) { networkManager.StopHost(); } SceneManager.LoadScene("MainMenuScene"); }
public void StartGame() { GameDiscovery.singleton.StartBroadcasting(); GameNetworkManager.CreateGame(); Dialog.Info("Waiting for opponent..", new UnityEngine.Events.UnityAction(delegate { GameDiscovery.singleton.Stop(); Init(); })); }
// Requests id from server when ready private void Init() { if (isLocalPlayer && _manager == null && GameNetworkManager.Singleton != null && !IsInit) { IsInit = true; Debug.Log("Requesting player name"); _manager = GameNetworkManager.Singleton; CmdRequestName(); } }
public void Start() { // 通知Unity在读取关卡的时候不要销毁这个游戏体 DontDestroyOnLoad(this); Instance = this; // 在这里创建ChatManager实例 mGNManager = new GameNetworkManager(); mGNManager.Start(); }
//SPECIALISATION DE LA SERIALIZATION DES COMPOSANTS ///<gameNetworkManager> void Serialize(NetworkWriter _writer, GameNetworkManager net) { _writer.Write((int)net.m_currentState); _writer.Write(net.m_players.Count); for (int i = 0; i < net.m_players.Count; ++i) { _writer.Write(net.m_players[i].m_ID); _writer.Write(net.m_players[i].m_name); _writer.Write(net.m_players[i].m_color); } }
public ChooseSpell(Character character, List <Spells[]> spells, GameNetworkManager gameNetworkManager) { this.gameNetworkManager = gameNetworkManager; this.character = character; BackColor = Color.White; offsetY = -Tile.HALF_HEIGHT - 1 * BACK_HEIGHT + HEX_OFFSET_Y; backOffsetY = offsetY - (BACK_OFFSET_Y / 2f); Size = new Size((int)BACK_WIDTH, (int)BACK_HEIGHT); Location = new Point((int)(character.CurrentTile.centerX - BACK_OFFSET_X), (int)(character.CurrentTile.centerY + backOffsetY)); refreshPanel(character, spells); }
private static void GoToSinglePlayerLobby() { GameNetworkManager gameNetworkManager = FindObjectOfType <GameNetworkManager>(); GameNetworkManager.HostDescription.HostingParameters hostingParameters = new GameNetworkManager.HostDescription.HostingParameters { listen = false, maxPlayers = 4 }; gameNetworkManager.desiredHost = new GameNetworkManager.HostDescription(hostingParameters); SceneManager.LoadScene("lobby", LoadSceneMode.Single); }
private void Awake() { if (Singleton != null) { Debug.Log("GameManager already exists!"); return; } _spawnPoints = GetSpawnPoints(); Debug.Log("GameManager created"); Singleton = this; }
public void OnRemoteDisplaySessionStart(CastRemoteDisplayManager manager) { // Start hosting and join lobby. Destroy(castSearchAnimation); LocalGameFinder localGameFinder = GameObject.FindObjectOfType <LocalGameFinder>(); localGameFinder.StartBroadCasting(); GameNetworkManager networkManager = GameObject.FindObjectOfType <GameNetworkManager>(); networkManager.StartHost(); SceneManager.LoadScene("LobbyScene"); }
public GameManager(GameForm gameForm, string playerName, bool isHost, string ip, int port) { this.gameForm = gameForm; if (isHost) { IsHost = isHost; gameNetworkManager = new GameServer(port); randomSeed = (int)DateTime.Now.Ticks; gameNetworkManager.enqueueMsg(NetworkMsgPrefix.SetSeed, GameNetworkUtilities.serializeRandomSeed(randomSeed)); } else { gameNetworkManager = new GameClient(ip, port); } grid = new Grid(GRID_WIDTH, GRID_HEIGHT, (int)((gameForm.Width - (Tile.WIDTH * GRID_WIDTH)) / 3), (int)((gameForm.Height - (Tile.HEIGHT * GRID_HEIGHT)) / 3) + 30, this); TeamBlue = new List <Character>(); TeamRed = new List <Character>(); Player = new Player(playerName, true); otherPlayers = new List <Player>(); playersLeaderBoard = new PlayersLeaderBoard(Player); CharShop = new CharShop(gameForm, this); spellShop = new Shop(gameForm, this, gameNetworkManager); stageTimer = new StageTimer(this); stageManager = new StageManager(stageTimer, TeamBlue, TeamRed, grid, Player, playersLeaderBoard, CharShop, this, gameNetworkManager); stageTimer.switchStageEvent += stageManager.switchStage; stopwatch = new Stopwatch(); timer = new Timer { Interval = GAMELOOP_INTERVAL }; timer.Tick += new EventHandler(gameLoop); }
void Start() { HealthBar = GameObject.FindGameObjectWithTag("HealthBar").GetComponent <Image>(); HealthBar.fillAmount = 1; GameNetworkManager = FindObjectOfType <GameNetworkManager>(); Rigidbody.velocity = Vector3.zero; if (!photonView.IsMine) { Destroy(PlayerCamera.gameObject.GetComponent <AudioListener>()); Destroy(PlayerCamera); Destroy(Canvas.gameObject); Destroy(Rigidbody); } }
public void Initialize() { if (instance != null) { Destroy(gameObject); return; } instance = this; // UNET currently crashes on iOS if the runInBackground property is set to true. if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.tvOS) { runInBackground = false; } }
private void Start() { if (instance == null) { DontDestroyOnLoad(this.gameObject); instance = this; udpClient = gameObject.GetComponent <UDPClientComponent>(); ConnectToUDPServer(); } else { //一个客户端只需要一个交互类 Destroy(this.gameObject); } }
void Deserialize(NetworkReader _reader, GameNetworkManager net) { State currentState = (State)_reader.ReadInt32(); net.AskForState(currentState); int playerCount = _reader.ReadInt32(); net.m_players = new List <PlayerParam>(); for (int i = 0; i < playerCount; i++) { var player = new PlayerParam(); player.m_ID = _reader.ReadInt32(); player.m_name = _reader.ReadString(); player.m_color = _reader.ReadColor(); net.m_players.Add(player); } }
private void GameSelectionPanel_UpdateShip(On.GameSelectionPanel.orig_UpdateShip orig, GameSelectionPanel self, Amplitude.StaticString shipName, bool nextOrPrevious, bool syncOverNetwork, bool refreshContent) { if (shipName == GetName()) { orig(self, shipName, nextOrPrevious, syncOverNetwork, refreshContent); DynData <GameSelectionPanel> d = new DynData <GameSelectionPanel>(self); GameNetworkManager manager = d.Get <GameNetworkManager>("gameNetManager"); Dungeon.SetShip(GetName()); if (syncOverNetwork && manager.IsServer()) { global::Session session = manager.GetSession(); session.SetLobbyData(global::Session.LOBBYDATA_GAME_SHIP, GetName()); // Values["AssumedPod"] } return; } orig(self, shipName, nextOrPrevious, syncOverNetwork, refreshContent); }
//GameNetworkManagerの初期化 public void Initialize() { if (instance != null) { Destroy(gameObject); return; } instance = this; // UNET currently crashes on iOS if the runInBackground property is set to true. //runInBackgroundプロパティがtrueに設定されていると、UNETは現在iOSでクラッシュします。 //なので、iOSの場合ここでfalseに設定する //UNETはネットワーク通信するための仕組み。 if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.tvOS) { runInBackground = false; } }
public new void Start() { base.Start(); CastRemoteDisplayManager castDisplayManager = CastRemoteDisplayManager.GetInstance(); if (castDisplayManager.IsCasting()) { castDisplayManager.RemoteDisplayErrorEvent.AddListener(OnRemoteDisplayError); castDisplayManager.RemoteDisplaySessionEndEvent.AddListener(OnRemoteDisplaySessionEnd); } this.gameNetworkManager = GameObject.FindObjectOfType <GameNetworkManager>(); InvokeRepeating("CheckConnection", CONNECTION_CHECK_INTERVAL, CONNECTION_CHECK_INTERVAL); // Load menu assets. arrowIcon = Resources.Load <Texture>("Menu/arrow"); arrowFlippedIcon = Resources.Load <Texture>("Menu/arrow-flipped"); difficultyIcons = Resources.LoadAll <Texture>("Menu/Difficulties"); }
public SpellShopPopUP(GameForm gameForm, GameManager gameManager, Shop shop, GameNetworkManager gameNetworkManager) { this.shop = shop; this.gameNetworkManager = gameNetworkManager; lbl_spellStats = new Label { Dock = DockStyle.Top }; manager = gameManager; Size = new Size(270, 300); Location = new Point((int)(gameForm.Width * 0.55), (int)(gameForm.Height * 0.09)); Visible = false; Padding = new Padding(10, 10, 10, 10); BorderStyle = BorderStyle.FixedSingle; BackColor = Color.FromArgb(100, 255, 255, 255); DoubleBuffered = true; btn_upgradeSkill = new Button { Height = 35, Text = "Upgrade spell", Dock = DockStyle.Bottom }; btn_upgradeSkill.MouseClick += upgradeSpell_click; btn_upgradeSkill.Visible = false; btn_buySkill = new Button { Height = 35, Text = "Purchase spell", Dock = DockStyle.Bottom }; btn_buySkill.Visible = false; btn_buySkill.MouseClick += buySkill_click; Controls.Add(btn_buySkill); Controls.Add(btn_upgradeSkill); gameForm.Controls.Add(this); }
public Character(Grid grid, Tile currentTile, Teams team, CharacterType[] characterType, GameManager gameManager, GameNetworkManager gameNetworkManager) { this.grid = grid; currentTile.CurrentCharacter = this; this.team = team; SpellReady = false; this.characterType = characterType; this.gameManager = gameManager; this.gameNetworkManager = gameNetworkManager; ChooseSpell = new ChooseSpell(this, ActiveSpells, gameNetworkManager); InactiveSpell = new InactiveSpell(this, InactiveSpells, gameNetworkManager); Stats = CharacterType.statsCopy(); ActiveSpells = new List <Spells[]>(); InactiveSpells = new List <Spells[]>(); LearnedSpells = new List <Spells[]>(); SpellLevel = new Dictionary <Spells[], int>(); brush = (team == Teams.Blue) ? Brushes.BlueViolet : Brushes.Red; isBlue = (team == Teams.Blue); statusEffects = new List <StatusEffect>(); IsDead = false; statsMultiplier = new Dictionary <StatusType, float>(); statsAdder = new Dictionary <StatusType, int>(); foreach (StatusType statusType in Enum.GetValues(typeof(StatusType))) { statsAdder.Add(statusType, 0); statsMultiplier.Add(statusType, 1f); } hpBar = new StatBar(this, team == Teams.Blue ? Brushes.GreenYellow : Brushes.OrangeRed, 0); charageBar = new StatBar(this, Brushes.Blue, 1); }
public new void Start() { base.Start(); CastRemoteDisplayManager castDisplayManager = CastRemoteDisplayManager.GetInstance(); if (castDisplayManager.IsCasting()) { castDisplayManager.RemoteDisplayErrorEvent.AddListener(OnRemoteDisplayError); castDisplayManager.RemoteDisplaySessionEndEvent.AddListener(OnRemoteDisplaySessionEnd); } this.gameNetworkManager = GameObject.FindObjectOfType<GameNetworkManager>(); InvokeRepeating("CheckConnection", CONNECTION_CHECK_INTERVAL, CONNECTION_CHECK_INTERVAL); // Load menu assets. arrowIcon = Resources.Load<Texture>("Menu/arrow"); arrowFlippedIcon = Resources.Load<Texture>("Menu/arrow-flipped"); difficultyIcons = Resources.LoadAll<Texture>("Menu/Difficulties"); }
private void Start() { instance = this; }
private void Awake() { // Init network manager _gameNW = GetComponent<GameNetworkManager>(); }
void Awake() { Init(); netManager = netManagerObject.GetComponent<GameNetworkManager> (); }
void Awake() { instance = this; m_match = gameObject.AddComponent<NetworkMatch>(); Network.sendRate = 100f; ClearServerList (); }
void Awake() { instance = this; }
protected void Awake() { BaseNetworkManager.baseInstance = this; GameNetworkManager.instance = this; }