예제 #1
0
    private void controllerAssigned(SessionPlayer player)
    {
        if (_animator != null)
            _animator.SetTrigger("Joined");

        this.JoinedText.gameObject.SetActive(true);
        this.JoinText.gameObject.SetActive(false);

        string buttonText = "";
        Player rewiredPlayer = ReInput.players.GetPlayer(player.RewiredId);
        int categoryId = ReInput.mapping.GetMapCategoryId(MenuInput.MENU_CATEGORY);

        foreach (ControllerMap map in rewiredPlayer.controllers.maps.GetAllMaps())
        {
            if (map.categoryId == categoryId)
            {
                foreach (ActionElementMap actionMap in map.ButtonMapsWithAction(MenuInput.EXIT))
                {
                    buttonText = actionMap.elementIdentifierName;
                    break;
                }

                if (buttonText != "")
                    break;
            }
        }
        
        this.JoinedText.text = player.Name + " JOINED (PRESS '" + buttonText.ToUpper() + "' TO LEAVE)";
    }
예제 #2
0
 void Update()
 {
     if (this.AllowReassignment && !PauseController.IsPaused())
     {
         for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
         {
             SessionPlayer p = DynamicData.GetSessionPlayer(i);
             if (!p.HasJoined)
             {
                 // Assignment
                 foreach (Player rewiredPlayer in ReInput.players.Players)
                 {
                     if (!rewiredPlayer.isPlaying && rewiredPlayer.GetButtonDown(JOIN_ACTION))
                     {
                         joinPlayer(p, rewiredPlayer);
                         break;
                     }
                 }
             }
             else
             {
                 // Unassignment
                 if (ReInput.players.GetPlayer(p.RewiredId).GetButtonDown(MenuInput.EXIT))
                 {
                     //TODO - Should be checking if button held rather than just pressed
                     dropPlayer(p);
                 }
             }
         }
     }
 }
예제 #3
0
    public static void RecordHighScore()
    {
        int score      = 0;
        int numPlayers = 0;

        for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(i);
            if (p.HasJoined)
            {
                ++numPlayers;
                score += ProgressData.GetPointsForPlayer(i);
            }
        }

        numPlayers = Mathf.Max(ProgressData.MostPlayersUsed, numPlayers);

        if (numPlayers > 1)
        {
            if (score > _highScoreCoop)
            {
                _highScoreCoop = score;
            }
        }
        else
        {
            if (score > _highScoreSinglePlayer)
            {
                _highScoreSinglePlayer = score;
            }
        }
    }
예제 #4
0
    private void controllerAssigned(SessionPlayer player)
    {
        if (_animator != null)
        {
            _animator.SetTrigger("Joined");
        }

        this.JoinedText.gameObject.SetActive(true);
        this.JoinText.gameObject.SetActive(false);

        string buttonText    = "";
        Player rewiredPlayer = ReInput.players.GetPlayer(player.RewiredId);
        int    categoryId    = ReInput.mapping.GetMapCategoryId(MenuInput.MENU_CATEGORY);

        foreach (ControllerMap map in rewiredPlayer.controllers.maps.GetAllMaps())
        {
            if (map.categoryId == categoryId)
            {
                foreach (ActionElementMap actionMap in map.ButtonMapsWithAction(MenuInput.EXIT))
                {
                    buttonText = actionMap.elementIdentifierName;
                    break;
                }

                if (buttonText != "")
                {
                    break;
                }
            }
        }

        this.JoinedText.text = player.Name + " JOINED (PRESS '" + buttonText.ToUpper() + "' TO LEAVE)";
    }
예제 #5
0
        public static void UpdatePresence(string sessionid, string presence)
        {
            sessionid = GetSessionID(sessionid);
            SessionPlayer player = players[sessionid];

            player.presence    = presence;
            players[sessionid] = player;
        }
