Ejemplo n.º 1
0
        public List <IRoomInformations> GetAllRoomUpdatesSinceLastTimeChecked(string ServerVersion)
        {
            DateTime CurrentTime = DateTime.Now;
            FilterDefinition <BsonDocument> LastTimeCheckedFilter = Builders <BsonDocument> .Filter.Gte("LastUpdate", LastTimeChecked);

            List <BsonDocument>      ListFoundRoomDocument = RoomsCollection.Find(LastTimeCheckedFilter).ToList();
            List <IRoomInformations> ListFoundRoom         = new List <IRoomInformations>();

            foreach (BsonDocument ActiveDocument in ListFoundRoomDocument)
            {
                string RoomID             = ActiveDocument.GetValue("_id").AsObjectId.ToString();
                string RoomName           = ActiveDocument.GetValue("RoomName").AsString;
                string Password           = ActiveDocument.GetValue("Password").AsString;
                string OwnerServerIP      = ActiveDocument.GetValue("OwnerServerIP").AsString;
                int    OwnerServerPort    = ActiveDocument.GetValue("OwnerServerPort").AsInt32;
                int    CurrentPlayerCount = ActiveDocument.GetValue("CurrentPlayerCount").AsInt32;
                int    MaxNumberOfPlayer  = ActiveDocument.GetValue("MaxNumberOfPlayer").AsInt32;
                bool   IsDead             = ActiveDocument.GetValue("IsDead").AsBoolean;

                IRoomInformations NewRoom = new RoomInformations(RoomID, RoomName, Password, OwnerServerIP, OwnerServerPort, CurrentPlayerCount, MaxNumberOfPlayer, IsDead);
                ListFoundRoom.Add(NewRoom);
            }

            LastTimeChecked = CurrentTime;
            return(ListFoundRoom);
        }
 public PlayerLeftScriptClient(RoomInformations Owner, BattleMapOnlineClient Client, GamePreparationScreen MissionSelectScreen)
     : base(ScriptName)
 {
     this.Owner  = Owner;
     this.Client = Client;
     this.MissionSelectScreen = MissionSelectScreen;
 }
Ejemplo n.º 3
0
 public PlayerLeftScriptClient(RoomInformations Owner, TripleThunderOnlineClient Client, IMissionSelect MissionSelectScreen)
     : base(ScriptName)
 {
     this.Owner  = Owner;
     this.Client = Client;
     this.MissionSelectScreen = MissionSelectScreen;
 }
Ejemplo n.º 4
0
        protected override void Execute(IOnlineConnection Sender)
        {
            base.Execute(Sender);

            RoomInformations NewRoom = (RoomInformations)CreatedGroup.Room;

            foreach (IOnlineConnection ActivePlayer in CreatedGroup.Room.ListOnlinePlayer)
            {
                //Add Game Specific scripts
                Dictionary <string, OnlineScript> DicNewScript = new Dictionary <string, OnlineScript>();
                if (NewRoom.RoomType == RoomInformations.RoomTypeMission)
                {
                    MissionRoomInformations MissionRoom = (MissionRoomInformations)NewRoom;

                    DicNewScript.Add(AskStartGameMissionScriptServer.ScriptName, new AskStartGameMissionScriptServer(MissionRoom, (TripleThunderClientGroup)CreatedGroup, Owner));
                    DicNewScript.Add(AskChangeRoomExtrasMissionScriptServer.ScriptName, new AskChangeRoomExtrasMissionScriptServer(MissionRoom));
                }
                else if (NewRoom.RoomType == RoomInformations.RoomTypeBattle)
                {
                    BattleRoomInformations BattleRoom = (BattleRoomInformations)NewRoom;

                    DicNewScript.Add(AskStartGameMissionScriptServer.ScriptName, new AskStartGameBattleScriptServer(BattleRoom, (TripleThunderClientGroup)CreatedGroup, Owner));
                    DicNewScript.Add(AskChangeRoomExtrasBattleScriptServer.ScriptName, new AskChangeRoomExtrasBattleScriptServer(BattleRoom));
                }

                DicNewScript.Add(AskChangeCharacterScriptServer.ScriptName, new AskChangeCharacterScriptServer(NewRoom));
                DicNewScript.Add(AskChangePlayerTypeScriptServer.ScriptName, new AskChangePlayerTypeScriptServer(NewRoom));
                DicNewScript.Add(AskChangeTeamScriptServer.ScriptName, new AskChangeTeamScriptServer(NewRoom));
                DicNewScript.Add(AskChangeMapScriptServer.ScriptName, new AskChangeMapScriptServer(NewRoom, Owner));
                DicNewScript.Add(AskChangeRoomSubtypeScriptServer.ScriptName, new AskChangeRoomSubtypeScriptServer(NewRoom));
                DicNewScript.Add(LeaveRoomScriptServer.ScriptName, new LeaveRoomScriptServer(NewRoom, Owner));
                ActivePlayer.AddOrReplaceScripts(DicNewScript);
            }
        }
