Esempio n. 1
0
 void GetNetworkGameManager()
 {
     if (_netMgr == null)
     {
         _netMgr = GameObject.Find("NetworkGameManager").GetComponent <NetworkGameManager>();
     }
 }
Esempio n. 2
0
    private void RestartGame()
    {
        NetworkGameManager.StopServer();
        Destroy(GameObject.Find("Network Manager"));

        SceneManager.LoadScene(0);
    }
Esempio n. 3
0
 // Start is called before the first frame update
 void Start()
 {
     _networkGameManager = FindObjectOfType <NetworkGameManager>();
     nodesOnPiece        = new List <Transform>();
     //  placedTrackPieces = new List<GameObject>();
     GetNextNodeList();
 }
    private bool MovePlayer()
    {
        if (movingPathTiles.Count <= 1)
        {
            return(false);
        }

        var oldPlayerTile = PlayingAreaController.tiles[currentPlayer.GetRow(), currentPlayer.GetCol()].GetComponent <Tile>();

        oldPlayerTile.objectOnTile = null;

        var newPlayerTile = PlayingAreaController.tiles[movingPathTiles[movingPathTiles.Count - 1].GetRow(), movingPathTiles[movingPathTiles.Count - 1].GetCol()].GetComponent <Tile>();

        if (newPlayerTile.objectOnTile != null)
        {
            if (newPlayerTile.objectOnTile.GetComponent <Diamond>() != null)
            {
                currentPlayer.UpdateNumOfDiamonds(1);

                Destroy(newPlayerTile.objectOnTile);
            }
            else if (newPlayerTile.objectOnTile.GetComponent <Player>() != null)
            {
                NetworkGameManager.SendMessageToClient("TileOccupied", playerTrun);
                return(false);
            }
        }

        currentPlayer.SetPlayerPos(movingPathTiles[movingPathTiles.Count - 1].GetRow(), movingPathTiles[movingPathTiles.Count - 1].GetCol());
        newPlayerTile.objectOnTile = currentPlayer.gameObject;

        return(true);
    }
Esempio n. 5
0
 public void OnPhotonInstantiate(PhotonMessageInfo info)
 {
     Debug.Log("Player #" + NetworkGameManager.localPlayerIndex +
               " received OnPhotonInstantiate callback from Player #" +
               NetworkGameManager.PlayerIndex(info.Sender));
     info.Sender.TagObject = gameObject;
 }
Esempio n. 6
0
    private void Start()
    {
        networkIdentity = GetComponent <NetworkIdentity>();
        weaponHandler   = GetComponent <WeaponHandler>();

        NetworkGameManager networkGameManager = FindObjectOfType <NetworkGameManager>();

        if (networkGameManager && isServer)
        {
            networkGameManager.RpcRegisterPlayer();
        }

        rb = GetComponent <Rigidbody>();
        Disable();
        StopAllCoroutines();

        if (!isLocalPlayer)
        {
            MeshRenderer[] meshRenderers = GetComponentsInChildren <MeshRenderer>();
            foreach (MeshRenderer meshRenderer in meshRenderers)
            {
                meshRenderer.material.color = Color.black;
            }
        }
        else
        {
            GetComponentInChildren <HealthIndicator>().gameObject.SetActive(false);
            GameObject playerHealthUI = Instantiate(localPlayerHealth.gameObject) as GameObject;
            playerHealthUI.GetComponent <LocalPlayerHealth>().Init(GetComponent <CharacterDamageable>());

            InitPlayerStartingPosition();
            InitDisconnectButton();
        }
    }
Esempio n. 7
0
    /// <summary>
    /// ローカルサーバーとして接続
    /// </summary>
    public IEnumerator ConnectLocalServer()
    {
        Debug.Log("Start local server");

        NetworkGameManager nm = NetworkGameManager.Instance;

        nm.networkPort = nm.DefaultNetworkPort;

        // 初期化
        nm.Discovery.Initialize();

        // サーバーとして開始
        if (nm.Discovery.StartAsServer() && nm.StartHost() != null)
        {
            // メンバーが揃うまで待機
            while (NetworkGameManager.Instance.PlayerCount < NetworkGameManager.Instance.matchSize)
            {
                yield return(null);
            }

            nm.Discovery.StopBroadcast();

            // ゲーム開始
            StartCoroutine(StartGame(true));
        }
        else
        {
            m_MatchingCoroutine = null;
            yield return(CancelMatch());
        }
    }
    public void EndMinigame()
    {
        NetworkGameManager.SendMessageToAllClients("Loading");

        ShowTimeResluts();
        SaveMinigameResults();
        StartCoroutine(LoadEndMingame());
    }