예제 #6
0
 private void playerDied(LocalEventNotifier.Event e)
 {
     if (_player != null && (e as PlayerDiedEvent).PlayerIndex == _player.PlayerIndex)
     {
         _rectTransform.position = new Vector3(-99999, -99999, _rectTransform.position.z);
         _player = null;
     }
 }
예제 #7
0
 private void playerDied(LocalEventNotifier.Event e)
 {
     if (_player != null && (e as PlayerDiedEvent).PlayerIndex == _player.PlayerIndex)
     {
         _rectTransform.position = new Vector3(-99999, -99999, _rectTransform.position.z);
         _player = null;
     }
 }
예제 #8
0
    public void AddPlayer(string PlayerID, FoodPreferenceType PreferenceType)
    {
        AvaiableFoodPreferenceTypes.Remove(PreferenceType);

        var Player = new SessionPlayer(PlayerID, PreferenceType);

        Players.Add(Player);
    }
예제 #9
0
    private void pointsReceived(LocalEventNotifier.Event e)
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined && player.PlayerIndex == ((PlayerPointsReceivedEvent)e).PlayerIndex)
        {
            this.UpdateLength(ProgressData.GetHealthForPlayer(this.PlayerIndex), ProgressData.MAX_HEALTH);
        }
    }
예제 #10
0
 public static SessionPlayer GetSessionPlayer(int playerIndex)
 {
     SessionPlayer player = _sessionPlayers[playerIndex];
     if (player == null)
     {
         player = new SessionPlayer(playerIndex);
         _sessionPlayers[playerIndex] = player;
     }
     return player;
 }
예제 #11
0
    private void controllerUnassigned(SessionPlayer player)
    {
        if (_animator != null)
            _animator.SetTrigger("Unjoined");

        this.JoinedText.gameObject.SetActive(false);
        this.JoinText.gameObject.SetActive(true);

        //TODO - Try to display correct button text with data from Rewired maps?
    }
예제 #12
0
    public static SessionPlayer GetSessionPlayer(int playerIndex)
    {
        SessionPlayer player = _sessionPlayers[playerIndex];

        if (player == null)
        {
            player = new SessionPlayer(playerIndex);
            _sessionPlayers[playerIndex] = player;
        }
        return(player);
    }
예제 #13
0
    public static Vector2 GetMovementAxis(int playerIndex, bool normalized = false)
    {
        SessionPlayer p    = DynamicData.GetSessionPlayer(playerIndex);
        Vector2       axis = ReInput.players.GetPlayer(p.RewiredId).GetAxis2D(MOVE_HORIZONTAL, MOVE_VERTICAL);

        if (normalized)
        {
            axis.Normalize();
        }
        return(axis);
    }
예제 #14
0
    private void pointsReceived(LocalEventNotifier.Event e)
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined && player.PlayerIndex == ((PlayerPointsReceivedEvent)e).PlayerIndex)
        {
            for (int i = 0; i < this.Slots.Length; ++i)
            {
                this.Slots[i].UpdateWithSessionPlayer(player);
            }
        }
    }
예제 #15
0
    private void controllerUnassigned(SessionPlayer player)
    {
        if (_animator != null)
        {
            _animator.SetTrigger("Unjoined");
        }

        this.JoinedText.gameObject.SetActive(false);
        this.JoinText.gameObject.SetActive(true);

        //TODO - Try to display correct button text with data from Rewired maps?
    }
