Inheritance: MonoBehaviour
Beispiel #1
0
 //Called every frame
 void Update()
 {
     if (Input.GetKey(KeyCode.Mouse0) && attackReady)
     {
         //left click attack
         attackReady = false;
         var   dir   = ((Vector2)(Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position)).normalized;
         float delay = player.basicAttack(dir);
         Invoke("enableAttack", delay);
         NetworkingManager.send_next_packet(DataType.Trigger, player.playerID, new List <Pair <string, string> > {
             new Pair <string, string>("Attack", "0"),
             new Pair <string, string>("DirectionX", dir.x.ToString()),
             new Pair <string, string>("DirectionY", dir.y.ToString())
         });
     }
     else if (Input.GetKey(KeyCode.Mouse1) && attackReady && specialReady)
     {
         //right click attack
         attackReady  = false;
         specialReady = false;
         var     dir   = ((Vector2)(Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position)).normalized;
         float[] delay = player.specialAttack(dir);
         Invoke("enableAttack", delay[0]);
         Invoke("enableSpecial", delay[1]);
         NetworkingManager.send_next_packet(DataType.Trigger, player.playerID, new List <Pair <string, string> > {
             new Pair <string, string>("Attack", "1"),
             new Pair <string, string>("DirectionX", dir.x.ToString()),
             new Pair <string, string>("DirectionY", dir.y.ToString()),
         });
     }
 }
