cinvoke-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cinvoke-svn] r119 - in trunk/skorpion: . server/game server/network ser


From: will
Subject: [cinvoke-svn] r119 - in trunk/skorpion: . server/game server/network server/universe
Date: 12 Nov 2006 06:51:18 -0500

Author: p
Date: 2006-11-12 06:51:17 -0500 (Sun, 12 Nov 2006)
New Revision: 119

Modified:
   trunk/skorpion/Client.cs
   trunk/skorpion/Controller.cs
   trunk/skorpion/PlayerList.cs
   trunk/skorpion/server/game/Server.cs
   trunk/skorpion/server/network/Protocol.cs
   trunk/skorpion/server/universe/Entity.cs
   trunk/skorpion/server/universe/Universe.cs
   trunk/skorpion/skorpion.cs
Log:
add teams and individual scoring



Modified: trunk/skorpion/Client.cs
===================================================================
--- trunk/skorpion/Client.cs    2006-11-12 07:17:13 UTC (rev 118)
+++ trunk/skorpion/Client.cs    2006-11-12 11:51:17 UTC (rev 119)
@@ -138,7 +138,8 @@
                                                s.Position    = 
m.ShipPos[j].GetVector();
                                                s.Orientation = 
m.ShipOrt[j].GetVector();
                                                s.UpDirection = 
m.ShipUp[j].GetVector();
-                                               s.Velocity    = 
m.ShipVel[j].GetVector();
+                                       //      s.Velocity    = 
m.ShipVel[j].GetVector();
+                                               s.Team        = m.ShipTeam[j];
                                        }
 
                                        Ship universeMe = 
(Ship)Universe.Entities[MyID];
@@ -168,6 +169,7 @@
                                                                Ship s = new 
Ship((ushort)de.Key);
                                                                s.Orientation = 
((Ship)de.Value).Orientation;
                                                                s.UpDirection = 
((Ship)de.Value).UpDirection;
+                                                               s.Team = 
((Ship)de.Value).Team;
                                                                e = (Entity)s;
                                                        }
                                                        else // this could 
break stuff with objects other than ships
@@ -228,20 +230,18 @@
                                else if (PlayerInfo.TYPE == 
((GameMsg)msg[i]).Type)
                                {
                                        LastPlayerInfo = (PlayerInfo)msg[i];
+                                       Universe.Players.Clear();
                                        
                                        for(int playerIndex = 0; playerIndex < 
LastPlayerInfo.Name.Length; playerIndex++)
                                        {
                                                ushort id = 
LastPlayerInfo.ID[playerIndex];
-                                               Ship ship = 
(Ship)Universe.Players[id];
-                                               if(ship == null)
-                                               {
-                                                       ship = new Ship(id);
-                                                       Universe.Players[id] = 
ship;
-                                               }
+                                               Ship ship = new Ship(id);
+                                               Universe.Players[id] = ship;
 
                                                ship.Name = 
LastPlayerInfo.Name[playerIndex];
                                                ship.Ping = 
LastPlayerInfo.Ping[playerIndex];
                                                ship.Team = 
LastPlayerInfo.Team[playerIndex];
+                                               ship.Score = 
LastPlayerInfo.Score[playerIndex];
                                        }
                                }
                                else if (TeamAck.TYPE == ((GameMsg)msg[i]).Type)

Modified: trunk/skorpion/Controller.cs
===================================================================
--- trunk/skorpion/Controller.cs        2006-11-12 07:17:13 UTC (rev 118)
+++ trunk/skorpion/Controller.cs        2006-11-12 11:51:17 UTC (rev 119)
@@ -15,6 +15,7 @@
 
                public Command(GameClient c)
                {
+                       List["position"]    = new CallBack(this.Position);
                        List["snapin"]      = new CallBack(c.snapIn);
                        List["snapout"]     = new CallBack(c.snapOut);
                        List["+fire"]       = new CallBack(c.fireStart);
@@ -95,6 +96,11 @@
                        GlobalState.Client.Net.ACKQueue.Add(m);
                }
 