예제 #16
0
        public static bool CreateSession(string sessionid, string psnticket, string ipAddr, SQLiteCommand sqlite_cmd)
        {
            //Decode PSN ticket data
            //sessionid = GetSessionID(sessionid);
            NPTicket ticket = DecodePSNTicket(psnticket);

            if (players.ContainsKey(sessionid))
            {
                return(false);
            }
            SQLiteDataReader sqReader = DatabaseManager.GetReader(sqlite_cmd, "SELECT player_id FROM Users WHERE psn_id=@id", new SQLiteParameter("@id", ticket.user_id.ToString()));
            int id = 1;

            if (!sqReader.HasRows)
            {
                sqReader.Close();
                sqReader = DatabaseManager.GetReader(sqlite_cmd, "SELECT player_id FROM Users ORDER BY player_id DESC LIMIT 1;");
                if (sqReader.HasRows)
                {
                    id = sqReader.GetInt32(0) + 1;
                }
                sqReader.Close();
                DatabaseManager.NonQuery(sqlite_cmd, "INSERT INTO Users VALUES (@psn_id,@player_id,@username,@city,@country,@created_at,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,@player_creation_quota,0,@province,@quote,0,0,@skill_level,@skill_level_id,@skill_level_name,@state,0,0,0,0,0)"
                                         , new SQLiteParameter("@psn_id", ticket.user_id.ToString())
                                         , new SQLiteParameter("@player_id", id)
                                         , new SQLiteParameter("@username", ticket.online_id)
                                         , new SQLiteParameter("@city", "")
                                         , new SQLiteParameter("@country", ticket.region)
                                         , new SQLiteParameter("@created_at", DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss"))
                                         , new SQLiteParameter("@player_creation_quota", 30)
                                         , new SQLiteParameter("@province", "")
                                         , new SQLiteParameter("@quote", "")
                                         , new SQLiteParameter("@skill_level", "Newcomer I")
                                         , new SQLiteParameter("@skill_level_id", "1")
                                         , new SQLiteParameter("@skill_level_name", "Newcomer I")
                                         , new SQLiteParameter("@state", ""));
            }
            else
            {
                id = sqReader.GetInt32(0); sqReader.Close();
            }
            SessionPlayer player = new SessionPlayer();

            player.ip_address = ipAddr;
            player.player_id  = (ulong)id;
            player.username   = ticket.online_id;
            player.presence   = "ONLINE";
            player.encoding   = "US-ASCII";
            players.Add(sessionid, player);
            playerTickets.Add(sessionid, ticket);
            return(true);
        }
예제 #17
0
    void Start()
    {
        SessionPlayer p = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (p.HasJoined)
        {
            controllerAssigned(p);
        }
        else
        {
            controllerUnassigned(p);
        }
    }
예제 #18
0
        private void OnPlayerUpdate(PlayerUpdate update)
        {
            var player = new SessionPlayer(update.UserId, (PlayerStatus)update.Status);

            _users.AddOrUpdate(update.UserId, player, (_, __) => player);

            var action = OnConnectedPlayersChanged;

            if (action != null)
            {
                action(player);
            }
        }
예제 #19
0
        public async Task <IActionResult> Create(CreateSessionViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (viewModel.SelectedSessionPlayers == null)
                    {
                        viewModel.SelectedSessionPlayers = new List <int>();
                    }

                    List <SessionPlayer>   playersInSession   = new List <SessionPlayer>();
                    List <AdventurePlayer> playersInAdventure = new List <AdventurePlayer>();

                    foreach (int playerID in viewModel.SelectedSessionPlayers)
                    {
                        //Wie speelt mee in de session
                        SessionPlayer sessionPlayer = new SessionPlayer();
                        sessionPlayer.PlayerID  = playerID;
                        sessionPlayer.SessionID = viewModel.Session.SessionID;

                        //Welke spelers spelen het avontuur mee
                        AdventurePlayer adventurePlayer = new AdventurePlayer();
                        adventurePlayer.PlayerID    = playerID;
                        adventurePlayer.AdventureID = viewModel.Session.AdventureID;

                        playersInSession.Add(sessionPlayer);
                        playersInAdventure.Add(adventurePlayer);
                    }
                    _context.Add(viewModel.Session);
                    await _context.SaveChangesAsync();

                    Session session = await _context.Sessions
                                      .Include(s => s.SessionPlayers)
                                      .Include(a => a.Adventure.AdventurePlayers)
                                      .SingleOrDefaultAsync(x => x.SessionID == viewModel.Session.SessionID);

                    session.SessionPlayers.AddRange(playersInSession);
                    session.Adventure.AdventurePlayers.AddRange(playersInAdventure);

                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (Exception)
                {
                    return(Redirect("~/Views/Shared/Error.cshtml"));
                }
            }
            return(View(viewModel));
        }