Ejemplo n.º 5
0
        private void btnJoinRoom_Click(object sender, System.EventArgs e)
        {
            gbRooms.Enabled      = false;
            gbRoomInfo.Enabled   = true;
            btnStartGame.Enabled = false;

            if (lstRooms.SelectedIndex >= 0)
            {
                RoomInformations ActiveRoom = (RoomInformations)lstRooms.SelectedItem;
                OnlineClient.JoinRoom(ActiveRoom.RoomID);
            }
        }
Ejemplo n.º 6
0
        public static Dictionary <string, OnlineScript> GetRoomScriptsServer(RoomInformations NewRoom, GameServer Owner)
        {
            Dictionary <string, OnlineScript> DicNewScript = new Dictionary <string, OnlineScript>();

            DicNewScript.Add(AskChangeCharacterScriptServer.ScriptName, new AskChangeCharacterScriptServer(NewRoom));
            DicNewScript.Add(AskChangePlayerTypeScriptServer.ScriptName, new AskChangePlayerTypeScriptServer(NewRoom));
            DicNewScript.Add(AskChangeTeamScriptServer.ScriptName, new AskChangeTeamScriptServer(NewRoom));
            DicNewScript.Add(AskChangeMapScriptServer.ScriptName, new AskChangeMapScriptServer(NewRoom, Owner));
            DicNewScript.Add(AskChangeRoomSubtypeScriptServer.ScriptName, new AskChangeRoomSubtypeScriptServer(NewRoom));
            DicNewScript.Add(LeaveRoomScriptServer.ScriptName, new LeaveRoomScriptServer(NewRoom, Owner));

            return(DicNewScript);
        }
Ejemplo n.º 7
0
    public void Teleport(string DoorName)
    {
        RoomInformations nextRoom = ReturnRoomDest(DoorName);

        distanceOfTheCamera = CalculateDistBtwCamToDoor(DoorName);
        if (!inRespawn)
        {
            StartCoroutine(Respawn(ReturnDoorDest(DoorName).transform, nextRoom, ReturnAccessDoor(DoorName).transform));
            if (DoorList.Find(x => x.AccessDoor.name == DoorName).teleportSound != null)
            {
                AudioManager.Instance.PlaySound(DoorList.Find(x => x.AccessDoor.name == DoorName).teleportSound);
            }
        }
    }
Ejemplo n.º 8
0
 public void UpdatePlayerCountInRoom(string RoomID, byte CurrentPlayerCount)
 {
     foreach (List <RoomInformations> ListRoomInfo in ListRoom.Values)
     {
         for (int i = 0; i < ListRoomInfo.Count; i++)
         {
             RoomInformations ActiveRoom = ListRoomInfo[i];
             if (ActiveRoom.RoomID == RoomID)
             {
                 ActiveRoom.CurrentPlayerCount = CurrentPlayerCount;
                 return;
             }
         }
     }
 }