+               public void Position(string s)
+               {
+                       GlobalState.Console.Print("Position " + 
GlobalState.Client.Me.Position);
+               }
+
                public void Passcmds(string s)
                {
                        if (GlobalState.Console.IsVisible)

Modified: trunk/skorpion/PlayerList.cs
===================================================================
--- trunk/skorpion/PlayerList.cs        2006-11-12 07:17:13 UTC (rev 118)
+++ trunk/skorpion/PlayerList.cs        2006-11-12 11:51:17 UTC (rev 119)
@@ -24,7 +24,7 @@
                private PlayerListState        _state                    = 
PlayerListState.Closed;
                private DateTime            _stateChange;
                private StringBuilder       _entryLine                = new 
StringBuilder(_prefix);
-               private System.Drawing.Font _windowsFont              = new 
System.Drawing.Font("Arial", 14.0f);
+               private System.Drawing.Font _windowsFont              = new 
System.Drawing.Font("Courier", 14.0f, System.Drawing.FontStyle.Bold);
                private Device              _device;
                private int                 _topMargin                = 150;
                private int                 _leftMargin               = 200;
@@ -108,12 +108,12 @@
                        if (_debug)
                                _lock.WaitOne();
 
-                       _font.DrawText(null, ":SupeR Sk0rp1on B4LL 6oo6:", new 
System.Drawing.Point(_leftMargin+60, line), black);
+                       _font.DrawText(null, ":SKoRPioN SPaCEBaLL 6oo6:", new 
System.Drawing.Point(_leftMargin+60, line), black);
                        line += this.LineHeight;
 
-                       _font.DrawText(null, "Team 1: silver", new 
System.Drawing.Point(_leftMargin+140, line), black);
+                       _font.DrawText(null, "Team 1: ontario", new 
System.Drawing.Point(_leftMargin+140, line), black);
                        line += this.LineHeight;
-                       _font.DrawText(null, "name     ping", new 
System.Drawing.Point(_leftMargin+10, line), black);
+                       _font.DrawText(null, "name               score    
ping", new System.Drawing.Point(_leftMargin+10, line), black);
                        line += this.LineHeight;
 
                        // draw team 1 entries
@@ -124,7 +124,13 @@
                                        Ship ship = (Ship)e;
                                        if(ship.Team == 1)
                                        {
-                                               string playerLine = ship.Name + 
"     " + ship.Ping;
+                                               string playerLine = ship.Name;
+                                               if (playerLine.Length > 16) 
playerLine = playerLine.Substring(0,16);
+                                               int len = playerLine.Length;
+                                               while (playerLine.Length < 20) 
playerLine += " ";
+                                               playerLine += ship.Ping;
+                                               while (playerLine.Length < 31) 
playerLine += " ";
+                                               playerLine += ship.Score;
                                                _font.DrawText(null, 
playerLine, new System.Drawing.Point(_leftMargin+10, line), black);
                                                line += this.LineHeight;
                                        }
@@ -132,9 +138,9 @@
                        }
 
                        line += this.LineHeight;
-                       _font.DrawText(null, "Team 2: ontario", new 
System.Drawing.Point(_leftMargin+135, line), black);
+                       _font.DrawText(null, "Team 2: silver", new 
System.Drawing.Point(_leftMargin+135, line), black);
                        line += this.LineHeight;
-                       _font.DrawText(null, "name     ping", new 
System.Drawing.Point(_leftMargin+10, line), black);
+                       _font.DrawText(null, "name               score    
ping", new System.Drawing.Point(_leftMargin+10, line), black);
                        line += this.LineHeight;
 
                        // draw team 2 entries
@@ -145,7 +151,13 @@
                                        Ship ship = (Ship)e;
                                        if(ship.Team == 2)
                                        {
-                                               string playerLine = ship.Name + 
"     " + ship.Ping;
+                                               string playerLine = ship.Name;
+                                               if (playerLine.Length > 16) 
playerLine = playerLine.Substring(0,16);
+                                               int len = playerLine.Length;
+                                               while (playerLine.Length < 20) 
playerLine += " ";
+                                               playerLine += ship.Score;
+                                               while (playerLine.Length < 31) 
playerLine += " ";
+                                               playerLine += ship.Ping;
                                                _font.DrawText(null, 
playerLine, new System.Drawing.Point(_leftMargin+10, line), black);
                                                line += this.LineHeight;
                                        }

Modified: trunk/skorpion/server/game/Server.cs
===================================================================
--- trunk/skorpion/server/game/Server.cs        2006-11-12 07:17:13 UTC (rev 
118)
+++ trunk/skorpion/server/game/Server.cs        2006-11-12 11:51:17 UTC (rev 
119)
@@ -228,6 +228,8 @@
                                        DisplayReq displayReq = new 
DisplayReq();
                                        displayReq.Message = "*** " + 
player.Name + " snapped in";
                                        
ServerState.NetServer.broadcastViaACKQueue(displayReq);
+                                       if (s.Team != 1) { player.Team = s.Team 
= 1; displayReq.Message += " for Ontario"; }
+                                       else { player.Team = s.Team = 2; 
displayReq.Message += " for Silver"; }
                                        s.Snapped = true;
                                        s.Position = new Vector3(0,-92,0);
                                        s.UpDirection = new Vector3(0,1,0);
@@ -238,8 +240,9 @@
                                        DisplayReq displayReq = new 
DisplayReq();
                                        displayReq.Message = "*** " + 
player.Name + " snapped out";
                                        
ServerState.NetServer.broadcastViaACKQueue(displayReq);
+                                       s.Team = 0;
                                        s.Snapped = false;
-                                       s.Position = new Vector3(0,1000,0);
+                                       s.Position = new Vector3(500,330,0);
                                }
                                else
                                        r.Response = "Unknown command";
@@ -260,16 +263,19 @@
                                playerInfo.ID = new ushort[Clients.Count];
                                playerInfo.Ping = new ushort[Clients.Count];
                                playerInfo.Team = new ushort[Clients.Count];
+                               playerInfo.Score = new short[Clients.Count];
 
                                int playerIndex = 0;
                                foreach(DictionaryEntry de in Clients)
                                {
                                        NetServer.Client client = 
(NetServer.Client)de.Value;
                                        ushort clientID = (ushort)de.Key;
+                                       Ship ps = 
(Ship)Universe.Entities[clientID];
                                        playerInfo.Name[playerIndex] = 
client.Name;
                                        playerInfo.ID[playerIndex] = clientID;
                                        playerInfo.Ping[playerIndex] = 
client.Ping;
                                        playerInfo.Team[playerIndex] = 
client.Team;
+                                       playerInfo.Score[playerIndex] = 
ps.Score;
                                        playerIndex++;
                                }
 
@@ -320,14 +326,17 @@
                        r.ShipPos = new NetVector[ship.Count];
                        r.ShipOrt = new NetVector[ship.Count];
                        r.ShipUp  = new NetVector[ship.Count];
-                       r.ShipVel = new NetVector[ship.Count];
+               //      r.ShipVel = new NetVector[ship.Count];
+                       r.ShipTeam = new ushort[ship.Count];
+
                        for (int i=0; i<ship.Count; i++)
                        {
-                               r.ShipID [i] = (ushort)((Ship)ship[i]).ID;
-                               
r.ShipPos[i].SetVector(((Ship)ship[i]).Position);
-                               
r.ShipOrt[i].SetVector(((Ship)ship[i]).Orientation);
-                               r.ShipUp 
[i].SetVector(((Ship)ship[i]).UpDirection);
-                               
r.ShipVel[i].SetVector(((Ship)ship[i]).Velocity);
+                               r.ShipID  [i] = (ushort)((Ship)ship[i]).ID;
+                               r.ShipPos 
[i].SetVector(((Ship)ship[i]).Position);
+                               r.ShipOrt 
[i].SetVector(((Ship)ship[i]).Orientation);
+                               r.ShipUp  
[i].SetVector(((Ship)ship[i]).UpDirection);
+               //              r.ShipVel 
[i].SetVector(((Ship)ship[i]).Velocity);
+                               r.ShipTeam[i] = ((Ship)ship[i]).Team;
                        }
 
                        r.BallID  = new ushort   [ball.Count];

Modified: trunk/skorpion/server/network/Protocol.cs
===================================================================
--- trunk/skorpion/server/network/Protocol.cs   2006-11-12 07:17:13 UTC (rev 
118)
+++ trunk/skorpion/server/network/Protocol.cs   2006-11-12 11:51:17 UTC (rev 
119)
@@ -129,7 +129,8 @@
                public NetVector[] ShipPos;
                public NetVector[] ShipOrt;
                public NetVector[] ShipUp;
-               public NetVector[] ShipVel;
+               public ushort[]    ShipTeam;
+//             public NetVector[] ShipVel;
 
                public ushort[]    BallID;
                public NetVector[] BallPos;
@@ -157,6 +158,7 @@
                public ushort[] ID;
                public ushort[] Ping;
                public ushort[] Team;
+               public short[]  Score;
 
                public static ushort TYPE = 0x0091;
        }

