상속: NetworkManager
예제 #1
0
        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);
        }
예제 #2
0
    // 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;
     }
 }
예제 #4
0
 /// <summary>
 /// Awake is called before Start
 /// </summary>
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
예제 #5
0
 private void OnEnable()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #6
0
 void Start()
 {
     vars               = GetComponentInParent <BasePlayerVariables>();
     hitPlayerId        = vars.playerId;
     gameController     = FindObjectOfType <GameManager>();
     gameNetworkManager = FindObjectOfType <GameNetworkManager>();
 }
예제 #7
0
 private void SetObjectId(string id)
 {
     _manager        = GameNetworkManager.Singleton;
     ObjectId        = id;
     gameObject.name = id;
     _manager.RegisterObject(id, this);
     UpdateDebugText();
 }
예제 #8
0
	void Start()
	{
		m_userNameText = GetDefaultUsername();
		m_badTickets = new List<string>();
		m_metagame = GetComponent<MetagameClient>();
		m_netManager = GetComponent<GameNetworkManager>();
		StartCoroutine(Connect());
	}
예제 #9
0
    // Join a local game, go to lobby.
    private void Join()
    {
        GameNetworkManager networkManager = GameObject.FindObjectOfType <GameNetworkManager>();

        networkManager.networkAddress = hostIP;
        networkManager.StartClient();
        SceneManager.LoadScene("LobbyScene");
    }
예제 #10
0
 // 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;
    }
예제 #13
0
        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);
        }
예제 #14
0
    // 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");
    }
예제 #15
0
 public void StartGame()
 {
     GameDiscovery.singleton.StartBroadcasting();
     GameNetworkManager.CreateGame();
     Dialog.Info("Waiting for opponent..", new UnityEngine.Events.UnityAction(delegate
     {
         GameDiscovery.singleton.Stop();
         Init();
     }));
 }
예제 #16
0
 // 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();
     }
 }
예제 #17
0
    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);
     }
 }
예제 #19
0
 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);
 }
예제 #20
0
파일: Quisk.cs 프로젝트: dasmods/ror2
        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);
        }
예제 #21
0
    private void Awake()
    {
        if (Singleton != null)
        {
            Debug.Log("GameManager already exists!");
            return;
        }

        _spawnPoints = GetSpawnPoints();
        Debug.Log("GameManager created");
        Singleton = this;
    }
예제 #22
0
    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");
    }
예제 #23
0
        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);
     }
 }
예제 #25
0
    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);
        }
    }
예제 #28
0
 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);
 }
예제 #29
0
    //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;
        }
    }
예제 #30
0
파일: Lobby.cs 프로젝트: RUGSoftEng/Team-7
    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);
        }
예제 #32
0
        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);
        }
예제 #33
0
파일: Lobby.cs 프로젝트: RUGSoftEng/Team-7
    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;
 }
예제 #35
0
 private void Awake() {
     // Init network manager
     _gameNW = GetComponent<GameNetworkManager>();
 }
예제 #36
0
파일: Game.cs 프로젝트: rkdrnf/fortresswar
 void Awake()
 {
     Init();
     netManager = netManagerObject.GetComponent<GameNetworkManager> ();
 }
예제 #37
0
    void Awake()
    {
        instance = this;

        m_match = gameObject.AddComponent<NetworkMatch>();
        Network.sendRate = 100f;
        ClearServerList ();
    }
 void Awake()
 {
     instance = this;
 }
예제 #39
0
 protected void Awake()
 {
     BaseNetworkManager.baseInstance = this;
     GameNetworkManager.instance = this;
 }