Example #1
0
        private void CustomPlayer_OnMusicStart(object sender, MusicEventArgs e)
        {
            if (!this.SelectedPlayList.Equals(this.PlayingPlayList))
            {
                return;
            }
            if (!IsAdd)
            {
                this.MusicContainer.MusicPlay = this.MusicContainer.playList.musics.First((musicNotify) =>
                {
                    return(musicNotify.musics.Equals(e.music));
                });
            }
            savePlayList?.Invoke(this.PlayListCollections);
            count_music += 1;
            if (count_music >= 5 && this.AD && !IsAdd)
            {
                CustomPlayer.Visibility = Visibility.Hidden;
                CustomPlayer.IsEnabled  = false;
                CustomPlayer.Stop();

                CustomPlayerAd.Visibility = Visibility.Visible;
                CustomPlayerAd.IsEnabled  = false;
                CustomPlayerAd.SetMusic(this.AdMusic);
                CustomPlayerAd.Play();

                IsAdd = true;
            }
        }
Example #2
0
 //TODO : Correct the false condition
 private void OnEventJoin(CustomPlayer customPlayer)
 {
     if (!GameManager.Instance.gameStarted && _logic.GetLocalPlayerId() == 0)
     {
         GameUIManager.Instance.ChangeUIState(GameUIManager.GameUIState.GAME_LOBBY);
     }
 }
Example #3
0
        public static EntityPlaceHolder GetEntity(this string line, Room room, List <CustomPlayer> customEntities)
        {
            string[] words = line.Split(' ');
            switch (words[0])
            {
            case "Door":
                string name  = words[1];
                Point  point = GetPoint(words[2], words[3]);
                //bool blocking = GetBool(words[4]); Not needed for door
                int    id       = words[5].GetInt();
                bool   unlinked = words[6].GetBool();
                string roomName = "";
                int    doorId   = 0;
                if (!unlinked)
                {
                    roomName = words[7];
                    doorId   = words[8].GetInt();
                }
                return(new DoorPlaceHolder((roomName, doorId), room.name, point, id));

            case "Troop":
                name  = words[5];
                point = GetPoint(words[2], words[3]);
                string       type   = words[1];
                CustomPlayer player = (CustomPlayer)customEntities.First(c => c.Name == type).Clone();
                player.troop.Name     = name;
                player.troop.Position = point;
                player.Name           = name;
                return(new PlayerPlaceHolder(player));

            default:
                throw new NotImplementedException(line);
            }
        }
Example #4
0
        public static async void OnEnterLoginData(CustomPlayer player, Dictionary <string, string> loginData)
        {
            var col      = Context.MongoDB.GetCollection <AccountData>("accounts");
            var email    = loginData["email"];
            var password = loginData["password"];

            try {
                var filter = Builders <AccountData> .Filter.Eq("Email", email);

                var res = await col.Find(filter).Limit(1).SingleOrDefaultAsync();

                if (res == null)
                {
                    player.Emit("auth:loginFailed", "account doesn't exist");
                    return;
                }
                var isPasswordCorrect = PasswordHasher.VerifyHash(password, res !.Salt, res !.Password);
                if (isPasswordCorrect)
                {
                    player.Emit("auth:loginSuccess");
                    player.LoggedIn = true;
                    player.Data     = res;
                    spawnPlayer(player, 0);
                    return;
                }
            } catch (Exception e) {
                Alt.Log(e.ToString());
                player.Emit("auth:loginFailed", e.Message);
            }
        }
Example #5
0
        public static async void OnPlayerDead(CustomPlayer player, CustomPlayer killer, uint reason)
        {
            spawnPlayer(player, 2000);
            await Task.Delay(2000);

            player.Emit("player:onSpawn");
        }
Example #6
0
 public Player(string playerName, Classe classe, Faction faction, CustomPlayer customPlayer)
 {
     this.playerName   = playerName;
     this.classe       = classe;
     this.customPlayer = customPlayer;
     this.faction      = faction;
 }