Beispiel #2
0
        internal static bool Prefix(NetworkingManager __instance, string serverTitle, string password, int maxPlayerCount)
        {
            Network.InitializeSecurity();

            try
            {
                __instance.password_    = password;
                __instance.serverTitle_ = serverTitle;

                G.Sys.GameData_.SetString("ServerTitleDefault", __instance.serverTitle_);

                __instance.maxPlayerCount_ = Mathf.Clamp(maxPlayerCount, 1, Mod.Instance.Config.MaxPlayerCount);

                G.Sys.GameData_.SetInt("MaxPlayersDefault", __instance.maxPlayerCount_);

                const int num         = 1;
                int       connections = __instance.maxPlayerCount_ - num;

                NetworkConnectionError networkConnectionError = Network.InitializeServer(connections, 32323, true);

                if (networkConnectionError != NetworkConnectionError.NoError)
                {
                    G.Sys.MenuPanelManager_.ShowError("Failed to create game lobby. Error code: " + networkConnectionError.ToString(), "Network Error", null, UIWidget.Pivot.Center);
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
                Mod.Instance.Logger.Exception(ex);
            }

            return(false);
        }
Beispiel #3
0
    /*---------------------------------------------------------------------------------------
     * -- FUNCTION:     OkDropButtonOnClick
     * -- DATE:         10/03/2016
     * -- REVISIONS:
     * -- DESIGNER:     Joseph Tam-Huang
     * -- PROGRAMMER:   Joseph Tam-Huang
     * -- INTERFACE:    public void OkDropButtonOnClick()
     * -- RETURNS:  void
     * -- NOTES:
     * -- Checks that the amount trying to be dropped is allowed. If yes, send a DropItem
     * -- network message, otherwise update the error message.
     * ----------------------------------------------------------------------------------------*/
    public void OkDropButtonOnClick()
    {
        Debug.Log("ok drop clicked");
        _drop_amt = int.Parse(_amt_input_field.GetComponent <InputField>().text);
        if (_drop_amt > 0 && _drop_amt <= _amt)
        {
            // Send Network message
            List <Pair <string, string> > msg =
                _world_item_manager.CreateDropItemNetworkMessage(_item.id, _drop_amt, _inv_pos);
            NetworkingManager.send_next_packet(DataType.Item, (int)ItemUpdate.Drop, msg, Protocol.TCP);

            // Pretend that a drop message was received
            if (Application.platform != RuntimePlatform.LinuxPlayer)
            {
                _world_item_manager.ReceiveItemDropPacket(_world_item_manager.ConvertListToJSONClass(msg));
            }

            GameData.MouseBlocked = false;
            Deactivate();
        }
        else
        {
            _error_text.text = "Invalid amount";
        }
    }
    private void OnEnable()
    {
        if (instance != this)
        {
            if (instance != null)
            {
                enabled = false;
            }
            else
            {
                instance = this;
            }
        }

        var identifiers = FindObjectsOfType <StudentIdentifier>();

        //foreach (var identifier in identifiers)
        //{
        //	if (identifier.name.ToLower().Contains("voice"))
        //		voiceWand = identifier;
        //}
        GameObject wand = (GameObject)NetworkingManager.LoadNetworkedPrefab("StudentSelectWand");

        voiceWand = NetworkingManager.Instantiate(wand).GetComponent <StudentIdentifier>();

        if (voiceWand)
        {
            voiceWand.studentSelected.AddListener(StudentSelectedForVoice);
        }
        studentsRequesting = new List <int>();
    }
    void died(JSONClass packet)
    {
        if (GameData.LobbyData[playerID].TeamID == GameData.MyPlayer.TeamID)
        {
            GameData.EnemyTeamKillCount++;
        }
        else
        {
            GameData.AllyTeamKillCount++;
        }

        NetworkingManager.Unsubscribe(DataType.Player, playerID);
        GameData.PlayerPosition.Remove(playerID);
        Destroy(gameObject);

        if (playerID == GameData.AllyKingID)
        {
            GameManager.instance.GameLost();
        }

        if (playerID == GameData.EnemyKingID)
        {
            GameManager.instance.GameWon();
        }
    }
Beispiel #6
0
 public void Start()
 {
     manager = GetComponent <NetworkingManager>();
     loginCreatureComforts = FindObjectOfType <LoginCreatureComforts>();
     DontDestroyOnLoad(this.gameObject);
     manager.Connect();
 }
Beispiel #7
0
 void Awake()
 {
     myID       = 0;
     regenerate = false;
     alive      = new bool[9];
     manager    = gameObject.GetComponent <NetworkingManager>();
 }
Beispiel #8
0
    private void escolherEmpresa()
    {
#if ACME_CO
        NetworkingManager.loadEmpresa(choices,
                                      PlaceholderData.acmeCo,
                                      s => mensagem(s, escolherEmpresa));
        escolherCPF();
        return;
#elif TIO_PATINHAS_BANK
        NetworkingManager.loadEmpresa(choices,
                                      PlaceholderData.tioPatinhasBank,
                                      s => mensagem(s, escolherEmpresa));
        escolherCPF();
        return;
#else
        foreach (string nomeEmpresa in PlaceholderData.nomeEmpresas)
        {
            createUI(basic_button)
            .setText(nomeEmpresa)
            .setOnClick(() => {
                clearUI();
                loading("Carregando informações da empresa...");
                if (NetworkingManager.loadEmpresa(
                        choices, nomeEmpresa, s => mensagem(s, escolherEmpresa, doClearUI: true)))
                {
                    clearUI();
                    escolherCPF();
                }
            });
        }
#endif
    }
Beispiel #9
0
 /*---------------------------------------------------------------------------------------------------------------------
 *  -- METHOD: ReturnToMenu
 *  --
 *  -- DATE: March 25th, 2016
 *  --
 *  -- REVISIONS: N/A
 *  --
 *  -- DESIGNER: Carson Roscoe
 *  --
 *  -- PROGRAMMER: Carson Roscoe
 *  --
 *  -- INTERFACE: void ReturnToMenu(void)
 *  --
 *  -- RETURNS: void
 *  --
 *  -- NOTES:
 *  -- Cleanup all data & networking code since the game is over when this is invoked. Essentially reset everything
 *  ---------------------------------------------------------------------------------------------------------------------*/
 public void ReturnToMenu()
 {
     NetworkingManager.instance.ResetConnections();
     NetworkingManager.ClearSubscriptions();
     GameData.LobbyData.Clear();
     GameData.aiSpawn            = new Pair <int, int>(10, 10);
     GameData.AllyKingID         = -1;
     GameData.EnemyKingID        = -1;
     GameData.AllyTeamKillCount  = 0;
     GameData.EnemyTeamKillCount = 0;
     GameData.GameStart          = false;
     GameData.InputBlocked       = false;
     GameData.IP           = "192.168.0.";
     GameData.ItemCollided = false;
     GameData.MouseBlocked = false;
     GameData.Seed         = 0;
     GameData.TeamSpawnPoints.Clear();
     GameData.PlayerPosition.Clear();
     GameData.MyPlayer     = new PlayerData();
     GameData.GameState    = GameState.Playing;
     GameData.CurrentTheme = Themes.Grass;
     Destroy(NetworkingManager.instance);
     Destroy(Inventory.instance);
     Destroy(WorldItemManager.Instance);
     //Application.LoadLevel("MenuScene");
 }
Beispiel #10
0
 private static void Send(string packet)
 {
     if (NetworkingManager.TCP_Send(packet, 256) < 0)
     {
         Debug.Log("[Debug]: SelectTeam(): Packet sending failed\n");
     }
 }
Beispiel #11
0
    /*---------------------------------------------------------------------------------------------------------------------
    *  -- FUNCTION:    SendLaserPacket
    *  --
    *  -- DATE:        March 16, 2016
    *  --
    *  -- REVISIONS:
    *  --
    *  -- DESIGNER:    Carson Roscoe
    *  --
    *  -- PROGRAMMER:  Carson Roscoe
    *  --
    *  -- INTERFACE:   void SendLaserPacket()
    *  --
    *  -- RETURNS:     void
    *  --
    *  -- NOTES:
    *  --  Sends a packet to the networking manager to tell it that you have fired a gunner special shot.
    *  ---------------------------------------------------------------------------------------------------------------------*/
    void SendLaserPacket()
    {
        var member = new List <Pair <string, string> >();

        member.Add(new Pair <string, string>("playerID", playerID.ToString()));
        NetworkingManager.send_next_packet(DataType.SpecialCase, (int)SpecialCase.GunnerSpecial, member, Protocol.UDP);
    }
Beispiel #12
0
 // Update is called once per frame
 void Update()
 {
     if (EndGameCanvas == null)
     {
         if (NetworkingManager.GetLocalPlayer() != null)
         {
             EndGameCanvas = NetworkingManager.GetLocalPlayer().GetComponentInChildren <EndGameCanvasScript>().gameObject;
             EndGameCanvasScript canvasscript = NetworkingManager.GetLocalPlayer().GetComponentInChildren <EndGameCanvasScript>();
             WinObject = canvasscript.WinObject;
         }
         else
         {
             return;
         }
     }
     ThirtyTimerPlaceHolder = PlayerPrefs.GetFloat("30mTimer");
     if (PlayerPrefs.GetInt("ThirtyMinuteTimer") == 1 && GameObject.Find("1LeverHandle(Clone)").GetComponent <LeverScript>().GameOver == false || PlayerPrefs.GetInt("ThirtyMinuteTimer") == 1 && GameObject.Find("2LeverHandle(Clone)").GetComponent <LeverScript>().GameOver == false)
     {
         TimerPlaceHolder -= Time.deltaTime;
         float b;
         b = TimerPlaceHolder;
         PlayerPrefs.SetFloat("30mTimer", b);
     }
     ThirtyTimerPlaceHolder = PlayerPrefs.GetFloat("TimeElapsedTimer");
     if (PlayerPrefs.GetInt("TimeElapsed") == 1 && GameObject.Find("1LeverHandle(Clone)").GetComponent <LeverScript>().GameOver == false || PlayerPrefs.GetInt("TimeElapsed") == 1 && GameObject.Find("2LeverHandle(Clone)").GetComponent <LeverScript>().GameOver == false)
     {
         ThirtyTimerPlaceHolder += Time.deltaTime;
         float b;
         b = ThirtyTimerPlaceHolder;
         PlayerPrefs.SetFloat("TimeElapsedTimer", b);
     }
 }
Beispiel #13
0
    /*--------------------------------------------------------------------------------------
     * -- FUNCTION:     OnTriggerEnter2D
     * -- DATE:         05/03/2016
     * -- REVISIONS:
     * -- DESIGNER:     Joseph Tam-Huang
     * -- PROGRAMMER:   Joseph Tam-Huang
     * -- INTERFACE:    void OnTriggerEnter2D(Collider2D other)
     * --                  Collider2D other: The collider box of the other GameObject
     * -- RETURNS:  void
     * -- NOTES:
     * -- The trigger_entered flag is enabled when the player comes into contact with the
     * -- collider box of the world item for the first time.
     * -----------------------------------------------------------------------------------------*/
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Player" &&
            other.gameObject.GetComponent <BaseClass>().playerID == GameData.MyPlayer.PlayerID)
        {
            _trigger_entered = true;

            // Send item pickup message once if gold
            if (Inventory.instance.CheckIfItemCanBeAdded(item.stackable, item.id))
            {
                if (autolootable)
                {
                    int player_id = GameData.MyPlayer.PlayerID;
                    List <Pair <string, string> > msg = new List <Pair <string, string> >();
                    msg = _world_item_manager.CreatePickupItemNetworkMessage(world_item_id, player_id, item.id, amount);
                    NetworkingManager.send_next_packet(DataType.Item, (int)ItemUpdate.Pickup, msg, Protocol.TCP);

                    _tooltip.Deactivate();

                    // Pretend that a pickup event was received
                    if (Application.platform != RuntimePlatform.LinuxPlayer)
                    {
                        StartCoroutine(WorldItemManager.Instance.WaitSmallDelayBeforeReceivePickupPacket(WorldItemManager.Instance.ConvertListToJSONClass(msg)));
                    }
                }
            }
            else
            {
                StartCoroutine(Inventory.instance.DisplayInventoryFullError());
            }
        }
    }