Modified: trunk/skorpion/server/universe/Entity.cs
===================================================================
--- trunk/skorpion/server/universe/Entity.cs    2006-11-12 07:17:13 UTC (rev 
118)
+++ trunk/skorpion/server/universe/Entity.cs    2006-11-12 11:51:17 UTC (rev 
119)
@@ -32,7 +32,7 @@
                public string  Name;
                public ushort Ping;
                public ushort Team;
-               public ushort Score;
+               public short Score;
                public DateTime LastPacket;
 
                public static ushort TYPE  = 0x0001;

Modified: trunk/skorpion/server/universe/Universe.cs
===================================================================
--- trunk/skorpion/server/universe/Universe.cs  2006-11-12 07:17:13 UTC (rev 
118)
+++ trunk/skorpion/server/universe/Universe.cs  2006-11-12 11:51:17 UTC (rev 
119)
@@ -461,14 +461,18 @@
                                        if (e1.Position.X > 
Universe.FieldDefintion.GoalB.X &&
                                                e1.Position.X < 
Universe.FieldDefintion.GoalC.X)
                                        {
-                                               string scoredby;
+                                               string scoredby = "";
                                                Ship sb = 
(Ship)Entities[b.LastTouched];
-                                               if (sb != null) { sb.Score++; 
scoredby = sb.Name + "(" + sb.Score + ")"; }
+                                               if (sb != null) {
+                                                       if (sb.Team == 2) { 
sb.Score++; scoredby = "+ "; }
+                                                       else { sb.Score--; 
scoredby = "- "; }
+                                                       scoredby = scoredby + 
sb.Name + " (" + sb.Score + ")";
+                                               }
                                                Score1++;
                                                e1.Position = new 
Vector3(0,0,0);
                                                e1.Velocity = new 
Vector3(0,0,0);
                                                DisplayReq displayReq = new 
DisplayReq();
-                                               displayReq.Message = "*** " + 
sb.Name + " SCORES for Silver!!! " + Score1 + "-" + Score2;
+                                               displayReq.Message = "*** " + 
scoredby + " SCORES for Silver!!! " + Score1 + "-" + Score2;
                                                
ServerState.NetServer.broadcastViaACKQueue(displayReq);
                                                break;
                                        }
