public void OnMapChanged(int newMap)
 {
     if (SocketConnection.GetIsServer())
     {
         orig_OnMapChanged(newMap); // Prevent the client from changing their map with the sidebar
     }
 }
예제 #2
0
 public bool CanStartGame()
 {
     if (!SocketConnection.GetIsServer()) // Prevent the client from starting the game, since the host is in charge
     {
         return(false);
     }
     return(orig_CanStartGame());
 }
예제 #3
0
        public override bool CanRemove(Unit unit)
        {
            bool isServer = SocketConnection.GetIsServer();

            return((isServer && !SocketConnection.getTcpClient().Connected) ||
                   (unit.Team == (isServer ? Team.Red : Team.Blue)) && !SocketConnection.gameStarted);
            // Make sure that each client can only remove on their position if it's connected
        }
 public static new void LoadMap(MapAsset map)
 {
     if (SocketConnection.GetIsServer())
     {
         SocketConnection.WriteToOpponent("LOADMAP|" + map.m_mapIndex); // Send the current map's ID
     }
     //SocketConnection.WriteToUI("SHOWMSG|Loading map " + map.m_mapIndex + " " + map.MapName); // Debug
     orig_LoadMap(map); // Call orig function
 }
예제 #5
0
 public new void ClearRed()
 {
     if (!SocketConnection.GetIsServer()) // Prevent the opponent from clearing the host's warriors
     {
         return;
     }
     orig_ClearRed(); // The host can clear both areas by the way
     SocketConnection.WriteToOpponent("CLEAR|true");
 }
예제 #6
0
        public override bool CanPlace(UnitBlueprint unitToSpawn, Team team, ref Vector3 position)
        {
            bool isServer = SocketConnection.GetIsServer();

            return(base.CanPlace(unitToSpawn, team, ref position) &&
                   ((isServer && !SocketConnection.getTcpClient().Connected) ? true :
                    (GetTeamAreaAtPosition(position) == (isServer ? Team.Red : Team.Blue) && !SocketConnection.gameStarted)));
            // Make sure that each client can only place on their position if it's connected
        }
예제 #7
0
        public override void CursorUpdate(Vector3 position)
        {
            base.CursorUpdate(position);
            bool isServer = SocketConnection.GetIsServer();

            if (!(isServer && !SocketConnection.getTcpClient().Connected) &&
                GetTeamAreaAtPosition(position) != (isServer ? Team.Red : Team.Blue))
            {
                base.PlacementCursor.Renderer.material = base.PlacementCursorVisuals.DenyPlaceMaterial;
            }
            // Show a block icon if the cursor hovers over the opponent if it's connected
        }
 public IEnumerator Play(SoundEffectInstance soundEffect, AudioPlayer player, float volumeMultiplier,
                         Vector3 position, SoundEffectVariations.MaterialType materialType, Transform transformToFollow) // Hook this method for audio sharing
 {
     if (SocketConnection.GetIsServer() && SocketConnection.gameStarted)
     {
         SocketConnection.SetCulture();
         Vector3 distance = position == Vector3.zero ? position : Camera.main.transform.position - position; // Get the relative position from the camera
         string  tosend   = "AUDIO|" + GetCategory(soundEffect) + "/" + soundEffect.soundRef + "|" +
                            volumeMultiplier + "|" + distance.ToString("F5") + "|" + materialType.ToString();
         SocketConnection.WriteToOpponent(tosend); // Transfer the sound
     }
     return(orig_Play(soundEffect, player, volumeMultiplier, position, materialType, transformToFollow));
 }