Beispiel #14
0
    /*---------------------------------------------------------------------------------------------------------------------
    *  -- METHOD: sleep
    *  --
    *  -- DATE: April 3rd, 2016
    *  --
    *  -- REVISIONS: N/A
    *  --
    *  -- DESIGNER: Dhivya Manohar
    *  --
    *  -- PROGRAMMER: Dhivya Manohar
    *  --
    *  -- INTERFACE: IEnumerator sleep(void)
    *  --
    *  -- RETURNS: void
    *  --
    *  -- NOTES:
    *  -- Wait 5 seconds and then invoke all cleanup code and close the game.
    *  ---------------------------------------------------------------------------------------------------------------------*/
    IEnumerator sleep()
    {
        yield return(new WaitForSeconds(5));

        System.Diagnostics.Process.GetCurrentProcess().Kill();
        NetworkingManager.instance.ResetConnections();
        NetworkingManager.ClearSubscriptions();
    }
	void Awake()
	{
		if (instance == null)				//Check if instance already exists
			instance = this;				//if not, set instance to this
		else if (instance != this)			//If instance already exists and it's not this:
			Destroy(gameObject);   			//Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. 
		DontDestroyOnLoad(gameObject);		//Sets this to not be destroyed when reloading scene
	}
Beispiel #16
0
 private void Init()
 {
     if (initialized)
     {
         return;
     }
     initialized       = true;
     networkingManager = (NetworkingManager)target;
 }