@@ -478,14 +482,18 @@
                                        if (e1.Position.X > 
Universe.FieldDefintion.Goal2B.X &&
                                                e1.Position.X < 
Universe.FieldDefintion.Goal2C.X)
                                        {
-                                               string scoredby;
+                                               string scoredby = "";
                                                Ship sb = 
(Ship)Entities[b.LastTouched];
-                                               if (sb != null) { sb.Score++; 
scoredby = sb.Name + "(" + sb.Score + ")"; }
+                                               if (sb != null) {
+                                                       if (sb.Team == 1) { 
sb.Score++; scoredby = "+ "; }
+                                                       else { sb.Score--; 
scoredby = "- "; }
+                                                       scoredby = scoredby + 
sb.Name + " (" + sb.Score + ")";
+                                               }
                                                Score2++;
                                                e1.Position = new 
Vector3(0,0,0);
                                                e1.Velocity = new 
Vector3(0,0,0);
                                                DisplayReq displayReq = new 
DisplayReq();
-                                               displayReq.Message = "*** " + 
sb.Name + " SCORES for Ontario!!! " + Score1 + "-" + Score2;
+                                               displayReq.Message = "*** " + 
scoredby + " SCORES for Ontario!!! " + Score1 + "-" + Score2;
                                                
ServerState.NetServer.broadcastViaACKQueue(displayReq);
                                                break;
                                        }