예제 #20
0
    private void joinPlayer(SessionPlayer p, Player rewiredP)
    {
        rewiredP.controllers.maps.SetMapsEnabled(true, MenuInput.MENU_CATEGORY);
        rewiredP.controllers.maps.SetMapsEnabled(false, ASSIGNMENT_CATEGORY);
        p.JoinSession(rewiredP.id);

        if (_assignmentCallbacks != null && _assignmentCallbacks.ContainsKey(p.PlayerIndex))
        {
            foreach (ControllerAssigned callback in _assignmentCallbacks[p.PlayerIndex])
            {
                callback(p);
            }
        }
    }
예제 #21
0
    public static int NumJoinedPlayers()
    {
        int num = 0;

        for (int i = 0; i < _sessionPlayers.Length; ++i)
        {
            SessionPlayer p = _sessionPlayers[i];
            if (p != null & p.HasJoined)
            {
                ++num;
            }
        }
        return(num);
    }
예제 #22
0
 private void playerSpawned(LocalEventNotifier.Event e)
 {
     PlayerSpawnedEvent playerSpawnedEvent = e as PlayerSpawnedEvent;
     if (playerSpawnedEvent.PlayerIndex == this.PlayerIndex)
     {
         SessionPlayer p = DynamicData.GetSessionPlayer(this.PlayerIndex);
         if (p.HasJoined && !ReInput.players.GetPlayer(p.RewiredId).controllers.hasMouse)
         {
             _player = p;
             _playerController = playerSpawnedEvent.PlayerObject.GetComponent<PlayerController>();
             _playerController.SetUsingController();
         }
     }
 }
예제 #23
0
    private void playerSpawned(LocalEventNotifier.Event e)
    {
        PlayerSpawnedEvent playerSpawnedEvent = e as PlayerSpawnedEvent;

        if (playerSpawnedEvent.PlayerIndex == this.PlayerIndex)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(this.PlayerIndex);
            if (p.HasJoined && !ReInput.players.GetPlayer(p.RewiredId).controllers.hasMouse)
            {
                _player           = p;
                _playerController = playerSpawnedEvent.PlayerObject.GetComponent <PlayerController>();
                _playerController.SetUsingController();
            }
        }
    }
예제 #24
0
        protected void gvContinue_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex < 0)
            {
                return;
            }
            using (FinalFantasyDrunkDataContext dc = new FinalFantasyDrunkDataContext())
            {
                string gameID = e.Row.Cells[0].Text;

                Game game = (from t in dc.Games where t.ID == int.Parse(gameID) select t).FirstOrDefault();

                PizzaNight.Session session = game.Sessions.Where(x => !x.DateEnded.HasValue).FirstOrDefault();
                if (session == null)
                {
                    // Create new session and go ahead
                    session = new PizzaNight.Session()
                    {
                        DateStarted = DateTime.Now,
                        GameID      = game.ID
                    };
                    dc.Sessions.InsertOnSubmit(session);
                    dc.SubmitChanges();

                    SessionPlayer newPlayerRobb = new SessionPlayer()
                    {
                        SessionID = session.ID,
                        PlayerID  = 1
                    };
                    SessionPlayer newPlayerBrian = new SessionPlayer()
                    {
                        SessionID = session.ID,
                        PlayerID  = 2
                    };
                    dc.SessionPlayers.InsertOnSubmit(newPlayerRobb);
                    dc.SessionPlayers.InsertOnSubmit(newPlayerBrian);
                    dc.SubmitChanges();
                }

                HyperLink hl = new HyperLink()
                {
                    NavigateUrl = "Session?id=" + session.ID,
                    Text        = "Go",
                    CssClass    = "btn btn-default btn-cs"
                };
                e.Row.Cells[0].Controls.Add(hl);
            }
        }