Example #7
0
 public override void GetWeaponDamage(Player player, ref int damage)
 {
     if (this.holy)
     {
         CustomPlayer modPlayer = player.GetModPlayer <CustomPlayer>(mod);
         damage = (int)(modPlayer.holyPower * damage);
     }
 }
Example #8
0
        public void SaveAndLoadCustomPlayer()
        {
            CustomPlayer customPlayer = new CustomPlayer("test", "enemyScout", Weapon.Fist, 0);

            Assert.IsNotNull(customPlayer);
            Assert.IsTrue(customPlayer.Save(@"./customPlayer.txt"));
            customPlayer = CustomPlayer.Load(@"./customPlayer.txt");
            Assert.IsNotNull(customPlayer);
            Assert.AreEqual("test", customPlayer.Name);
        }
Example #9
0
        public void SaveAndLoadCustomPlayerWithData()
        {
            CustomPlayer customPlayer = new CustomPlayer("complex", "enemyScout", Weapon.Fist, 0)
            {
                XP = 5
            };

            Assert.IsTrue(customPlayer.Save(@"./c.txt"));
            customPlayer = CustomPlayer.Load(@"./c.txt");
            Assert.IsNotNull(customPlayer);
            Assert.AreEqual(5, customPlayer.XP);
        }
Example #10
0
    public Player()
    {
        Classe classe = new Classe(Archetype.Guerrier);

        this.classe = classe;
        Faction faction = new Faction(FactionName.Empire);

        this.faction = faction;
        customPlayer = new CustomPlayer();
        customPlayer.isSpecialCharacter = false;
        customPlayer.specialsCharacters = SpecialsCharacters.None;
    }
Example #11
0
        private void VisibilitySelectedPlayList()
        {
            if (this.PlayListCollections.IndexOf(this.SelectedPlayList) == -1)
            {
                return;
            }

            this.MusicContainer.playList  = this.SelectedPlayList;
            this.MusicContainer.MusicPlay = this.MusicContainer.playList.musics.FirstOrDefault((musicNotify) =>
            {
                return(musicNotify.musics.Equals(CustomPlayer.getNowMusic()));
            });
        }
Example #12
0
        private void CustomPlayerAd_OnMusicEnded(object sender, MusicEventArgs e)
        {
            if (IsAdd)
            {
                CustomPlayerAd.Visibility = Visibility.Hidden;
                CustomPlayerAd.IsEnabled  = false;
                CustomPlayerAd.Stop();

                CustomPlayer.Visibility = Visibility.Visible;
                CustomPlayer.IsEnabled  = true;
                CustomPlayer.Play();

                IsAdd       = false;
                count_music = 0;
            }
        }
Example #13
0
        public unsafe void SetPlayer(CustomPlayer player)
        {
            MusicPlayerFunc mp = (IntPtr ud, byte *stream, int length) =>
            {
                var sp = new Span <byte>(stream, length);
                try
                {
                    player(sp);
                }
                catch (Exception e)
                {
                    SDL.OnUnhandledException(e, true);
                }
            };

            Mix_HookMusic(Marshal.GetFunctionPointerForDelegate(mp), IntPtr.Zero);
            mfp = mp;
        }
Example #14
0
        private void MusicContainer_OnSearch(string name)
        {
            var reg    = new Regex(name);
            var musics = new ObservableCollection <MusicNotifyChanged>();

            foreach (var musicNotifyChanged in this.SelectedPlayList.musics)
            {
                if (reg.IsMatch(musicNotifyChanged.musics.name))
                {
                    musics.Add(musicNotifyChanged);
                }
            }
            this.MusicContainer.playList = new PlayListCollection {
                name = "Поиск", musics = musics
            };
            this.MusicContainer.MusicPlay = this.MusicContainer.playList.musics.FirstOrDefault((musicNotify) =>
            {
                return(musicNotify.musics.Equals(CustomPlayer.getNowMusic()));
            });
        }