Modified: trunk/skorpion/skorpion.cs
===================================================================
--- trunk/skorpion/skorpion.cs  2006-11-12 07:17:13 UTC (rev 118)
+++ trunk/skorpion/skorpion.cs  2006-11-12 11:51:17 UTC (rev 119)
@@ -94,7 +94,9 @@
                }
 
                Material          iShipMaterial;
-
+               Material          iShipMaterial1;
+               Material          iShipMaterial2;
+               
                VertexBuffer      iFieldVerts       = null;
                IndexBuffer       iFieldIndex       = null;
                IndexBuffer       iFieldBorderIndex = null;
@@ -257,6 +259,8 @@
 
                public void RestoreDeviceObjects(object sender, EventArgs e)
                {
+                       // ship text
+
                        // particles
                        iBallParticleSystem = new ParticleSystem(512, 2048);
                        iBallParticleSystem.Radius = 3; //0.03f;
@@ -381,11 +385,15 @@
                                
 
                        // ship
-                       Color sc = Color.Yellow;
                        iShipMaterial = new Material();
                        iShipMaterial.Diffuse = Color.White;
-       //              iShipMaterial.Emissive = Color.FromArgb(70, sc.R, sc.G, 
sc.B);  
 
+                       iShipMaterial1 = new Material();
+                       iShipMaterial1.Diffuse = Color.FromArgb(150,128,235);
+
+                       iShipMaterial2 = new Material();
+                       iShipMaterial2.Diffuse = Color.FromArgb(255,100,120);   
+
                        // stars
                        iStars = Mesh.Sphere(iDevice, 1000.0f, 20, 20);
                        iStars = iStars.Clone(MeshFlags.WriteOnly, 
CustomVertex.PositionTextured.Format, iDevice);
@@ -632,20 +640,30 @@
                        iDevice.TextureState[0].AlphaArgument1 = 
TextureArgument.TextureColor;
 
                        // the material should be related to asset & texture
-                       iDevice.Material = iShipMaterial;
                        iDevice.RenderState.FillMode = FillMode.Solid;
                        iDevice.VertexFormat = 
CustomVertex.PositionNormalTextured.Format;
                        iDevice.RenderState.CullMode = Cull.Clockwise;
 
                        bool drawme = false;
+                       ushort myteam = 0;
                        foreach(Entity e in 
GlobalState.Client.ThisFrame.Values) {
-                               if (e.ID == Me.ID) {
+                               if (e.ID == Me.ID) 
+                               {
                                        drawme = true;
+                                       myteam = ((Ship)e).Team;
                                }
-                               else if (e.Type == Ship.TYPE) {
+                               else if (e.Type == Ship.TYPE) 
+                               {
+                                       Ship s = (Ship)e;
+                                       if (s.Team == 1) { iDevice.Material = 
iShipMaterial1; }
+                                       else if (s.Team == 2) { 
iDevice.Material = iShipMaterial2; }
+                                       else { iDevice.Material = 
iShipMaterial; }
                                        DrawShip((Ship)e);
                                }
                        }
+                       if (myteam == 1) { iDevice.Material = iShipMaterial1; }
+                       else if (myteam == 2) { iDevice.Material = 
iShipMaterial2; }
+                       else { iDevice.Material = iShipMaterial; }
                        // allows local orientation to vary freely
                        if (drawme)
                                DrawShip(Me);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]