コード例 #1
0
 private void ProjectileFired(ProjectileData projectile)
 {
     foreach (var player in Components)
     {
         if (player.GetType() == typeof(OtherPlayerSprite) &&
             ((OtherPlayerSprite)player).pData.playerID == projectile.ID)
         {
             OtherPlayerSprite p = ((OtherPlayerSprite)player);
             p.turret.CreateProjectile(new Vector2(p.Position.X, p.Position.Y), projectile.ID, projectile.projectileID);
         }
     }
 }
コード例 #2
0
        //Code Client-Side for leaving server.
        private void PlayerLeft(PlayerData player, List <PlayerData> otherPlayers)
        {
            //This method looks for the player that just left and hides him from other clients.
            foreach (var p in Components)
            {
                if (p.GetType() == typeof(OtherPlayerSprite) && //look through otherplayers by comparing with player that was passed to it through playerID.
                    ((OtherPlayerSprite)p).pData.playerID == player.playerID)
                {
                    OtherPlayerSprite found = ((OtherPlayerSprite)p); //Once we got it, set found to p.
                    found.Visible = false;                            //Hide the player that left.
                    break;                                            //Break out of the loop as soon as player is found in the otherplayers collection as we have what we wanted.
                }
            }

            new FadeText(this, new Vector2(10, 20), string.Format("{0} has left the game.", player.GamerTag));
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: RadicalRadishes/RadRepo2.0
 private void clientOtherMoved(string playerID, Position newPos)
 {
     // iterate over all the other player components
     // and check to see the type and the right id
     foreach (var player in Components)
     {
         if (player.GetType() == typeof(OtherPlayerSprite) &&
             ((OtherPlayerSprite)player).pData.playerID == playerID)
         {
             OtherPlayerSprite p = ((OtherPlayerSprite)player);
             p.pData.playerPosition = newPos;
             p.Position             = new Point(p.pData.playerPosition.X, p.pData.playerPosition.Y);
             break; // break out of loop as only one player position is being updated
                    // and we have found it
         }
     }
 }
コード例 #4
0
        private void hitRegistered(ProjectileData projectile)
        {
            foreach (var player in Components)
            {
                if (player.GetType() == typeof(OtherPlayerSprite) &&
                    ((OtherPlayerSprite)player).pData.playerID == projectile.ID)
                {
                    OtherPlayerSprite p = ((OtherPlayerSprite)player);

                    foreach (SimpleProjectile proj in p.turret.projectiles)
                    {
                        if (proj.data.projectileID == projectile.projectileID)
                        {
                            proj.visible = false;
                            break;
                        }
                    }
                    break;
                }
            }
        }
コード例 #5
0
 private void clientOtherMoved(string playerID, Position newPos)
 {
     // iterate over all the other player components
     // and check to see the type and the right id
     foreach (var player in Components)
     {
         if (player.GetType() == typeof(OtherPlayerSprite) &&
             ((OtherPlayerSprite)player).pData.playerID == playerID)
         {
             OtherPlayerSprite p = ((OtherPlayerSprite)player);
             p.pData.playerPosition = newPos;
             p.Position             = new Point(p.pData.playerPosition.X, p.pData.playerPosition.Y);
             p.rotation             = p.pData.playerPosition.angle;
             p.turret.rotation      = p.pData.playerPosition.TurretAngle;
             p.turret.BoundingRect  = new Rectangle(p.Position.X, p.Position.Y, p.turret._tx.Width, p.turret._tx.Height);
             if (score.players.Contains(p.pData))
             {
             }
             break; // break out of loop as only one player position is being updated
                    // and we have found it
         }
     }
 }