Example #15
0
    /// <summary>Use this to add a new Player to the List.</summary>
    public void Add(CustomPlayer newPlayer)
    {
        int m_index = -1;

        //if a CustomPlayer contains newPlayer means hee already exists
        //lets just update him
        m_index = m_customPlayerList.FindIndex(x => x.PhotonPlayer == newPlayer.PhotonPlayer);

        if (m_index != -1)
        {
            CustomPlayer m_updatedPlayer = m_customPlayerList[m_index];
            m_updatedPlayer.PhotonView   = newPlayer.PhotonView;
            m_updatedPlayer.PlayerObject = newPlayer.PlayerObject;
            m_customPlayerList[m_index]  = m_updatedPlayer;
            return;
        }

        m_customPlayerList.Add(newPlayer);
        Debug.LogFormat("Added {0} to PlayerList. ", newPlayer.PhotonPlayer.NickName);
    }
Example #16
0
    /// <summary>
    /// Handler for "Player Leaved" Event
    /// </summary>
    /// <param name="CustomPlayer">Player that leaved the game</param>
    private void OnLeavedPlayer(CustomPlayer CustomPlayer)
    {
        string name = CustomPlayer.NickName;

        foreach (GameObject playerObject in playerObjects)
        {
            if (playerObject.name == name)
            {
                remotePlayers.Remove(name);
                playerObjects.Remove(playerObject);
                Object.Destroy(playerObject);
                return;
            }
        }

        if (!GameManager.Instance.gameStarted)
        {
            UpdateBasePositions();
            UpdateBaseColors();
            UpdateBaseNames();
        }
    }
Example #17
0
        public static async void OnEnterRegisterData(CustomPlayer player, Dictionary <string, string> registerData)
        {
            if (player.LoggedIn)
            {
                return;
            }
            var pData = new AccountData();

            pData.Email = registerData["email"];
            pData.Login = registerData["login"];
            var passAndSalt = PasswordHasher.CreatePasswordHash(registerData["password"]);

            pData.Password = passAndSalt.Item1;
            pData.Salt     = passAndSalt.Item2;
            try
            {
                pData.Save();
            }
            catch (MongoWriteException e)
            {
                Alt.Log(e.ToString());
                if (e.WriteError.Code == 11000)
                {
                    player.Emit("auth:registerFailed", 0, "Player with such email or login already exists!");
                }
                else
                {
                    player.Emit("auth:registerFailed", 1, e.Message);
                }
                return;
            }
            player.LoggedIn = true;
            player.Data     = pData;
            player.Emit("auth:registerSuccess");

            player.Model = (uint)PedModel.FreemodeMale01;
            spawnPlayer(player, 0);
        }
Example #18
0
        public void SaLDungeonWithCustomEntities()
        {
            Dungeon dungeon = new Dungeon("SpiderTest");

            dungeon.active.map.map[0, 0].type = new MapTileType()
            {
                type = MapTileTypeEnum.land
            };
            dungeon.active.map.map[0, 0].free = true;
            CustomPlayer item = new CustomPlayer("spider", "spiderWarrior", Weapon.Fist, 0);

            item.troop.Position = new Point(0, 0);
            dungeon.customEntities.Add((CustomPlayer)item.Clone());
            dungeon.active.AddEntity(item.troop);

            Assert.IsTrue(dungeon.Save(true));

            dungeon = Dungeon.Load("SpiderTest");
            Assert.IsNotNull(dungeon);
            Assert.IsNotNull(dungeon.customEntities);
            Assert.IsTrue(dungeon.customEntities.Count == 1);
            Assert.IsTrue(dungeon.customEntities[0].Name == "spider");
            Assert.IsTrue(dungeon.active.map.entities.Count == 1);
        }