예제 #25
0
    private void dropPlayer(SessionPlayer p)
    {
        Player rewiredP = ReInput.players.GetPlayer(p.RewiredId);

        rewiredP.controllers.maps.SetMapsEnabled(false, MenuInput.MENU_CATEGORY);
        rewiredP.controllers.maps.SetMapsEnabled(true, ASSIGNMENT_CATEGORY);
        p.LeaveSession();

        if (_unassignmentCallbacks != null && _unassignmentCallbacks.ContainsKey(p.PlayerIndex))
        {
            foreach (ControllerUnassigned callback in _unassignmentCallbacks[p.PlayerIndex])
            {
                callback(p);
            }
        }
    }
예제 #26
0
    void Start()
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined)
        {
            for (int i = 0; i < this.Slots.Length; ++i)
            {
                this.Slots[i].UpdateWithSessionPlayer(player);
            }
            GlobalEvents.Notifier.Listen(PlayerPointsReceivedEvent.NAME, this, pointsReceived);
            GlobalEvents.Notifier.Listen(PlayerSpawnedEvent.NAME, this, playerSpawned);
        }
        else
        {
            this.gameObject.SetActive(false);
        }
    }
예제 #27
0
    public static bool AnyPlayerButtonPressed(string buttonName)
    {
        int numJoined = 0;

        for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(i);
            if (p.HasJoined)
            {
                ++numJoined;
                if (!ReInput.players.GetPlayer(p.RewiredId).GetButtonDown(buttonName))
                {
                    return(false);
                }
            }
        }
        return(numJoined > 0);
    }
예제 #28
0
    void Start()
    {
        if (this.AssignFirstPlayerOnStart)
        {
            SessionPlayer p1 = DynamicData.GetSessionPlayer(0);
            if (!p1.HasJoined)
            {
                // Find most recent active input and join p1 with it
                Player lastActive     = null;
                float  lastActiveTime = 0.0f;
                foreach (Player p in ReInput.players.Players)
                {
                    Controller c           = p.controllers.GetLastActiveController();
                    float      cActiveTime = c != null?c.GetLastTimeActive() : lastActiveTime;

                    if (cActiveTime > lastActiveTime || (lastActive == null && (p.controllers.hasMouse || p.controllers.joystickCount != 0)))
                    {
                        lastActiveTime = cActiveTime;
                        lastActive     = p;
                    }
                }

                // Only join if this input isn't already joined with another player
                if (DynamicData.GetSessionPlayerByRewiredId(lastActive.id) == null)
                {
                    joinPlayer(p1, lastActive);
                }
            }
        }

        if (this.DisableMenuInputForUnjoinedPlayers || this.EnableMenuInputForUnjoinedPlayers)
        {
            foreach (Player rewiredP in ReInput.players.Players)
            {
                if (DynamicData.GetSessionPlayerByRewiredId(rewiredP.id) == null)
                {
                    rewiredP.controllers.maps.SetMapsEnabled(this.EnableMenuInputForUnjoinedPlayers, MenuInput.MENU_CATEGORY);
                }
            }
        }
    }
예제 #29
0
    public static Vector2 GetAimingAxis(int playerIndex, Vector2 playerWorldPosition, bool normalized = true)
    {
        SessionPlayer p        = DynamicData.GetSessionPlayer(playerIndex);
        Player        rewiredP = ReInput.players.GetPlayer(p.RewiredId);
        Vector2       axis;

        if (rewiredP.controllers.hasMouse)
        {
            Vector2 playerScreenPosition = Camera.main.WorldToScreenPoint(playerWorldPosition);
            axis = rewiredP.controllers.Mouse.screenPosition - playerScreenPosition;

            if (!normalized)
            {
                float maxMouseExtension = MAX_MOUSE_EXTENSION_RATIO * Screen.width;
                if (axis.magnitude > maxMouseExtension)
                {
                    axis = axis.normalized * maxMouseExtension;
                }
                axis /= maxMouseExtension;
            }
        }
        else
        {
            axis = rewiredP.GetAxis2D(AIM_HORIZONTAL, AIM_VERTICAL);
            if (axis.magnitude < AIM_DEAD)
            {
                axis = Vector2.zero;
            }

            /*if (Mathf.Abs(axis.x) < AIM_DEAD)
             *  axis.x = 0;
             * if (Mathf.Abs(axis.y) < AIM_DEAD)
             *  axis.y = 0;*/
        }

        if (normalized)
        {
            axis.Normalize();
        }
        return(axis);
    }