Esempio n. 9
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     CreatePlayerConnection();
 }
    private void BackToOptionMenu()
    {
        currentGameState = GameState.Transitioning;

        NetworkGameManager.SendMessageToClient("Back", playerTrun);

        currentGameState = GameState.OptionMenu;
    }
Esempio n. 11
0
    private IEnumerator BackToMainGame()
    {
        yield return(new WaitForSeconds(WAIT_SEC));

        SceneManager.UnloadSceneAsync(3);
        NetworkGameManager.SendMessageToAllClients("Back");
        GameController.EndMinigame();
    }
Esempio n. 12
0
    public void Init(Color color, NetworkGameManager owner)
    {
        this.owner = owner;

        MeshRenderer meshRend = GetComponent <MeshRenderer>();

        meshRend.sharedMaterial.color = color;
    }
Esempio n. 13
0
 public void ReceiveUpdateTimer(NWMTimerUpdate timerData)
 {
     if (!network_GM)
     {
         network_GM = GameObject.Find("NetworkGameManager").GetComponent <NetworkGameManager>();
     }
     network_GM.TimerManager.UpdateTimerUI(timerData.seconds);
 }
Esempio n. 14
0
    /// <summary>
    /// マッチング
    /// </summary>
    public IEnumerator Matching()
    {
        Debug.Log("Start global match");

        NetworkGameManager nm = NetworkGameManager.Instance;

        nm.networkPort = NetworkGameManager.Instance.DefaultNetworkPort;

        // マッチ開始
        if (nm.matchMaker == null)
        {
            nm.StartMatchMaker();
        }

        // ルーム検索
        yield return(nm.FindMatch());

        // ルーム参加
        yield return(nm.JoinMatch());

        // ルーム未参加ならルーム作成
        if (!nm.IsJoinedMatch)
        {
            yield return(nm.CreateMatch());

            // ルーム作成に失敗したらリスタート
            if (!nm.IsCreatedMatch)
            {
                nm.StopMatchMaker();
                StartCoroutine(m_MatchingCoroutine = Matching());
                yield break;
            }
        }

        // メンバーが揃うまで待機
        float waitTime = m_OtherPlayerCloneWaitTime;

        while (NetworkGameManager.Instance.PlayerCount < nm.matchSize)
        {
            // 自分以外のプレイヤーが一定時間いなければ退室
            if (nm.IsJoinedMatch && waitTime < 0 && NetworkGameManager.Instance.PlayerCount <= 1)
            {
                Debug.LogWarning("Host player not found");
                yield return(nm.DropMatch());

                StartCoroutine(m_MatchingCoroutine = Matching());
                yield break;
            }
            waitTime -= Time.deltaTime;

            yield return(null);
        }

        // ゲーム開始
        StartCoroutine(StartGame(true));

        m_MatchingCoroutine = null;
    }
    private static void StartNewTurn()
    {
        currentGameState = GameState.Transitioning;

        currentPlayer = PlayingAreaController.players[playerTrun].GetComponent <Player>();

        currentGameState = GameState.OptionMenu;

        NetworkGameManager.SendMessageToClient("StartTurn", playerTrun);
    }
    // Use this for initialization
    void Start()
    {
        GameController.SetNewMinigameManager(this);

        ChooseRandomMinigame();
        InitializePlayersReady();
        SetupMinigameTitleAndDescription();

        NetworkGameManager.SendMessageToAllClients("Ready?");
    }
Esempio n. 17
0
 //Wake
 void Awake()
 {
     if (!_instance)
     {
         _instance = this;
     }
     _discardPileAdventure = new Deck("");
     _discardPileStory     = new Deck("");
     _adventureDeck        = new Deck("Adventure");
     _storyDeck            = new Deck("Story");
 }
Esempio n. 18
0
 public void Update()
 {
     if (!nwgm)
     {
         nwgm = GameObject.Find("NetworkGameManager").GetComponent <NetworkGameManager>();
     }
     if (!client && !nwgm.game_finished)
     {
         client = GameObject.Find("ClientNetworkManager").GetComponent <ClientNetwork>();
     }
 }
        public override void OnServerSceneChanged(string sceneName)
        {
            var gmPrefab = Instantiate(GamemanagerPrefab);

            NetworkServer.Spawn(gmPrefab);

            NetworkGameManager = gmPrefab.GetComponent <NetworkGameManager>();
            NetworkGameManager.Set();

            base.OnServerSceneChanged(sceneName);
        }