Example #19
0
        public MainWindow()
        {
            InitializeComponent();
            string   directory = Environment.CurrentDirectory + "\\..\\..\\";
            Playlist list      = new Playlist(new List <Music>
            {
                new Music {
                    source = new Uri(directory + "audioTest/Artik.mp3"), name = "Artik 2.0"
                },
                new Music {
                    source = new Uri(directory + "audioTest/Rasa.mp3"), sourceImg = new Uri("https://img1.goodfon.ru/wallpaper/nbig/8/b9/ssha-shtat-kaliforniya-gorod-2279.jpg")
                },
                new Music {
                    source = new Uri(directory + "audioTest/MATRANG.mp3")
                },
                new Music {
                    source = new Uri(directory + "audioTest/Rakhim.mp3"), name = "Dance", sourceImg = new Uri(directory + "imgTest/slon.jpg")
                },
            });

            CustomPlayer.SetPlayList(list);
            CustomPlayer.StartRandom();
            // CustomPlayer.SetMusic(new Music {source = new Uri(directory + "audioTest/Artik.mp3")});
        }
Example #20
0
 public void OnPlayerJoin(CustomPlayer player)
 {
     Alt.Emit(ServerEventsConstants.DefaultEvents.OnPlayerJoin, player);
 }
Example #21
0
        public override void UpdateEquip(Player player)
        {
            CustomPlayer modPlayer = player.GetModPlayer <CustomPlayer>(mod);

            modPlayer.holyPower *= 1.3f;
        }
Example #22
0
 private static void spawnPlayer(CustomPlayer player, uint delay)
 {
     player.Spawn(OtherConstants.SPAWN_POS, delay);
     player.Rotation = OtherConstants.SPAWN_ROT;
 }
Example #23
0
 public static void OnPlayerJoin(CustomPlayer player, string reason)
 {
     player.Emit(AltVEventsConstants.Auth.ShowAuthScreen);
 }
Example #24
0
 public PlayerPlaceHolder(CustomPlayer player)
 {
     this.player = player;
 }
Example #25
0
 public EntityFactory(EntityTemplate type, Dungeon dungeon, CustomPlayer customPlayer, Point point) : this(type, dungeon, point)
 {
     this.customPlayer = customPlayer;
 }
Example #26
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            CustomPlayer modPlayer = player.GetModPlayer <CustomPlayer>(mod);

            modPlayer.holyPower *= 1.15f;
        }
Example #27
0
    /// <summary>
    /// Handler for "Player Joined" Event
    /// </summary>
    /// <param name="CustomPlayer">Player that joined the game</param>
    private void OnJoinedPlayer(CustomPlayer customPlayer)
    {
        RollbackManager.rbInputManager.localPlayerId = localPlayer.LocalPlayer.ActorNumber - 1;
        if (!customPlayer.IsLocal)
        {
            // Adding the new player, that just joined the game
            lock (remotePlayers)
            {
                if (!remotePlayers.ContainsKey(customPlayer.NickName))
                {
                    GameObject playerPrefab = Resources.Load("NeoReaverProject/Prefabs/Player", typeof(GameObject)) as GameObject;
                    GameObject player       = Object.Instantiate(playerPrefab, new Vector3(), new Quaternion());
                    RollbackManager.rbInputManager.AddPlayer();
                    player.name = customPlayer.NickName;

                    player.GetComponent <PlayerController>().SetupPlayer(customPlayer.ActorNumber - 1, customPlayer.NickName);
                    playerObjects.Add(player);
                    customPlayer.playerObject = player;
                    remotePlayers.Add(customPlayer.NickName, customPlayer);
                }
            }
        }
        else
        {
            // Adding the remote players that already appeared in the game
            lock (localPlayer)
            {
                foreach (Player player1 in localPlayer.LocalRoom.Players.Values)
                {
                    CustomPlayer p = (CustomPlayer)player1;
                    foreach (GameObject playerObject in playerObjects)
                    {
                        if (playerObject.name == p.NickName)
                        {
                            return;
                        }
                    }

                    GameObject playerPrefab = Resources.Load("NeoReaverProject/Prefabs/Player", typeof(GameObject)) as GameObject;
                    GameObject player       = Object.Instantiate(playerPrefab, new Vector3(), new Quaternion());
                    RollbackManager.rbInputManager.AddPlayer();
                    player.name = p.NickName;

                    player.GetComponent <PlayerController>().SetupPlayer(p.ActorNumber - 1, p.NickName);
                    playerObjects.Add(player);
                    p.playerObject = player;
                    remotePlayers.Add(p.NickName, p);
                }
            }
        }

        if (!GameManager.Instance.gameStarted)
        {
            UpdateBasePositions();
            UpdateBaseColors();
            UpdateBaseNames();
        }
        else
        {
            DisablePlayer(customPlayer.ActorNumber - 1);
        }
    }