예제 #30
0
    /**
     * Private
     */
    private static bool checkButton(string buttonName, int playerIndex)
    {
        if (playerIndex < 0)
        {
            foreach (Player player in ReInput.players.GetPlayers())
            {
                if (player.GetButtonDown(buttonName))
                {
                    return(true);
                }
            }
            return(false);
        }

        SessionPlayer sessionPlayer = DynamicData.GetSessionPlayer(playerIndex);

        if (sessionPlayer == null || !sessionPlayer.HasJoined)
        {
            return(false);
        }

        return(ReInput.players.GetPlayer(sessionPlayer.RewiredId).GetButtonDown(buttonName));
    }
예제 #31
0
 protected void AddGame_Click(object sender, EventArgs e)
 {
     using (FinalFantasyDrunkDataContext dc = new FinalFantasyDrunkDataContext())
     {
         Game game = new Game()
         {
             DateStarted   = DateTime.Now,
             CharacterName = tbCharacterName.Text,
             LastPlayed    = DateTime.Now,
             GameTypeID    = int.Parse(ddGameType.SelectedValue)
         };
         dc.Games.InsertOnSubmit(game);
         dc.SubmitChanges();
         PizzaNight.Session session = new PizzaNight.Session()
         {
             GameID      = game.ID,
             DateStarted = DateTime.Now
         };
         dc.Sessions.InsertOnSubmit(session);
         dc.SubmitChanges();
         SessionPlayer newPlayerRobb = new SessionPlayer()
         {
             SessionID = session.ID,
             PlayerID  = 1
         };
         SessionPlayer newPlayerBrian = new SessionPlayer()
         {
             SessionID = session.ID,
             PlayerID  = 2
         };
         dc.SessionPlayers.InsertOnSubmit(newPlayerRobb);
         dc.SessionPlayers.InsertOnSubmit(newPlayerBrian);
         dc.SubmitChanges();
         Response.Redirect("Session?id=" + session.ID, false);
     }
     Context.ApplicationInstance.CompleteRequest();
 }
예제 #32
0
    void Update()
    {
        if (!_setup)
        {
            for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
            {
                SessionPlayer p = DynamicData.GetSessionPlayer(i);
                if (p.HasJoined)
                {
                    if (ReInput.players.GetPlayer(p.RewiredId).controllers.hasMouse)
                    {
                        _player = p;
                        AllegianceColorizer colorizer = this.GetComponent <AllegianceColorizer>();
                        AllegianceInfo      info      = colorizer.AllegianceInfo;
                        info.MemberId = i;
                        colorizer.UpdateVisual(info);
                        break;
                    }
                }
            }
            _setup = true;
        }

        if (_player != null)
        {
            if (PauseController.IsPaused())
            {
                _rectTransform.position = new Vector3(-99999, -99999, _rectTransform.position.z);
            }
            else
            {
                Player  rewiredP  = ReInput.players.GetPlayer(_player.RewiredId);
                Vector2 screenPos = rewiredP.controllers.Mouse.screenPosition;
                _rectTransform.position = new Vector3(screenPos.x, screenPos.y, _rectTransform.position.z);
            }
        }
    }