Ejemplo n.º 9
0
    IEnumerator Respawn(Transform FinalDestTrans, RoomInformations FinalDestRoom, Transform AccessDoor)
    {
        if (!inRespawn)
        {
            inRespawn = true;
            fadePanel.GetComponent <Animator>().SetBool("FadeIn", true);
            Camera.main.GetComponent <BoxCollider2D>().enabled = false;
            yield return(new WaitForSeconds(0.3f));

            fadePanel.GetComponent <Animator>().SetBool("FadeIn", false);
            if (FinalDestRoom.roomTheme != null && FinalDestRoom.roomTheme != GameObject.Find("AudioManager").GetComponent <AudioSource>().clip)
            {
                GameObject.Find("AudioManager").GetComponent <AudioSource>().clip = FinalDestRoom.roomTheme;
                GameObject.Find("AudioManager").GetComponent <AudioSource>().Play();
            }
            FinalDestRoom.gameObject.SetActive(true);
            player.transform.position = CalculateDestPos(FinalDestTrans, AccessDoor);
            player.GetComponent <MovementsPlayer>().canRun = FinalDestRoom.canRun;

            //if (!internTeleport)
            //{
            //    transform.parent.parent.gameObject.SetActive(false);
            //    linkedWith.transform.parent.parent.GetComponent<SceneInformations>().ShowZoneName();
            //}
            //FinalDestRoom.PlaceCamera();
            if (!FinalDestRoom.staticCamera)
            {
                Camera.main.GetComponent <CameraFollow>().actualRoom = FinalDestRoom.gameObject;
                Camera.main.GetComponent <CameraFollow>().InitRoomLimit();
                Camera.main.GetComponent <BoxCollider2D>().enabled = true;
                Camera.main.transform.position = new Vector3(FinalDestRoom.transform.position.x + distanceOfTheCamera, player.transform.position.y + FinalDestRoom.YOffset, player.transform.position.z - FinalDestRoom.distBtwPlAndCam);
                Camera.main.GetComponent <CameraFollow>().YOffset     = FinalDestRoom.YOffset;
                Camera.main.GetComponent <CameraFollow>().barrier     = "none";
                Camera.main.GetComponent <CameraFollow>().collision   = false;
                Camera.main.GetComponent <CameraFollow>().isFollowing = true;
            }
            else
            {
                Camera.main.GetComponent <CameraFollow>().actualRoom = FinalDestRoom.gameObject;
                Camera.main.GetComponent <CameraFollow>().InitRoomLimit();
                Camera.main.transform.position = FinalDestRoom.CameraSpot.position;
                Camera.main.GetComponent <CameraFollow>().isFollowing = false;
            }
            inRespawn = false;
        }
    }
        protected override void Execute(IOnlineConnection Sender)
        {
            base.Execute(Sender);

            RoomInformations NewRoom = (RoomInformations)CreatedGroup.Room;

            foreach (IOnlineConnection ActivePlayer in CreatedGroup.Room.ListOnlinePlayer)
            {
                //Add Game Specific scripts
                Dictionary <string, OnlineScript> DicNewScript = new Dictionary <string, OnlineScript>();
                DicNewScript.Add(AskStartGameScriptServer.ScriptName, new AskStartGameScriptServer(CreatedGroup));
                DicNewScript.Add(LeaveRoomScriptServer.ScriptName, new LeaveRoomScriptServer(NewRoom, Owner.OnlineServer));
                ActivePlayer.AddOrReplaceScripts(DicNewScript);
            }

            AddRoom();
        }
Ejemplo n.º 11
0
        public IRoomInformations GenerateNewRoom(string RoomName, string Password, string OwnerServerIP, int OwnerServerPort)
        {
            BsonDocument document = new BsonDocument
            {
                { "LastUpdate", DateTime.Now },
                { "RoomName", RoomName },
                { "Password", Password },
                { "OwnerServerIP", OwnerServerIP },
                { "OwnerServerPort", OwnerServerPort },
                { "CurrentPlayerCount", 1 },
                { "MaxNumberOfPlayer", 3 },
                { "IsDead", false },
            };

            RoomsCollection.InsertOne(document);

            RoomInformations NewRoom = new RoomInformations(document.GetValue("_id").AsObjectId.ToString(), RoomName, OwnerServerIP, OwnerServerPort);

            return(NewRoom);
        }
Ejemplo n.º 12
0
 public AskChangePlayerTypeScriptServer(RoomInformations Owner)
     : base(ScriptName)
 {
     this.Owner = Owner;
 }
Ejemplo n.º 13
0
 public AskChangeMapScriptServer(RoomInformations Owner, GameServer OnlineServer)
     : base(ScriptName)
 {
     this.Owner        = Owner;
     this.OnlineServer = OnlineServer;
 }