Example #28
0
    /// <summary>
    /// Implementation of a callback that's used by the Photon library to update the application / game of incoming events.
    /// </summary>
    /// <remarks>
    /// When you override this method, it's very important to call base.OnEvent to keep the state.
    ///
    /// Photon uses events to add or remove players from this client's lists. When we call base.OnEvent()
    /// and it adds a player, we want to fetch this player afterwards, if this removes a player, this
    /// player will be gone after base.OnEvent().
    /// To get the added/removed player in any case, we might have to fetch it before or after running base code.
    /// </remarks>
    /// <param name="photonEvent">The event someone (or the server) sent.</param>
    public override void OnEvent(EventData photonEvent)
    {
        // most events have a sender / origin (but not all) - let's find the player sending this
        int    actorNr = 0;
        Player origin  = null;

        actorNr = photonEvent.Sender;

        if (actorNr > 0)
        {
            this.LocalRoom.Players.TryGetValue(actorNr, out origin);
        }

        base.OnEvent(photonEvent);  // important to call, to keep state up to date

        if (actorNr > 0 && origin == null)
        {
            this.LocalRoom.Players.TryGetValue(actorNr, out origin);
        }

        // the list of players will only store Player references (not the derived class). simply cast:
        CustomPlayer originatingPlayer = (CustomPlayer)origin;

        // this demo logic doesn't handle any events from the server (that is done in the base class) so we could return here
        if (actorNr != 0 && originatingPlayer == null)
        {
            this.DebugReturn(DebugLevel.WARNING, photonEvent.Code + " ev. We didn't find a originating player for actorId: " + actorNr);
            return;
        }

        switch (photonEvent.Code)
        {
        case CustomConstants.EvInput:
            originatingPlayer?.ReadEvInput((Hashtable)photonEvent[ParameterCode.CustomEventContent]);
            break;

        case CustomConstants.EvColor:
            Debug.Log("Recieved Color");
            originatingPlayer?.ReadEvColor((Hashtable)photonEvent[ParameterCode.CustomEventContent]);
            break;

        case CustomConstants.EvPosition:
            Debug.Log("Recieved Postion");
            originatingPlayer?.ReadEvPosition((Hashtable)photonEvent[ParameterCode.CustomEventContent]);
            break;

        case CustomConstants.EvPing:
            originatingPlayer?.ReadEvPing((Hashtable)photonEvent[ParameterCode.CustomEventContent]);
            break;

        // in this demo, we want a callback when players join or leave (so we can update their representation)
        case EventCode.GameListUpdate:
            Debug.Log("GameListUpdate");
            break;

        case EventCode.Join:
            OnEventJoin?.Invoke(originatingPlayer);
            break;

        case EventCode.Leave:
            OnEventLeave?.Invoke(originatingPlayer);
            break;
        }

        UpdateVisuals = true;
    }
Example #29
0
 public void SaveCameraCoords(CustomPlayer player, string coords, string cameraPos, string name)
 {
     Console.WriteLine($"Coords: {coords}\nCamera pos: ${cameraPos}\nName: ${name}");
 }