예제 #33
0
    private void spawnPlayer(SessionPlayer sessionPlayer, Transform spawn)
    {
        IntegerVector position = new IntegerVector(spawn.position);
        GameObject    player   = Instantiate(this.PlayerPrefab, new Vector3(position.X, position.Y, this.transform.position.z), Quaternion.identity) as GameObject;

        foreach (EnemySpawner spawner in this.EnemySpawners)
        {
            if (spawner != null)
            {
                spawner.Targets.Add(player.transform);
            }
        }

        PlayerController playerController = player.GetComponent <PlayerController>();

        playerController.PlayerIndex = sessionPlayer.PlayerIndex;
        playerController.NoFire      = this.NoFireForPlayers;
        if (this.PlayerInteractionDelay > 0.0f)
        {
            playerController.SetInteractionDelay(this.PlayerInteractionDelay);
        }

        GlobalEvents.Notifier.SendEvent(new PlayerSpawnedEvent(player, sessionPlayer.PlayerIndex));
    }
예제 #34
0
    public void SpawnPlayers()
    {
        int t = 0;

        for (int p = 0; p < DynamicData.MAX_PLAYERS; ++p)
        {
            SessionPlayer player = DynamicData.GetSessionPlayer(p);
            if (player.HasJoined)
            {
                while (t < this.PlayerSpawns.Length && this.PlayerSpawns[t] == null)
                {
                    ++t;
                }
                if (t < this.PlayerSpawns.Length)
                {
                    spawnPlayer(player, this.PlayerSpawns[t]);
                }
                else
                {
                    break;
                }
            }
        }
    }
예제 #35
0
    private void spawnPlayer(SessionPlayer sessionPlayer, Transform spawn)
    {
        IntegerVector position = new IntegerVector(spawn.position);
        GameObject player = Instantiate(this.PlayerPrefab, new Vector3(position.X, position.Y, this.transform.position.z), Quaternion.identity) as GameObject;

        foreach (EnemySpawner spawner in this.EnemySpawners)
        {
            if (spawner != null)
                spawner.Targets.Add(player.transform);
        }

        PlayerController playerController = player.GetComponent<PlayerController>();
        playerController.PlayerIndex = sessionPlayer.PlayerIndex;
        playerController.NoFire = this.NoFireForPlayers;
        if (this.PlayerInteractionDelay > 0.0f)
            playerController.SetInteractionDelay(this.PlayerInteractionDelay);

        GlobalEvents.Notifier.SendEvent(new PlayerSpawnedEvent(player, sessionPlayer.PlayerIndex));
    }
예제 #36
0
    public static bool GetFireButton(int playerIndex)
    {
        SessionPlayer p = DynamicData.GetSessionPlayer(playerIndex);

        return(ReInput.players.GetPlayer(p.RewiredId).GetButton(FIRE));
    }
예제 #37
0
 public void UpdateWithSessionPlayer(SessionPlayer player)
 {
     this.UpdateSlots(ProgressData.WeaponSlotsByPlayer[player.PlayerIndex]);
 }
예제 #38
0
    private void dropPlayer(SessionPlayer p)
    {
        Player rewiredP = ReInput.players.GetPlayer(p.RewiredId);
        rewiredP.controllers.maps.SetMapsEnabled(false, MenuInput.MENU_CATEGORY);
        rewiredP.controllers.maps.SetMapsEnabled(true, ASSIGNMENT_CATEGORY);
        p.LeaveSession();

        if (_unassignmentCallbacks != null && _unassignmentCallbacks.ContainsKey(p.PlayerIndex))
        {
            foreach (ControllerUnassigned callback in _unassignmentCallbacks[p.PlayerIndex])
            {
                callback(p);
            }
        }
    }
예제 #39
0
    private void joinPlayer(SessionPlayer p, Player rewiredP)
    {
        rewiredP.controllers.maps.SetMapsEnabled(true, MenuInput.MENU_CATEGORY);
        rewiredP.controllers.maps.SetMapsEnabled(false, ASSIGNMENT_CATEGORY);
        p.JoinSession(rewiredP.id);

        if (_assignmentCallbacks != null && _assignmentCallbacks.ContainsKey(p.PlayerIndex))
        {
            foreach (ControllerAssigned callback in _assignmentCallbacks[p.PlayerIndex])
            {
                callback(p);
            }
        }
    }