Beispiel #17
0
 public void ButtonExitToMainMenu()
 {
     AudioManager.PlaySFX(EnumAudioId.Button);
     Toast.MakeText(EnumToast.Debug, "Disconnected from lobby!");
     NetworkingManager.DisconnectFromLobby();
     EventManager.Raise(new GameResetEvent(DefynModules.EventCore.Definitions.E.Launch));
     UIManager.FlushPanel();
     UIManager.RenderPanel(EnumUI.MainMenu);
 }
Beispiel #18
0
    /*----------------------------------------------------------------------------
     * --	Attempt to place a building to where the mouse is at when an left click
     * --  event is triggered. Assigns the corresponding attributes to the Building
     * --  component.
     * --	Interface:  private bool PlaceBuilding(GameObject building)
     * --					[building] Building that will be placed
     * --	programmer: Jerry Jia, Thomas Yu
     * --	@return: void
     * ------------------------------------------------------------------------------*/
    private bool PlaceBuilding(GameObject building)
    {
        // Construct a vector of where the Gameobject will be placed
        Vector3 buildingLocation = new Vector3((int)currFramePosition.x, (int)currFramePosition.y, -2);

        // Check if it is a valid location to place the building
        if (!CheckValidLocation(building))
        {
            return(false);
        }


        // Set the color transparency
        shop.Selected.Building.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f);

        SetAllCollidersStatus(building, true);


        // Indicate that the item has been successfully bought and placed
        ItemBought = false;

        //weird merge conflict here (END)
        placementRange.SetActive(false);

        print("x: " + building.transform.rotation.x + " y: " + building.transform.rotation.y + " z: " + building.transform.rotation.z);
        if (Application.platform == RuntimePlatform.LinuxPlayer)
        {
            // Send the packet, with Team ID, user name, and the message input
            List <Pair <string, string> > packetData = new List <Pair <string, string> >();
            packetData.Add(new Pair <string, string>(NetworkKeyString.TeamID, GameData.MyPlayer.TeamID.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.XPos, buildingLocation.x.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.YPos, buildingLocation.y.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.ZPos, buildingLocation.z.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.XRot, building.transform.rotation.x.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.YRot, building.transform.rotation.y.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.ZRot, building.transform.eulerAngles.z.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.BuildType, ((int)buildType).ToString()));
            var packet = NetworkingManager.send_next_packet(DataType.UI, (int)UICode.BuildingCreation, packetData, Protocol.NA);
            Send(packet);
        }
        else
        {
            GameObject testBuild = (GameObject)Instantiate(building, buildingLocation, building.transform.rotation);
            testBuild.GetComponent <Building>().placing = false;
            if (testBuild.GetComponent <Building>().type == Building.BuildingType.Turret)
            {//
                testBuild.GetComponent <AI>().instantTurret(2, 40, 2, 15, 15);

                //testBuild.GetComponent<AI>().instantTurret(2, 40, GameData.MyPlayer.TeamID, 15, 15);
                Debug.Log("Instant turret 2");
            }
        }

        Destroy(building);
        return(true);
    }
    public void ButtonSendEmoji(int id)
    {
        if (isMessageReady)
        {
            StartCoolDown();

            object[] data = { id };
            NetworkingManager.RaiseNetworkEvent(EnumNetworkEvent.Emoji, data);
        }
    }