Ejemplo n.º 14
0
 public ChangeTeamScriptClient(RoomInformations Owner)
     : base(ScriptName)
 {
     this.Owner = Owner;
 }
 public AskChangeCharacterScriptServer(RoomInformations Owner)
     : base(ScriptName)
 {
     this.Owner = Owner;
 }
 public ChangeCharacterScriptClient(RoomInformations Owner, IMissionSelect MissionSelectScreen)
     : base(ScriptName)
 {
     this.Owner = Owner;
     this.MissionSelectScreen = MissionSelectScreen;
 }
 public AskChangeLoadoutScriptServer(RoomInformations Owner)
     : base(ScriptName)
 {
     this.Owner = Owner;
 }
Ejemplo n.º 18
0
        protected override void OnJoinRoomLocal(IOnlineConnection Sender, string RoomID, GameClientGroup ActiveGroup)
        {
            RoomInformations JoinedRoom            = (RoomInformations)ActiveGroup.Room;
            List <Player>    ListJoiningPlayerInfo = JoinedRoom.GetOnlinePlayer(Sender);

            foreach (IOnlineConnection ActivePlayer in ActiveGroup.Room.ListOnlinePlayer)
            {
                if (ActivePlayer == Sender)
                {
                    continue;
                }

                ActivePlayer.Send(new PlayerJoinedScriptServer(ListJoiningPlayerInfo));
            }

            Dictionary <string, OnlineScript> DicNewScript = OnlineHelper.GetRoomScriptsServer(JoinedRoom, Owner);

            if (JoinedRoom.RoomType == RoomInformations.RoomTypeMission)
            {
                MissionRoomInformations MissionRoom = (MissionRoomInformations)JoinedRoom;

                DicNewScript.Add(AskStartGameMissionScriptServer.ScriptName, new AskStartGameMissionScriptServer(MissionRoom, (TripleThunderClientGroup)ActiveGroup, Owner));
                DicNewScript.Add(AskChangeRoomExtrasMissionScriptServer.ScriptName, new AskChangeRoomExtrasMissionScriptServer(MissionRoom));
            }
            else if (JoinedRoom.RoomType == RoomInformations.RoomTypeBattle)
            {
                BattleRoomInformations BattleRoom = (BattleRoomInformations)JoinedRoom;

                DicNewScript.Add(AskStartGameMissionScriptServer.ScriptName, new AskStartGameBattleScriptServer(BattleRoom, (TripleThunderClientGroup)ActiveGroup, Owner));
                DicNewScript.Add(AskChangeRoomExtrasBattleScriptServer.ScriptName, new AskChangeRoomExtrasBattleScriptServer(BattleRoom));
            }
            Sender.AddOrReplaceScripts(DicNewScript);

            if (ActiveGroup.CurrentGame != null)
            {
                FightingZone CurrentGame = (FightingZone)ActiveGroup.CurrentGame;

                foreach (Player ActivePlayer in ListJoiningPlayerInfo)
                {
                    CurrentGame.AddLocalCharacter(ActivePlayer);
                    ActivePlayer.OnlineClient = Sender;

                    int LayerIndex;
                    CurrentGame.AddPlayerFromSpawn(ActivePlayer, CurrentGame.NextRobotID + (uint.MaxValue - 100), true, out LayerIndex);

                    //Add Game Specific scripts
                    DicNewScript = OnlineHelper.GetTripleThunderScriptsServer((TripleThunderClientGroup)ActiveGroup, ActivePlayer);
                    Sender.AddOrReplaceScripts(DicNewScript);

                    foreach (IOnlineConnection OtherPlayer in ActiveGroup.Room.ListOnlinePlayer)
                    {
                        if (OtherPlayer == Sender)
                        {
                            continue;
                        }

                        OtherPlayer.Send(new CreatePlayerScriptServer(ActivePlayer, LayerIndex, false));
                    }
                }
            }

            Sender.Send(new JoinRoomLocalScriptServer(RoomID, JoinedRoom.CurrentDifficulty, ListJoiningPlayerInfo, ActiveGroup));
        }
 public ChangeLoadoutScriptClient(RoomInformations Owner, GamePreparationScreen MissionSelectScreen)
     : base(ScriptName)
 {
     this.Owner = Owner;
     this.MissionSelectScreen = MissionSelectScreen;
 }