Esempio n. 20
0
    public void UpdateNumOfDiamonds(int diamond)
    {
        numOfDiamonds += diamond;

        if (numOfDiamonds == GameController.DIAMOND_WIN_COUNT)
        {
            GameController.someoneWon = true;
            GameController.winner     = playerId;
        }

        NetworkGameManager.SendMessageToClient("Diamonds|" + numOfDiamonds, playerId);
    }
    // Use this for initialization
    void Start()
    {
        GameController.SetNewMinigameManager(this);

        playerStopCount = 0;
        timeStoped      = new float[NetworkGameManager.playerCount];

        resultOffset = new Vector3(Screen.width / 2, Screen.height / 4, 0f);

        NetworkGameManager.SendMessageToAllClients("Minigame|" + (GameController.minigameId - 1));

        StartMinigame();
    }
    // Use this for initialization
    void Start()
    {
        NetworkGameManager.SetNewGameManager(this);

        playingAreaSize = Mathf.RoundToInt(Mathf.Sqrt(PlayingAreaController.tiles.Length));

        playerTrun   = 0;
        numOfPlayers = NetworkGameManager.playerCount;

        someoneWon = false;

        playerTurnText.text = "Player" + (playerTrun + 1);
        StartNewTurn();
    }
Esempio n. 23
0
    public void CmdAssignSkill(int index)
    {
        AssignedSkillIndex = index;
        int commanderIndex = NetworkGameManager.GetCommanderCharacterIndex(characterIndex);
        NetworkPlayerCharacter commanderNetworkPlayerCharacter = NetworkGameManager.sNetworkPlayerCharacters [0];

        for (int i = 1; i < NetworkGameManager.sNetworkPlayerCharacters.Count; i++)
        {
            if (NetworkGameManager.sNetworkPlayerCharacters [i].characterIndex == commanderIndex)
            {
                commanderNetworkPlayerCharacter = NetworkGameManager.sNetworkPlayerCharacters [i];
            }
        }
        commanderNetworkPlayerCharacter.CommandSkill(GetCommandString(characterIndex, index));
    }
Esempio n. 24
0
    /// <summary>
    /// ローカルクライアントとして接続
    /// </summary>
    public IEnumerator ConnectLocalClient()
    {
        Debug.Log("Start local client");

        NetworkGameManager nm = NetworkGameManager.Instance;

        nm.networkPort = nm.DefaultNetworkPort;

        // 初期化
        nm.Discovery.Initialize();

        // クライアントとして開始
        if (nm.Discovery.StartAsClient())
        {
            // サーバー検索
            while (nm.Discovery.broadcastsReceived == null || nm.Discovery.broadcastsReceived.Count == 0)
            {
                yield return(null);
            }

            // アドレスを設定して開始
            foreach (var results in nm.Discovery.broadcastsReceived)
            {
                string address = results.Value.serverAddress;
                address = address.Substring(address.LastIndexOf(':') + 1);

                nm.networkAddress = address;
                nm.StartClient();
                break;
            }

            // メンバーが揃うまで待機
            while (NetworkGameManager.Instance.PlayerCount < NetworkGameManager.Instance.matchSize)
            {
                yield return(null);
            }

            nm.Discovery.StopBroadcast();

            // ゲーム開始
            StartCoroutine(StartGame(true));
        }
        else
        {
            m_MatchingCoroutine = null;
            yield return(CancelMatch());
        }
    }
Esempio n. 25
0
 private void Update()
 {
     current_tick += 1 * Time.deltaTime;
     UpdateMessage();
     if (in_lobby)
     {
         UpdateClientLobbyScene();
     }
     else if (in_game)
     {
         if (network_GM == null)
         {
             network_GM = GameObject.Find("NetworkGameManager").GetComponent <NetworkGameManager>();
         }
     }
 }
Esempio n. 26
0
    public void Awake()
    {
        // Started from the wrong scene? Jump back to menu
        if (!PhotonNetwork.connected)
        {
            SceneManager.LoadScene("Menu");
            return;
        }

        I = this;
        // Calculate camera/game bounds
        Camera cam    = Camera.main;
        float  height = cam.orthographicSize;
        float  width  = height * cam.aspect;

        gameBounds = new Rect(-width, -height, width * 2f, height * 2f);
    }