Beispiel #20
0
    /*------------------------------------------------------------------------------------------------------------------
     * -- FUNCTION:     SendMessageToServer
     * -- DATE:         April 5, 2016
     * -- REVISIONS:    N/A
     * -- DESIGNER:    Krystle Bulalakaw
     * -- PROGRAMMER:  Krystle Bulalakaw
     * -- INTERFACE:    void SendMessageToServer(List<Pair<string, string>> msg, int eventType)
     * --                      List<Pair<string, string>> msg - the message to send
     * --                      int eventType                  - the item event type
     * -- RETURNS:  List<Pair<string, string>>   - List of map event data
     * -- NOTES:
     * -- Sends a message to the server via Networking Manager's send_next_packet call.
     * ----------------------------------------------------------------------------------------------------------------------*/
    void SendMessageToServer(List <Pair <string, string> > msg, int eventType)
    {
        var packet = NetworkingManager.send_next_packet(DataType.Item, eventType, msg, Protocol.TCP);

        if (Application.platform != RuntimePlatform.LinuxPlayer)
        {
            string temp = "[" + packet + "]";
            NetworkingManager.instance.update_data(temp);
        }
    }
Beispiel #21
0
 void networkingManager_MessageReceived(object sender, BlockPartyShared.MessageReceivedEventArgs e)
 {
     if (e.Message.Type == BlockPartyShared.NetworkMessage.MessageType.ServerGameState &&
         (string)e.Message.Content == "Results")
     {
         NetworkingManager.Send(new NetworkMessage(NetworkMessage.MessageType.ClientResults, Score.GameScore));
         ScoreManager.LatestScore = Score.GameScore;
         serverGameStateChanged   = true;
     }
 }
Beispiel #22
0
    public static void SendLobbyData(NetworkCode code)
    {
        // Construct json packet
        List <Pair <string, string> > packetData = new List <Pair <string, string> >();

        if (code != NetworkCode.PlayerJoinedLobby)
        {
            packetData.Add(new Pair <string, string>(NetworkKeyString.PlayerID, GameData.MyPlayer.PlayerID.ToString()));
        }

        switch (code)
        {
        case NetworkCode.TeamChangeRequest:
            packetData.Add(new Pair <string, string>(NetworkKeyString.TeamID, GameData.MyPlayer.TeamID.ToString()));
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.TeamChangeRequest, packetData, Protocol.NA));
            break;

        case NetworkCode.ClassChangeRequest:
            packetData.Add(new Pair <string, string>(NetworkKeyString.ClassID, ((int)GameData.MyPlayer.ClassType).ToString()));
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.ClassChangeRequest, packetData, Protocol.NA));
            break;

        case NetworkCode.ReadyRequest:
            packetData.Add(new Pair <string, string>(NetworkKeyString.Ready, GameData.MyPlayer.Ready ? "1" : "0"));
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.ReadyRequest, packetData, Protocol.NA));
            break;

        case NetworkCode.PlayerJoinedLobby:
            packetData.Add(new Pair <string, string>(NetworkKeyString.UserName, "\"" + GameData.MyPlayer.Username + "\""));
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.PlayerJoinedLobby, packetData, Protocol.NA));
            break;

        case NetworkCode.PlayerLeftLobby:
            SendingPacket = NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.PlayerLeftLobby, packetData, Protocol.NA);
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.PlayerLeftLobby, packetData, Protocol.NA));
            break;

        case NetworkCode.GameStart:
            SendingPacket = NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.GameStart, packetData, Protocol.NA);
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.GameStart, packetData, Protocol.NA));
            break;

        // NOTE:: Send packet indicating the team that slected the aman
        case NetworkCode.AmanSelection:
            packetData.Add(new Pair <string, string>(NetworkKeyString.TeamID, GameData.MyPlayer.TeamID.ToString()));
            packetData.Add(new Pair <string, string>(NetworkKeyString.AmanID, GameData.AllyKingID.ToString()));
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.AmanSelection, packetData, Protocol.NA));
            break;

        case NetworkCode.ThemeSelection:
            packetData.Add(new Pair <string, string>(NetworkKeyString.Theme, ((int)GameData.CurrentTheme).ToString()));
            Send(NetworkingManager.send_next_packet(DataType.Lobby, (int)NetworkCode.ThemeSelection, packetData, Protocol.NA));
            break;
        }
    }
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #24
0
    /*------------------------------------------------------------------------------------------------------------------
     * -- FUNCTION:     SendMessageToServer
     * -- DATE:         April 1, 2016
     * -- REVISIONS:    N/A
     * -- DESIGNER:    Krystle Bulalakaw
     * -- PROGRAMMER:  Krystle Bulalakaw
     * -- INTERFACE:    void SendMessageToServer(List<Pair<string, string>> msg, int eventType)
     * --                      List<Pair<string, string>> msg - the message to send
     * --                      int eventType                  - the map event type
     * -- RETURNS:  List<Pair<string, string>>   - List of map event data
     * -- NOTES:
     * -- Sends a message to the server via Networking Manager's send_next_packet call.
     * ----------------------------------------------------------------------------------------------------------------------*/
    void SendMessageToServer(List <Pair <string, string> > msg, int eventType)
    {
        var    packet = NetworkingManager.send_next_packet(DataType.Environment, eventType, msg, Protocol.TCP);
        string temp   = "[" + packet + "]";       // Wrap JSON child into array

        // Fakes network data updates for local testing. Comment this line when actually testing on network.
        if (Application.platform != RuntimePlatform.LinuxPlayer)
        {
            NetworkingManager.instance.update_data(temp);
        }
    }
	// Use this for initialization
	void Start () {
		//Check if instance already exists
		if (instance == null)				
			//if not, set instance to this
			instance = this;				
		//If instance already exists and it's not this:
		else if (instance != this)			
			//Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
			Destroy(gameObject);   		
        networkingManager = GetComponent<NetworkingManager>();
	}
Beispiel #26
0
 protected override void LoadContent()
 {
     bannerManager     = new BannerManager(Content, GraphicsDevice);
     animationManager  = new AnimationManager(Content);
     tileManager       = new TileManager(Content, bannerManager);
     networkingManager = new NetworkingManager(bannerManager, tileManager, animationManager, Content.Load <SpriteFont>(@"Fonts\font"));
     fpsMonitor        = new FpsMonitor(Content.Load <SpriteFont>(@"Fonts\font"), new Vector2(10, 10));
     menuManager       = new MenuManager(Content, bannerManager, networkingManager);
     screenshotManager = new ScreenshotManager(GraphicsDevice, Content.Load <SpriteFont>(@"Fonts\font"));
     spriteBatch       = new SpriteBatch(GraphicsDevice);
 }
Beispiel #27
0
    // Use this for initialization
    void Start()
    {
        if (!NetworkingManager.Connected)
        {
            NetworkingManager.Connect();
        }

        NetworkingManager.MessageReceived += networkingManager_MessageReceived;

        ScoreText.text = ScoreManager.LatestScore.ToString();
    }