Esempio n. 27
0
    IEnumerator CountDown()
    {
        while (_waitingTime > 0)
        {
            _waitingTime -= 1;
            _text.text    = " Loading... " + _waitingTime;
            yield return(new WaitForSecondsRealtime(1));
        }

        if (gameObject.activeSelf)
        {
            NetworkGameManager nm = FindObjectOfType <NetworkGameManager>();
            nm.ChangeControlsState(true);
            nm.loading = false;
            gameObject.SetActive(false);
        }
    }
Esempio n. 28
0
    public void SetupClientGrid(int size, NetworkGameManager manager)
    {
        if (!in_editor)
        {
            network_manager = manager;
        }
        grid_size         = size;
        grid_base_objects = new List <List <GameObject> >();
        trackNodePos      = new List <Vector2>();
        grid_list         = new List <List <GridNode> >();
        visual_tracks     = new List <List <GameObject> >();
        for (int y = 0; y < size; y++)
        {
            List <GridNode> row_list = new List <GridNode>();
            for (int x = 0; x < size; x++)
            {
                GridNode node = new GridNode();
                node.x               = x;
                node.y               = y;
                node.player_id       = -1;
                node.tile_type       = 0;
                node.tile_y_rotation = 0.0f;
                row_list.Add(node);
            }
            grid_list.Add(row_list);
        }
        for (int y = 0; y < size; y++)
        {
            List <GameObject> base_rows = new List <GameObject>();
            List <GameObject> tile_rows = new List <GameObject>();

            for (int x = 0; x < size; x++)
            {
                GameObject base_object = Instantiate(Resources.Load("Prefabs/Base")) as GameObject;
                base_object.transform.parent = transform;
                Vector3 position = new Vector3(transform.position.x + x, transform.position.y, transform.position.z + y);
                base_object.transform.position = position;
                base_object.name = "Base Tile " + y + " " + x;
                base_rows.Add(base_object);
                tile_rows.Add(null);
            }
            grid_base_objects.Add(base_rows);
            visual_tracks.Add(tile_rows);
        }
    }
Esempio n. 29
0
 public void ReceiveUserCount(NWMUserCount user_counter)
 {
     if (connected_user_count == -1)
     {
         connected_user_count = user_counter.count;
         Debug.Log("NetworkCalled");
         if (!network_GM)
         {
             network_GM = GameObject.Find("NetworkGameManager").GetComponent <NetworkGameManager>();
         }
         if (!AR)
         {
             network_GM.SetupScene();
             network_GM.AssignClientPlayer(player_id);
             network_GM.AssignNetworkPlayer(connected_user_count);
         }
     }
 }
Esempio n. 30
0
        public override void Initialize()
        {
            HudOrigin = new Point(FinalBomber.Instance.GraphicsDevice.Viewport.Width - 234, 0);

            // Launch the dedicated server as host
            _serverProcess = new Process
            {
                StartInfo =
                {
                    FileName  = "Server.exe",
                    Arguments = "COUCOU",
                    //WindowStyle = ProcessWindowStyle.Hidden
                }
            };

            //_serverProcess.Start();

            _gameManager = GameServer.Instance.GameManager;

            _gameManager.AddPlayers();

            base.Initialize();

            // Server events
            GameServer.Instance.End += GameServer_End;

            HudOrigin     = new Point(GraphicsDevice.Viewport.Width - 234, 0);
            HudTopSpace   = 15;
            HudMarginLeft = 15;

            ScoresWindowBox = new WindowBox(WindowSkin, new Vector2(HudOrigin.X, HudOrigin.Y),
                                            new Point(GraphicsDevice.Viewport.Width - (HudOrigin.X),
                                                      HudTopSpace + _gameManager.Players.Count * Config.HUDPlayerInfoSpace + 15));

            TimerWindowBox = new WindowBox(WindowSkin, new Vector2(HudOrigin.X, ScoresWindowBox.Size.Y),
                                           new Point(GraphicsDevice.Viewport.Width - HudOrigin.X, 40));

            _gameManager.NetworkManager.AddPlayer += ResizeHud;
        }
Esempio n. 31
0
 void Awake()
 {
     sInstance = this;
 }