Beispiel #28
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Beispiel #29
0
 private void Start()
 {
     myDataConfirmed         = false;
     readyToTurnWheel        = false;
     otherPlayerDataReceived = false;
     _turnState   = TurnState.none;
     _clientState = ClientState.none;
     nm           = ServiceLocator.GetService <NetworkingManager>();
     ConnectToTcpServer();
     MessageReceived += nm.DecodeMessage;
 }
 public void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Beispiel #31
0
    // Use this for initialization
    void Start()
    {
        if (!NetworkingManager.Connected)
        {
            NetworkingManager.Connect();
        }

        NetworkingManager.MessageReceived += networkingManager_MessageReceived;

        UserText.text = UserManager.Name;
        StartCoroutine("LoadProfilePicture", UserPictureTexture);
    }
Beispiel #32
0
 /*-----------------------------------------------------------------------------------------------------------------
 *  -- FUNCTION: Update
 *  --
 *  -- DATE: April 04, 2016
 *  --
 *  -- DESIGNER: Spenser Lee
 *  --
 *  -- PROGRAMMER: Spenser Lee
 *  --
 *  -- INTERFACE: void Update()
 *  --
 *  -- RETURNS: void
 *  --
 *  -- NOTES:
 *  -- Called once per frame. Waits for new incoming network messages and will update the lobby list if changes are
 *  -- made. (e.g. new player, team changes etc.)
 *  -----------------------------------------------------------------------------------------------------------------*/
 void Update()
 {
     if (LobbyNetwork.connected)
     {
         string tmp = Marshal.PtrToStringAnsi(NetworkingManager.TCP_GetData());
         if (!String.Equals(tmp, "[]"))
         {
             LobbyNetwork.ParseLobbyData(tmp);
             UpdateLobbyList();
         }
     }
 }
Beispiel #33
0
    void Start()
    {
        if (!Application.isEditor && FB.IsLoggedIn)
        {
            FB.API("/me", Facebook.HttpMethod.GET, OnGetMe);
        }
        else
        {
            PersonalName.text = "Player Name";
        }

        networkingManager = GameObject.Find("Networking Manager").GetComponent<NetworkingManager>();
        networkingManager.MessageReceived += networkingManager_MessageReceived;
    }
 void Awake()
 {
     // If this is the first instance, make it the singleton. If a singleton already exists and another reference is found, destroy it
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != instance)
             Destroy(this.gameObject);
     }
 }
Beispiel #35
0
    // Use this for initialization
    void Start()
    {
        GameObject networkingManagerObject = GameObject.Find("Networking Manager");

        if (networkingManagerObject == null)
        {
            Debug.LogWarning("Couldn't find the Networking Manager. Proceeding without networking...");
        }
        else
        {
            networkingManager = networkingManagerObject.GetComponent<NetworkingManager>();
            networkingManager.MessageReceived += networkingManager_MessageReceived;
        }

        round = Instantiate(RoundPrefab) as Round;
    }
    /*
     * Start this script
     */
    public void StartMe()
    {
        StartPlaying();

        /* Set ourselves to be waiting for other players to join */
        PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() {
                {"waiting", true}
        });
        InitialNumberOfTurns = RoundsLeftUntilLose;

        /* Load everything necessary for waiting for other players to load */
        waitingCanvas = Resources.Load<GameObject>("Prefabs/UIPrefabs/WaitingCanvas");
        networkingManager = Object.FindObjectOfType<NetworkingManager>(); // Networking manager
        if (Application.loadedLevelName != "Tutorial")
        instantiatedCanvas = Instantiate(waitingCanvas); // Create UI to block player from doing anything
        readyPlayers.Add(PhotonNetwork.player); // We have already instantiated our player

        /* Send an RPC to master client to tell a player to select their class */
        if (!(bool)(PhotonNetwork.masterClient.customProperties["waiting"])) // Master client is in match maker
            GetComponent<PhotonView>().RPC("MatchMakerSendPlayerToClassSelect", PhotonNetwork.masterClient, null);
        else // Master client is in the same scene already
            GetComponent<PhotonView>().RPC("GameManagerSendPlayerToClassSelect", PhotonNetwork.masterClient, null);
    }