cinvoke-svn
[Top][All Lists]
Advanced

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

[cinvoke-svn] r117 - in trunk/skorpion: . assets server/game server/netw


From: will
Subject: [cinvoke-svn] r117 - in trunk/skorpion: . assets server/game server/network server/universe
Date: 12 Nov 2006 00:47:58 -0500

Author: p
Date: 2006-11-12 00:47:56 -0500 (Sun, 12 Nov 2006)
New Revision: 117

Added:
   trunk/skorpion/ParticleSystem.cs
   trunk/skorpion/assets/Particle.bmp
Modified:
   trunk/skorpion/Assets.cs
   trunk/skorpion/Chat.cs
   trunk/skorpion/Client.cs
   trunk/skorpion/Console.cs
   trunk/skorpion/Controller.cs
   trunk/skorpion/Form1.cs
   trunk/skorpion/PlayerList.cs
   trunk/skorpion/server/game/Server.cs
   trunk/skorpion/server/network/ACKQueue.cs
   trunk/skorpion/server/network/Protocol.cs
   trunk/skorpion/server/universe/Entity.cs
   trunk/skorpion/server/universe/Universe.cs
   trunk/skorpion/skorpion.cs
   trunk/skorpion/skorpion.csproj
Log:
skorp is BACK ONLINE!!!!!!!!!!!!



Modified: trunk/skorpion/Assets.cs
===================================================================
--- trunk/skorpion/Assets.cs    2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/Assets.cs    2006-11-12 05:47:56 UTC (rev 117)
@@ -152,8 +152,8 @@
                                                        int normindex = 
Convert.ToInt16(comps[2]) - 1;
 
                                                        
CustomVertex.PositionNormalTextured vert = new 
CustomVertex.PositionNormalTextured();
-                                                       
vert.SetPosition(ClientUtils.Vec((Vector3)tempverts[vertindex]));
-                                                       
vert.SetNormal(ClientUtils.Vec((Vector3)tempnorms[normindex]));
+                                                       vert.Position = 
ClientUtils.Vec((Vector3)tempverts[vertindex]);
+                                                       vert.Normal = 
ClientUtils.Vec((Vector3)tempnorms[normindex]);
                                                        vert.Tu = 
((Vector2)temptex[texindex]).X;
                                                        vert.Tv = 
((Vector2)temptex[texindex]).Y;
                                                        all.Add(vert);

Modified: trunk/skorpion/Chat.cs
===================================================================
--- trunk/skorpion/Chat.cs      2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/Chat.cs      2006-11-12 05:47:56 UTC (rev 117)
@@ -114,7 +114,7 @@
                        int red = Color.FromArgb(_alpha, r.R, r.G, 
r.B).ToArgb();
                        if(_state == ChatState.Typing)
                        {
-                               _font.DrawText(_entryLine.ToString(), new 
System.Drawing.Rectangle(2, line, 0, 0), DrawTextFormat.None, red);
+                               _font.DrawText(null, _entryLine.ToString(), new 
System.Drawing.Point(2, line), red);
                                line -= this.LineHeight;
                        }
                        if (_debug)
@@ -125,7 +125,7 @@
                        {
                                if (line > GlobalState.Form.Height - 150)
                                {
-                                       _font.DrawText(entry, new 
System.Drawing.Rectangle(2, line, 0, 0), DrawTextFormat.None, red);
+                                       _font.DrawText(null, entry, new 
System.Drawing.Point(2, line), red);
                                        line -= this.LineHeight;
                                }
                        }

Modified: trunk/skorpion/Client.cs
===================================================================
--- trunk/skorpion/Client.cs    2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/Client.cs    2006-11-12 05:47:56 UTC (rev 117)
@@ -17,12 +17,14 @@
                public Universe       Universe;
                public NetClient      Net;
                public bool           Ready;
+               public bool           Snapped;
 
                public ushort         MyID;
                public Ship           Me;
                public TokenVelocity  MyVelocity;
                public TokenVelocity  MyLastVelocity;
                public DateTime       BurstBegin;
+               public DateTime       FireBegin;
 
                public DateTime       LastSent;
                public DateTime       LastReceived;
@@ -49,6 +51,14 @@
                }
                public ArrayList      Collisions = new ArrayList();
                
+               public class CollisionOut
+               {
+                       public Vector3  point;
+                       public DateTime time;
+                       public CollisionOut(Vector3 p, DateTime t) { point=p; 
time=t; }
+               }
+               public ArrayList      CollisionsOut = new ArrayList();
+               
                public bool           HoldCamera;
                public Vector3        LastOrientation;
                public Vector3        LastUpDirection;
@@ -101,6 +111,8 @@
                                        Me.Position    = universeMe.Position;
                                        Me.Orientation = universeMe.Orientation;
                                        Me.UpDirection = universeMe.UpDirection;
+
+                                       snapIn(null);
                                }
                                else if (WorldRefresh.TYPE == 
((GameMsg)msg[i]).Type) 
                                {
@@ -163,6 +175,7 @@
 
                                                        e.Position = 
((Entity)de.Value).Position;
                                                        e.Active   = 
((Entity)de.Value).Active;
+                                                       e.Velocity = 
((Entity)de.Value).Velocity;
 
                                                        ThisFrame[e.ID] = e;
                                                }
@@ -182,6 +195,8 @@
 
                                                        e1.Position = 
m.CollisionPoint1[i].GetVector();
                                                        e2.Position = 
m.CollisionPoint2[i].GetVector();
+
+                                                       CollisionsOut.Add(new 
CollisionOut(e1.Position, DateTime.Now));
                                                }
                                                Collisions.Reverse();
                                        }
@@ -245,6 +260,8 @@
                                                continue;
 
                                        ((Entity)de.Value).Position  = 
((Entity)LastFrame[de.Key]).Position;
+
+                                       if (t > 0 && RefreshInterval > 0)
                                        ((Entity)de.Value).Position +=
                                                
(((Entity)NextFrame[de.Key]).Position - ((Entity)LastFrame[de.Key]).Position)
                                                * ((float)t / 
(float)RefreshInterval);
@@ -313,6 +330,29 @@
                        }
                }
 
+               public void fireStart(string s)
+               {
+                       FireBegin = DateTime.Now;
+               }
+
+               public void fireStop(string s)
+               {
+                       PlayerRefresh m = new PlayerRefresh();
+                       m.ShipOrt.SetVector(Me.Orientation);
+                       m.ShipUp.SetVector(Me.UpDirection);
+                       m.Velocity.SetVector(MyVelocity.Total(Me.Orientation, 
Me.UpDirection));
+                       m.Ping = Pinger.Send();
+
+                       int b = 
(int)(DateTime.Now.Subtract(FireBegin)).TotalMilliseconds;
+                       if (b > 65535) b = 65535;
+                       m.Fire = (ushort)b;
+                       // LOG.debug("sent burst " + m.Burst + " " + b);
+
+                       Net.send(m);
+
+                       LastSent = DateTime.Now;
+               }
+
                public void burstStart(string s)
                {
                        BurstBegin = DateTime.Now;
@@ -382,17 +422,45 @@
                        }
                }
 
-               public void rollLeft(int delta) {
+               public void Rcon(string s)
+               {
+                       RconReq m = new RconReq();
+                       m.Cmd = s;
+                       GlobalState.Client.Net.ACKQueue.Add(m);
+               }
+
+               public void snapIn(string s)
+               {
+                       Rcon("snapin");
+                       Snapped = true;
+                       Me.UpDirection = new Vector3(0,1,0);
+                       Me.Orientation = new Vector3(0,0,1);
+               }
+
+               public void snapOut(string s)
+               {
+                       Rcon("snapout");
+                       Snapped = false;
+               }
+
+               public void rollLeft(int delta) 
+               {
+                       if (!Snapped) {
                        Matrix rotation = 
Matrix.RotationAxis(ClientUtils.Vec(Me.Orientation), .001f * 
GlobalState.KeyboardSensitivity);
                        Me.UpDirection = 
ClientUtils.Vec(Microsoft.DirectX.Vector3.TransformCoordinate(ClientUtils.Vec(Me.UpDirection),
 rotation));
                }
+               }
                
-               public void rollRight(int delta) {
+               public void rollRight(int delta) 
+               {
+                       if (!Snapped) {
                        Matrix rotation = 
Matrix.RotationAxis(ClientUtils.Vec(Me.Orientation), -.001f * 
GlobalState.KeyboardSensitivity);
                        Me.UpDirection = 
ClientUtils.Vec(Microsoft.DirectX.Vector3.TransformCoordinate(ClientUtils.Vec(Me.UpDirection),
 rotation));
                }
+               }
 
                public void pitchUp(int delta) {
+                       if (!Snapped) {
                        Vector3 right = Vector3.Cross(Me.Orientation, 
Me.UpDirection);
                        right.Normalize();
 
@@ -400,8 +468,10 @@
                        Me.Orientation = 
ClientUtils.Vec(Microsoft.DirectX.Vector3.TransformCoordinate(ClientUtils.Vec(Me.Orientation),
 rotation));
                        Me.UpDirection = 
ClientUtils.Vec(Microsoft.DirectX.Vector3.TransformCoordinate(ClientUtils.Vec(Me.UpDirection),
 rotation));
                }
+               }
                
                public void pitchDown(int delta) {
+                       if (!Snapped) {
                        Vector3 right = Vector3.Cross(Me.Orientation, 
Me.UpDirection);
                        right.Normalize();
 
@@ -409,6 +479,7 @@
                        Me.Orientation = 
ClientUtils.Vec(Microsoft.DirectX.Vector3.TransformCoordinate(ClientUtils.Vec(Me.Orientation),
 rotation));
                        Me.UpDirection = 
ClientUtils.Vec(Microsoft.DirectX.Vector3.TransformCoordinate(ClientUtils.Vec(Me.UpDirection),
 rotation));
                }
+               }
 
                public void yawLeft(int delta) {
                        Matrix rotation = 
Matrix.RotationAxis(ClientUtils.Vec(Me.UpDirection), (float)delta * 
GlobalState.MouseSensitivity);
@@ -428,9 +499,9 @@
                public void moveLeftStop     (string s) { MyVelocity.left      
= false; }
                public void moveRightStart   (string s) { MyVelocity.right     
= true;  }
                public void moveRightStop    (string s) { MyVelocity.right     
= false; }
-               public void moveUpStart      (string s) { MyVelocity.up        
= true;  }
+               public void moveUpStart      (string s) { if (!Snapped) { 
MyVelocity.up = true; } }
                public void moveUpStop       (string s) { MyVelocity.up        
= false; }
-               public void moveDownStart    (string s) { MyVelocity.down      
= true;  }
+               public void moveDownStart    (string s) { if (!Snapped) { 
MyVelocity.down = true; } }
                public void moveDownStop     (string s) { MyVelocity.down      
= false; }
                public void rollLeftStart    (string s) { MyVelocity.rollLeft  
= true;  }
                public void rollLeftStop     (string s) { MyVelocity.rollLeft  
= false; }

Modified: trunk/skorpion/Console.cs
===================================================================
--- trunk/skorpion/Console.cs   2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/Console.cs   2006-11-12 05:47:56 UTC (rev 117)
@@ -176,7 +176,7 @@
                        // draw entry line
                        Color b = Color.Black;
                        int black = Color.FromArgb(_alpha, b.R, b.G, 
b.B).ToArgb();
-                       _font.DrawText(_entryLine.ToString(), new 
System.Drawing.Rectangle(2, line, 0, 0), DrawTextFormat.None, black);
+                       _font.DrawText(null, _entryLine.ToString(), new 
System.Drawing.Point(2, line), black);
                        line -= this.LineHeight;
 
                        if (_debug)
@@ -187,7 +187,7 @@
                        {
                                if (line > 5)
                                {
-                                       _font.DrawText(entry, new 
System.Drawing.Rectangle(2, line, 0, 0), DrawTextFormat.ExpandTabs, black);
+                                       _font.DrawText(null, entry, new 
System.Drawing.Point(2, line), black);
                                        line -= this.LineHeight;
                                }
                        }

Modified: trunk/skorpion/Controller.cs
===================================================================
--- trunk/skorpion/Controller.cs        2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/Controller.cs        2006-11-12 05:47:56 UTC (rev 117)
@@ -15,6 +15,10 @@
 
                public Command(GameClient c)
                {
+                       List["snapin"]      = new CallBack(c.snapIn);
+                       List["snapout"]     = new CallBack(c.snapOut);
+                       List["+fire"]       = new CallBack(c.fireStart);
+                       List["-fire"]       = new CallBack(c.fireStop);
                        List["+forward"]    = new CallBack(c.moveForwardStart);
                        List["-forward"]    = new CallBack(c.moveForwardStop);
                        List["+back"]       = new CallBack(c.moveBackwardStart);
@@ -108,6 +112,7 @@
                public void Name(string s)
                {
                        Rcon("name " + s);
+                       RegConfig.PlayerName = s;
                }
 
                public void Bind(string s)
@@ -171,7 +176,7 @@
                        if (s.Length > 0)
                        {
                                GlobalState.Client.Ready = false;
-                               if (GlobalState.Client.Net.connect(s, 
ServerConfig.DEFAULTPORT, ClientConfig.PlayerName, ClientConfig.Team))
+                               if (GlobalState.Client.Net.connect(s, 
ServerConfig.DEFAULTPORT, RegConfig.PlayerName, ClientConfig.Team))
                                        GlobalState.Console.Print("*** 
connecting to " + s);
                                else
                                        GlobalState.Console.Print("*** connect 
to " + s + " failed");
@@ -220,6 +225,9 @@
                        Add("f3",          "camera 3");
                        Add("f4",          "camera 4");
                        Add("mouse1",      "+burst");
+                       Add("mouse2",      "+fire");
+                       Add("i",           "snapin");
+                       Add("o",           "snapout");
                }
        }
 
@@ -427,7 +435,7 @@
                                                        s = s.Remove(0, 
1).Insert(0, "-");
                                                        
GlobalState.Command.Execute(s);
                                                }
-                                               else
+                                               else if (k.state == 
KeyInfo.State.DOWN)
                                                {
                                                        
GlobalState.Command.Execute(s);
                                                }

Modified: trunk/skorpion/Form1.cs
===================================================================
--- trunk/skorpion/Form1.cs     2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/Form1.cs     2006-11-12 05:47:56 UTC (rev 117)
@@ -6,6 +6,11 @@
 using System.Data;
 using System.IO;
 using System.Threading;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Xml.Serialization;
 
 namespace skorpion
 {
@@ -128,15 +133,17 @@
                        if (dirname == "Debug" || dirname == "Release")
                                Environment.CurrentDirectory = 
Environment.CurrentDirectory + @"\..\..";
 
+                       LoadConfig();
+
                        // bind the log callback before starting server if 
we're gonna start client
                        if (ClientConfig.ClientStart)
                        {
                                // in debug case we create a mutex and
                                // display messages from server thread in 
console
                                GlobalState.Console = new 
Console(ClientConfig.Debug);
+                               LOG.Callback = new 
LOG.CallBack(GlobalState.Console.Print);
                                if (ClientConfig.Debug)
                                {
-                                       LOG.Callback = new 
LOG.CallBack(GlobalState.Console.Print);
                                        LOG.level    = LOG.Level.DEBUG;
                                }
                                GlobalState.Chat = new Chat(ClientConfig.Debug);
@@ -151,7 +158,7 @@
                        }
                        
                        this.Text       = "Sk0rpion";
-                       this.ClientSize = new 
System.Drawing.Size(ClientConfig.FormWidth, ClientConfig.FormHeight);
+                       this.ClientSize = new 
System.Drawing.Size(RegConfig.FormWidth, RegConfig.FormHeight);
                        this.Closing   += new 
CancelEventHandler(this.OnClosing);
                        this.Resize    += new EventHandler(this.OnResize);
                        this.KeyPress  += new 
KeyPressEventHandler(this.OnKeyPress);
@@ -176,6 +183,105 @@
                                        System.Threading.Thread.Sleep(10);
                                }
                        }
+
+                       SaveConfig();
                }
+
+               // ----------- config file stuff -------
+
+               public static void SaveConfig()
+               {
+                       KeyValue[] kv = new 
KeyValue[typeof(RegConfig).GetFields().Length];
+                       int i = 0;
+                       foreach (FieldInfo fi in typeof(RegConfig).GetFields())
+                       {
+                               object val = fi.GetValue(null);
+
+                               if (val.GetType().IsEnum)
+                                       kv[i].Value = val.ToString();
+                               else
+                                       kv[i].Value = val;
+
+                               kv[i].Key   = fi.Name;
+                               i++;
+                       }
+                       DataStore.ToXmlFile("./config.xml", kv);
+               }
+
+               public void LoadConfig()
+               {
+                       KeyValue[] kv = 
(KeyValue[])DataStore.FromXmlFile("./config.xml", typeof(KeyValue[]));
+                       if (kv == null) return;
+
+                       Hashtable dict = new Hashtable();
+                       foreach (KeyValue x in kv) dict[x.Key] = x.Value;
+
+                       foreach (FieldInfo fi in typeof(RegConfig).GetFields())
+                               if (dict.ContainsKey(fi.Name))
+                               {
+                                       object val = fi.GetValue(null);
+
+                                       if (val.GetType().IsEnum) 
+                                               fi.SetValue(null, 
Enum.Parse(val.GetType(), (string)dict[fi.Name], true));
+                                       else
+                                               fi.SetValue(null, 
dict[fi.Name]);
+
+                               }
+               }
        }
+
+       [Serializable]
+       public struct KeyValue
+       {
+               public string Key;
+               public object Value;
+       }
+
+       public class DataStore
+       {
+               public static object FromXmlFile(string fileName, Type t)
+               {
+                       try 
+                       {
+                               FileStream s = new FileStream(fileName, 
FileMode.Open);
+                               XmlSerializer xs = new XmlSerializer(t);
+                               object ret = xs.Deserialize(s);
+                               s.Close();
+                               return ret;
+                       }
+
+                       catch { return null; }
+               }
+
+               public static void ToXmlFile(string fileName, object o)
+               {
+                       FileStream s = new FileStream(fileName, 
FileMode.Create);
+                       XmlSerializer xs = new XmlSerializer(o.GetType());
+                       xs.Serialize(s, o);
+                       s.Close();
+               }
+
+               public static object FromBinaryFile(string fileName)
+               {
+                       try 
+                       {
+                               FileStream s = new FileStream(fileName, 
FileMode.Open);
+                               BinaryFormatter bf = new BinaryFormatter();
+                               object ret = bf.Deserialize(s);
+                               s.Close();
+                               return ret;
+                       } 
+
+                       catch { return null; }
+               }
+
+               public static void ToBinaryFile(string fileName, object o)
+               {
+                       FileStream s = new FileStream(fileName, 
FileMode.Create);
+                       BinaryFormatter bf = new BinaryFormatter();
+                       bf.Serialize(s, o);
+                       s.Close();
+               }
+       }
 }
+

Added: trunk/skorpion/ParticleSystem.cs
===================================================================
--- trunk/skorpion/ParticleSystem.cs                            (rev 0)
+++ trunk/skorpion/ParticleSystem.cs    2006-11-12 05:47:56 UTC (rev 117)
@@ -0,0 +1,361 @@
+using System;
+using System.Windows.Forms;
+using System.Collections;
+using Microsoft.DirectX;
+using Microsoft.DirectX.Direct3D;
+    
+namespace skorpion
+{
+       public class ParticleSystem
+       {
+               public struct PointVertex
+               {
+                       public Vector3 v;
+                       public int color;
+                       public static readonly VertexFormats Format =  
VertexFormats.Position | VertexFormats.Diffuse;
+               };
+
+               public struct Particle
+               {
+                       public bool isSpark;
+
+                       public Vector3 positionVector;
+                       public Vector3 velocityVector;
+
+                       public Vector3 initialPosition;
+                       public Vector3 initialVelocity;
+                       public float creationTime;
+
+                       public System.Drawing.Color diffuseColor;
+                       public System.Drawing.Color fadeColor;
+                       public float fadeProgression;
+               };
+
+               private float _time;
+               private int _particleCount;
+               
+               private float _radius;
+               public float Radius
+               {
+                       set{ _radius = value; }
+               }
+
+               private int _particlesLimit;
+               public int ParticlesLimit
+               {
+                       set {_particlesLimit = value;}
+               }
+
+               private int _numParticlesToEmit;
+               public int NumParticlesToEmit
+               {
+                       set{ _numParticlesToEmit = value; }
+               }
+
+               private float _emitVelocity;
+               public float EmitVelocity
+               {
+                       set{ _emitVelocity = value; }
+               }
+               
+               // has to do with streaming VertexBuffers
+               private int _baseParticle = 0;
+               private int _flush = 0;
+               private int _discard = 0;
+
+               private System.Collections.ArrayList _particlesList;
+               private System.Collections.ArrayList _freeParticles;
+
+               private System.Random _rand;
+
+               private VertexBuffer _vertexBuffer = null;
+
+               public ParticleSystem(int numFlush, int numDiscard)
+               {
+                       _time = 0.0f;                           // elapsed 
since system initialization
+                       _particleCount = 0;                     // currently in 
scene
+                       _radius = 1;                            // unknown
+                       _particlesLimit = 32;           // number of particles
+                       _numParticlesToEmit = 1;        // per frame
+                       _emitVelocity = 32.0f;          // straight up
+
+                       // used for streaming via VertexBuffer
+                       _baseParticle = numDiscard;
+                       _flush = numFlush;
+                       _discard = numDiscard;
+
+                       _rand = new System.Random();
+                       _particlesList = new ArrayList();
+                       _freeParticles = new ArrayList();
+               }
+
+               // Create a vertex buffer for the particle system.  The size of 
this buffer
+               // does not relate to the number of particles that exist.  
Rather, the
+               // buffer is used as a communication channel with the device.. 
we fill in 
+               // a bit, and tell the device to draw.  While the device is 
drawing, we
+               // fill in the next bit using NOOVERWRITE.  We continue doing 
this until 
+               // we run out of vertex buffer space, and are forced to DISCARD 
the buffer
+               // and start over at the beginning.
+               public void RestoreDeviceObjects(Device dev)
+               {
+                       _vertexBuffer = new VertexBuffer(typeof(PointVertex),
+                                                                               
         _discard,
+                                                                               
         dev,
+                                                                               
         Usage.Dynamic | Usage.WriteOnly | Usage.Points,
+                                                                               
         PointVertex.Format,
+                                                                               
         Pool.Default);
+               }
+
+               // update the time and the position/velocity of the emitter
+               public void Update(float fSecsPerFrame,
+                       System.Drawing.Color clrEmitColor, System.Drawing.Color 
clrFadeColor,
+                       Vector3 vPosition, Vector3 vVelocity)
+               {
+                       _time += fSecsPerFrame;
+                       
+                       for(int ii = _particlesList.Count-1; ii >= 0; ii--)
+                       {
+                               Particle p = (Particle)_particlesList[ii];
+                               
+                               // Calculate new position
+                               float fT = _time - p.creationTime;
+                               float fGravity;
+
+                               if (p.isSpark)
+                               {
+                                       fGravity = -5.0f;
+                                       p.fadeProgression -= (fSecsPerFrame * 
2.25f);
+                               }
+                               else
+                               {
+                                       fGravity = -9.8f;
+                                       p.fadeProgression -= fSecsPerFrame * 
0.25f;
+                               }
+
+                               p.positionVector    = p.initialVelocity * fT + 
p.initialPosition;
+                               p.positionVector.Y += (0.5f * fGravity) * (fT * 
fT);
+                               p.velocityVector.Y  = p.initialVelocity.Y + 
fGravity * fT;
+
+                               if (p.fadeProgression < 0.0f)
+                                       p.fadeProgression = 0.0f;
+
+                               // remove particles that are too far from their 
emitter
+#if false
+                               //if(p.positionVector.Length() > 180)
+                               if(fT > 10 || fT < .01)
+                               {
+                                       freeParticles.Add(p);
+                                       particlesList.RemoveAt(ii);
+
+                                       if (!p.isSpark)
+                                               particles--;
+                               }
+                               else
+                                       particlesList[ii] = p;
+#endif
+
+                               // remove particles... or if they are a spark 
that has faded
+#if true
+                               // Kill old particles
+                               if (p.positionVector.Y + 100 < _radius ||
+                                       p.isSpark && p.fadeProgression <= 0.0f)
+                               {
+                                       // Emit sparks
+                                       if (!p.isSpark)
+                                       {
+                                               for (int i=0; i<4; i++)
+                                               {
+                                                       Particle spark;
+
+                                                       if 
(_freeParticles.Count > 0)
+                                                       {
+                                                               spark = 
(Particle)_freeParticles[0];
+                                                               
_freeParticles.RemoveAt(0);
+                                                       }
+                                                       else
+                                                       {
+                                                               spark = new 
Particle();
+                                                       }
+
+                                                       spark.isSpark  = true;
+                                                       spark.initialVelocity = 
new Vector3();
+                                                       spark.initialPosition   
= p.positionVector;
+                                                       spark.initialPosition.Y 
= _radius;
+
+                                                       float fRand1 = 
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 2.00f;
+                                                       float fRand2 = 
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 0.25f;
+
+                                                       spark.initialVelocity.X 
 = p.velocityVector.X * 0.25f + (float)Math.Cos(fRand1) * 
(float)Math.Sin(fRand2);
+                                                       spark.initialVelocity.Z 
 = p.velocityVector.Z * 0.25f + (float)Math.Sin(fRand1) * 
(float)Math.Sin(fRand2);
+                                                       spark.initialVelocity.Y 
 = (float)Math.Cos(fRand2);
+                                                       spark.initialVelocity.Y 
*= ((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * 1.5f;
+
+                                                       spark.positionVector = 
spark.initialPosition;
+                                                       spark.velocityVector = 
spark.initialVelocity;
+
+                                                       spark.diffuseColor = 
ColorOperator.Lerp(p.fadeColor, p.diffuseColor, p.fadeProgression);
+                                                       spark.fadeColor = 
System.Drawing.Color.Black;
+                                                       spark.fadeProgression   
= 1.0f;
+                                                       spark.creationTime  = 
_time;
+
+                                                       
_particlesList.Add(spark);
+                                               }
+                                       }
+
+                                       // Kill particle
+                                       _freeParticles.Add(p);
+                                       _particlesList.RemoveAt(ii);
+
+                                       if (!p.isSpark)
+                                               _particleCount--;
+                               }
+                               else
+                                       _particlesList[ii] = p;
+#endif
+                       }
+
+                       // emit NumParticlesToEmit new particles, but dont 
exceed _particlesLimit 
+                       int particlesEmit = _particleCount + 
_numParticlesToEmit;
+                       while(_particleCount < _particlesLimit && 
_particleCount < particlesEmit)
+                       {
+                               Particle particle;
+
+                               if (_freeParticles.Count > 0)
+                               {
+                                       particle = (Particle)_freeParticles[0];
+                                       _freeParticles.RemoveAt(0);
+                               }
+                               else
+                               {
+                                       particle = new Particle();
+                               }
+
+                               // Emit new particle
+                               float fRand1 = 
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 2.0f;
+                               float fRand2 = 
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 0.25f;
+
+                               particle.isSpark = false;
+
+                               particle.initialPosition = vPosition + new 
Vector3(0.0f, _radius, 0.0f);
+
+                               particle.initialVelocity.X  = 
(float)Math.Cos(fRand1) * (float)Math.Sin(fRand2) * 2.5f;
+                               particle.initialVelocity.Z  = 
(float)Math.Sin(fRand1) * (float)Math.Sin(fRand2) * 2.5f;
+                               particle.initialVelocity.Y  = 
(float)Math.Cos(fRand2);
+                               particle.initialVelocity.Y *= 
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * _emitVelocity;
+                               //particle.initialVelocity = vVelocity;
+                               particle.initialVelocity.X += 
(float)Math.Cos(fRand1) * (float)Math.Sin(fRand2) * .5f;
+                               particle.initialVelocity.Y += 
(float)Math.Sin(fRand1) * (float)Math.Sin(fRand2) * .5f;
+                               particle.initialVelocity.Z += 
(float)Math.Sin(fRand1) * (float)Math.Cos(fRand2) * .5f;
+
+                               //particle.initialVelocity.Scale(-10);
+
+                               particle.positionVector = 
particle.initialPosition;
+                               particle.velocityVector = 
particle.initialVelocity;
+
+                               particle.diffuseColor = clrEmitColor;
+                               particle.fadeColor    = clrFadeColor;
+                               particle.fadeProgression      = 1.0f;
+                               particle.creationTime     = _time;
+
+                               _particlesList.Add(particle);
+                               _particleCount++;
+                       }
+               }
+
+               public void Render(Device dev)
+               {
+                       // Set the render states for using point sprites
+                       dev.RenderState.PointSpriteEnable = true;
+                       dev.RenderState.PointScaleEnable = true ;
+                       dev.RenderState.PointSize = 0.8f; //0.08f;
+                       dev.RenderState.PointSizeMin = 0.00f;
+                       dev.RenderState.PointScaleA = 0.00f;
+                       dev.RenderState.PointScaleB = 0.00f;
+                       dev.RenderState.PointScaleC = 1.00f;
+
+                       // Set up the vertex buffer to be rendered
+                       dev.SetStreamSource(0, _vertexBuffer, 0);
+                       dev.VertexFormat = PointVertex.Format;
+
+                       PointVertex[] vertices = null;
+                       int numParticlesToRender = 0;
+
+                       // Lock the vertex buffer.  We fill the vertex buffer 
in small
+                       // chunks, using LockFlags.NoOverWrite.  When we are 
done filling
+                       // each chunk, we call DrawPrim, and lock the next 
chunk.  When
+                       // we run out of space in the vertex buffer, we start 
over at
+                       // the beginning, using LockFlags.Discard.
+
+                       _baseParticle += _flush;
+
+                       if (_baseParticle >= _discard)
+                               _baseParticle = 0;
+
+                       int count = 0;
+                       vertices = 
(PointVertex[])_vertexBuffer.Lock(_baseParticle * 
DXHelp.GetTypeSize(typeof(PointVertex)), typeof(PointVertex), (_baseParticle != 
0) ? LockFlags.NoOverwrite : LockFlags.Discard, _flush);
+                       foreach(Particle p in _particlesList)
+                       {
+                               Vector3 vPos = p.positionVector;
+                               Vector3 vVel = p.velocityVector;
+                               float fLengthSq = vVel.Length() * 
vVel.Length(); //vVel.LengthSq();
+                               uint steps;
+
+                               if (fLengthSq < 1.0f)        steps = 2;
+                               else if (fLengthSq <  4.00f) steps = 3;
+                               else if (fLengthSq <  9.00f) steps = 4;
+                               else if (fLengthSq < 12.25f) steps = 5;
+                               else if (fLengthSq < 16.00f) steps = 6;
+                               else if (fLengthSq < 20.25f) steps = 7;
+                               else                          steps = 8;
+
+                               vVel *= -0.04f / (float)steps;
+
+                               System.Drawing.Color diffuse = 
ColorOperator.Lerp(p.fadeColor, p.diffuseColor, p.fadeProgression);
+
+                               // Render each particle a bunch of times to get 
a blurring effect
+                               for (int i = 0; i < steps; i++)
+                               {
+                                       vertices[count].v     = vPos;
+                                       vertices[count].color = 
diffuse.ToArgb();
+                                       count++;
+
+                                       if (++numParticlesToRender == _flush)
+                                       {
+                                               // Done filling this chunk of 
the vertex buffer.  Lets unlock and
+                                               // draw this portion so we can 
begin filling the next chunk.
+
+                                               _vertexBuffer.Unlock();
+
+                                               
dev.DrawPrimitives(PrimitiveType.PointList, _baseParticle, 
numParticlesToRender);
+
+                                               // Lock the next chunk of the 
vertex buffer.  If we are at the 
+                                               // end of the vertex buffer, 
LockFlags.Discard the vertex buffer and start
+                                               // at the beginning.  
Otherwise, specify LockFlags.NoOverWrite, so we can
+                                               // continue filling the VB 
while the previous chunk is drawing.
+                                               _baseParticle += _flush;
+
+                                               if (_baseParticle >= _discard)
+                                                       _baseParticle = 0;
+
+                                               vertices = 
(PointVertex[])_vertexBuffer.Lock(_baseParticle * 
DXHelp.GetTypeSize(typeof(PointVertex)), typeof(PointVertex), (_baseParticle != 
0) ? LockFlags.NoOverwrite : LockFlags.Discard, _flush);
+                                               count = 0;
+
+                                               numParticlesToRender = 0;
+                                       }
+
+                                       vPos += vVel;
+                               }
+                       }
+
+                       // Unlock the vertex buffer
+                       _vertexBuffer.Unlock();
+                       // Render any remaining particles
+                       if (numParticlesToRender > 0)
+                               dev.DrawPrimitives(PrimitiveType.PointList, 
_baseParticle, numParticlesToRender);
+
+                       // Reset render states
+                       dev.RenderState.PointSpriteEnable = false;
+                       dev.RenderState.PointScaleEnable = false;
+               }
+       }
+}
\ No newline at end of file

Modified: trunk/skorpion/PlayerList.cs
===================================================================
--- trunk/skorpion/PlayerList.cs        2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/PlayerList.cs        2006-11-12 05:47:56 UTC (rev 117)
@@ -108,12 +108,12 @@
                        if (_debug)
                                _lock.WaitOne();
 
-                       _font.DrawText(":SupeR Sk0rp1on B4LL 6oo6:", new 
System.Drawing.Rectangle(_leftMargin+60, line, 0, 0), 
DrawTextFormat.ExpandTabs, black);
+                       _font.DrawText(null, ":SupeR Sk0rp1on B4LL 6oo6:", new 
System.Drawing.Point(_leftMargin+60, line), black);
                        line += this.LineHeight;
 
-                       _font.DrawText("Team 1: silver", new 
System.Drawing.Rectangle(_leftMargin+140, line, 0, 0), 
DrawTextFormat.ExpandTabs, black);
+                       _font.DrawText(null, "Team 1: silver", new 
System.Drawing.Point(_leftMargin+140, line), black);
                        line += this.LineHeight;
-                       _font.DrawText("name     ping", new 
System.Drawing.Rectangle(_leftMargin+10, line, 0, 0), 
DrawTextFormat.ExpandTabs, black);
+                       _font.DrawText(null, "name     ping", new 
System.Drawing.Point(_leftMargin+10, line), black);
                        line += this.LineHeight;
 
                        // draw team 1 entries
@@ -125,16 +125,16 @@
                                        if(ship.Team == 1)
                                        {
                                                string playerLine = ship.Name + 
"     " + ship.Ping;
-                                               _font.DrawText(playerLine, new 
System.Drawing.Rectangle(_leftMargin+10, line, 0, 0), 
DrawTextFormat.ExpandTabs, black);
+                                               _font.DrawText(null, 
playerLine, new System.Drawing.Point(_leftMargin+10, line), black);
                                                line += this.LineHeight;
                                        }
                                }
                        }
 
                        line += this.LineHeight;
-                       _font.DrawText("Team 2: ontario", new 
System.Drawing.Rectangle(_leftMargin+135, line, 0, 0), 
DrawTextFormat.ExpandTabs, black);
+                       _font.DrawText(null, "Team 2: ontario", new 
System.Drawing.Point(_leftMargin+135, line), black);
                        line += this.LineHeight;
-                       _font.DrawText("name     ping", new 
System.Drawing.Rectangle(_leftMargin+10, line, 0, 0), 
DrawTextFormat.ExpandTabs, black);
+                       _font.DrawText(null, "name     ping", new 
System.Drawing.Point(_leftMargin+10, line), black);
                        line += this.LineHeight;
 
                        // draw team 2 entries
@@ -146,7 +146,7 @@
                                        if(ship.Team == 2)
                                        {
                                                string playerLine = ship.Name + 
"     " + ship.Ping;
-                                               _font.DrawText(playerLine, new 
System.Drawing.Rectangle(_leftMargin+10, line, 0, 0), 
DrawTextFormat.ExpandTabs, black);
+                                               _font.DrawText(null, 
playerLine, new System.Drawing.Point(_leftMargin+10, line), black);
                                                line += this.LineHeight;
                                        }
                                }

Added: trunk/skorpion/assets/Particle.bmp
===================================================================
(Binary files differ)


Property changes on: trunk/skorpion/assets/Particle.bmp
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/skorpion/server/game/Server.cs
===================================================================
--- trunk/skorpion/server/game/Server.cs        2006-11-07 21:30:44 UTC (rev 
116)
+++ trunk/skorpion/server/game/Server.cs        2006-11-12 05:47:56 UTC (rev 
117)
@@ -11,8 +11,6 @@
                private Hashtable Clients;
                private Pinger    Pinger;
                private DateTime  LastRefreshTime;
-
-               private ushort    IDnext;
                
                public GameServer(Universe u)
                {
@@ -23,7 +21,7 @@
                        LastRefreshTime = DateTime.Now;
 
                        for (int i=0; i<ServerConfig.GameBalls; i++)
-                               NewBall(AllocID());
+                               NewBall(Universe.AllocID());
                }
 
                Random random = new Random(System.DateTime.Now.Millisecond);
@@ -58,21 +56,9 @@
                        Universe.Entities.Add(id, s);
                }
 
-               private ushort AllocID()
-               {
-                       do 
-                       {
-                               IDnext++;
-                               if (IDnext == 0) IDnext++;
-                       }
-                       while(Universe.Entities.Contains(IDnext));
-
-                       return IDnext;
-               }
-               
                public void Join(NetServer.Connection c, NetServer.Client p)
                {
-                       ushort id = AllocID();
+                       ushort id = Universe.AllocID();
                        Conns[c] = id;
                        Clients[id] = p;
                        NewShip(id);
@@ -82,7 +68,12 @@
                {
                        ushort id = (ushort)Conns[c];
                        Conns.Remove(c);
+                       Clients.Remove(id);
                        Universe.Entities.Remove(id);
+
+                       DisplayReq displayReq = new DisplayReq();
+                       displayReq.Message = "*** " + p.Name + " leaves";
+                       ServerState.NetServer.broadcastViaACKQueue(displayReq);
                }
 
                public void Msg(NetServer.Connection conn, NetServer.Client 
player, GameMsg GameMsg)
@@ -99,6 +90,7 @@
                        ushort id = (ushort)Conns[conn];
                        Ship   s  = (Ship)Universe.Entities[id];
 
+
                        if (JoinReq.TYPE == GameMsg.Type)
                        {
                                JoinReq m = (JoinReq)GameMsg;
@@ -139,6 +131,10 @@
                                if (m.Burst != 0)
                                        s.Burst = m.Burst;
 
+                               if (m.Fire != 0) 
+                               {
+                                       //      s.Fire = m.Fire;
+                               }
                                player.Pinger.Receive(m.Ping, ref player.Ping);
                        }
                        else if (RconReq.TYPE == GameMsg.Type)
@@ -177,6 +173,16 @@
                                        else
                                                r.Response = "Not 
Authenticated";                                               
                                }
+                               else if (cmd == "reset")
+                               {
+                                       Universe.Score1 = 0;
+                                       Universe.Score2 = 0;
+                                       r.Response = "*** " + player.Name + " 
reset score";
+                                       DisplayReq displayReq = new 
DisplayReq();
+                                       displayReq.Message = r.Response;
+
+                                       
ServerState.NetServer.broadcastViaACKQueue(displayReq);
+                               }
                                else if (cmd == "say")
                                {
                                        r.Response = "Message Sent: " + args;
@@ -187,14 +193,35 @@
                                }
                                else if (cmd == "name")
                                {
-                                       r.Response = "*** '" + player.Name + "' 
changed name to '" + args + "'";
+                                       r.Response = "*** " + player.Name + " 
changed name to " + args;
                                        player.Name = args;
+                                       s.Name = player.Name;
 
                                        DisplayReq displayReq = new 
DisplayReq();
                                        displayReq.Message = r.Response;
 
                                        
ServerState.NetServer.broadcastViaACKQueue(displayReq);
                                }
+                               else if (cmd == "snapin")
+                               {
+                                       r.Response = "*** " + player.Name + " 
snapped in";
+                                       DisplayReq displayReq = new 
DisplayReq();
+                                       displayReq.Message = r.Response;
+                                       
ServerState.NetServer.broadcastViaACKQueue(displayReq);
+                                       s.Snapped = true;
+                                       s.Position = new Vector3(0,-92,0);
+                                       s.UpDirection = new Vector3(0,1,0);
+                                       s.Orientation = new Vector3(0,0,1);
+                               }
+                               else if (cmd == "snapout")
+                               {
+                                       r.Response = "*** " + player.Name + " 
snapped out";
+                                       DisplayReq displayReq = new 
DisplayReq();
+                                       displayReq.Message = r.Response;
+                                       
ServerState.NetServer.broadcastViaACKQueue(displayReq);
+                                       s.Snapped = false;
+                                       s.Position = new Vector3(0,1000,0);
+                               }
                                else
                                        r.Response = "Unknown command";
 

Modified: trunk/skorpion/server/network/ACKQueue.cs
===================================================================
--- trunk/skorpion/server/network/ACKQueue.cs   2006-11-07 21:30:44 UTC (rev 
116)
+++ trunk/skorpion/server/network/ACKQueue.cs   2006-11-12 05:47:56 UTC (rev 
117)
@@ -15,6 +15,7 @@
 
                public ushort Send()
                {
+                       // the pinger code dosnt make sense and it isnt used 
for anything
                        NextID = (byte)((NextID + 1) % 16);
 
                        ushort   ping         = 0;

Modified: trunk/skorpion/server/network/Protocol.cs
===================================================================
--- trunk/skorpion/server/network/Protocol.cs   2006-11-07 21:30:44 UTC (rev 
116)
+++ trunk/skorpion/server/network/Protocol.cs   2006-11-12 05:47:56 UTC (rev 
117)
@@ -114,6 +114,7 @@
                public NetVector ShipUp;
 
                public ushort    Burst;
+               public ushort    Fire;
 
                public static ushort TYPE = 0x0040;
        }

Modified: trunk/skorpion/server/universe/Entity.cs
===================================================================
--- trunk/skorpion/server/universe/Entity.cs    2006-11-07 21:30:44 UTC (rev 
116)
+++ trunk/skorpion/server/universe/Entity.cs    2006-11-12 05:47:56 UTC (rev 
117)
@@ -11,9 +11,13 @@
                public Vector3 Position;
                public Vector3 Velocity;
                public ushort  Burst;
+               public ushort   Fire;
                public string  Asset;
                public string  Texture;
+               public ushort   DieIn;
+               public DateTime DieStart;
                public bool    Active;
+               public bool     Snapped;
 
                public Entity(ushort id, ushort type, float radius, string 
asset, string texture)
                {
@@ -28,6 +32,8 @@
                public string  Name;
                public ushort Ping;
                public ushort Team;
+               public ushort Score;
+               public DateTime LastPacket;
 
                public static ushort TYPE  = 0x0001;
                public static string ASSET = "a1a";
@@ -38,6 +44,7 @@
 
        public class Ball : Entity
        {
+               public ushort LastTouched;
                public static ushort TYPE  = 0x0060;
                public static string ASSET = "";
                public static string TEXTURE = "";

Modified: trunk/skorpion/server/universe/Universe.cs
===================================================================
--- trunk/skorpion/server/universe/Universe.cs  2006-11-07 21:30:44 UTC (rev 
116)
+++ trunk/skorpion/server/universe/Universe.cs  2006-11-12 05:47:56 UTC (rev 
117)
@@ -22,6 +22,9 @@
                Rules     Rules     = null;
                Field     BallField = null;
                float     Epsilon   = 0.01f;
+               ushort    IDnext    = 1;
+               public int       Score1    = 0;
+               public int       Score2    = 0;
                
                public Universe()
                {
@@ -37,8 +40,30 @@
                        LastTime  = DateTime.Now;
                }
 
+               public ushort AllocID()
+               {
+                       do 
+                       {
+                               IDnext++;
+                               if (IDnext == 0) IDnext++;
+                       }
+                       while(Entities.Contains(IDnext));
+
+                       return IDnext;
+               }
+
                public struct FieldDefintion
                {
+                       public static Vector3 GoalA = new Vector3(-50, 100, 
540);
+                       public static Vector3 GoalB = new Vector3(-50, -99, 
540);
+                       public static Vector3 GoalC = new Vector3( 50, -99, 
540);
+                       public static Vector3 GoalD = new Vector3( 50, 100, 
540);
+
+                       public static Vector3 Goal2A = new Vector3(-50, 100, 
-540);
+                       public static Vector3 Goal2B = new Vector3(-50, -99, 
-540);
+                       public static Vector3 Goal2C = new Vector3( 50, -99, 
-540);
+                       public static Vector3 Goal2D = new Vector3( 50, 100, 
-540);
+
                        // way back - upper left
                        public static Vector3 A = new Vector3(-340,  100,  540);
                        // way back - lower left
@@ -228,10 +253,49 @@
                                        }
                                }
                        }
+
+                       for (int i=0; i<RunSet.Count; i++)
+                       {
+                               RunState r = (RunState)RunSet[i];
+                               Ship     s = (Ship)r.e;
+
+                               if (s.Fire > 0) 
+                               {
+                                       ushort id = AllocID();
+                                       Entity b = new Ball(id);
+                                       b.Position = s.Position + 
s.Orientation*3;
+                                       b.Velocity = s.Orientation * 10;
+                                       b.DieIn    = 5;
+                                       b.DieStart = DateTime.Now;
+
+                                       Entities.Add(id, b);
+                                       s.Fire = 0;
+                               }
+                       }
+
+                       ArrayList DeleteSet = new ArrayList();
+
                        foreach(Entity e in Entities.Values)
+                       {
                                if (e.Type != Ship.TYPE)
+                               {
+                                       if (e.DieIn > 0 && 
(DateTime.Now.Subtract(e.DieStart)).TotalMilliseconds > e.DieIn * 1000)
+                                       {
+                                               DeleteSet.Add(e);
+                                       }
+                                       else
+                                       {
                                        RunSet.Add(new RunState(e, 
(float)deltaTime));
+                                       }
+                               }
+                       }
 
+                       for (int i=0; i<DeleteSet.Count; i++)
+                       {
+                               Entity e = (Entity)DeleteSet[i];
+                               Entities.Remove(e.ID);
+                       }
+
                        bool collisionsOccured = true;
                        while(collisionsOccured)
                        {
@@ -253,7 +317,7 @@
                                                Entity   e2 = r2.e;
 
                                                // only ships n balls for now
-                                               if (e1.Type == Ship.TYPE || 
e2.Type == Ball.TYPE)
+                                               if (e1.Type == Ship.TYPE && 
e2.Type == Ball.TYPE)
                                                {
                                                        Ship s = (Ship)e1;
 
@@ -317,9 +381,10 @@
                                                        continue;
 
                                                // again only for balls n ships
-                                               if (e1.Type == Ship.TYPE || 
e2.Type == Ball.TYPE)
+                                               if (e1.Type == Ship.TYPE && 
e2.Type == Ball.TYPE)
                                                {
                                                        Ship s = (Ship)e1;
+                                                       Ball b = (Ball)e2;
 
                                                        // advance to collision 
point
                                                        s.Position  += 
s.Velocity * CE.gameTime;
@@ -334,6 +399,8 @@
                                                        r2.time -= CE.gameTime;
 
                                                        Bounce(e2, 
s.Orientation, s.Velocity);
+                                                       e2.Velocity *= 1.3f;
+                                                       b.LastTouched = s.ID;
 
                                                        alreadyCollided[r1] = 
true;
                                                        alreadyCollided[r2] = 
true;
@@ -379,6 +446,7 @@
                {               
                        // slow the ball down a bit
                        // e1.Velocity *= f;
+                       Ball b = (Ball)e1;
 
                        // compute game field wall collisions
                        for (int k = 0; k < BallField.Planes.Length; k++)
@@ -386,6 +454,42 @@
                                float distance = clipPlane(e1.Position, 
BallField.Planes[k]);
                                if (distance > 0)
                                        continue;
+
+                               // GOALS!!!!!!!
+                               if (k == 0)
+                               {
+                                       if (e1.Position.X > 
Universe.FieldDefintion.GoalB.X &&
+                                               e1.Position.X < 
Universe.FieldDefintion.GoalC.X)
+                                       {
+                                               string scoredby;
+                                               Ship sb = 
(Ship)Entities[b.LastTouched];
+                                               if (sb != null) { sb.Score++; 
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;
+                                               
ServerState.NetServer.broadcastViaACKQueue(displayReq);
+                                               break;
+                                       }
+                               }
+                               else if (k == 5)
+                               {
+                                       if (e1.Position.X > 
Universe.FieldDefintion.Goal2B.X &&
+                                               e1.Position.X < 
Universe.FieldDefintion.Goal2C.X)
+                                       {
+                                               string scoredby;
+                                               Ship sb = 
(Ship)Entities[b.LastTouched];
+                                               if (sb != null) { sb.Score++; 
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;
+                                               
ServerState.NetServer.broadcastViaACKQueue(displayReq);
+                                               break;
+                                       }
+                               }
                                /*
                                Vector3 normal = new Vector3();
                                normal.X = BallField.Planes[k].A;

Modified: trunk/skorpion/skorpion.cs
===================================================================
--- trunk/skorpion/skorpion.cs  2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/skorpion.cs  2006-11-12 05:47:56 UTC (rev 117)
@@ -1,3 +1,18 @@
+/*
+ * chipping
+ * instant replay
+ * disconnect bug
+ * connection black screen bug
+ * individual scoring with updated tab thing
+ * improved particles
+ * thruster fire
+ * some indication of speed
+ * zones in field where you can do different htings
+ * 3d playing
+ * playing in web control
+ * space physics
+ * cvs
+ */
 using System;
 using System.Drawing;
 using System.Windows.Forms;
@@ -9,6 +24,13 @@
 
 namespace skorpion
 {
+       public class RegConfig
+       {
+               public static string        PlayerName          = "du0d";
+               public static int           FormWidth           = 800;
+               public static int           FormHeight          = 600;
+       }
+
        public class ClientConfig
        {
                public static bool          Debug               = false;
@@ -17,17 +39,13 @@
                public static DeviceType    DevType             = 
DeviceType.Hardware;
                public static CreateFlags   DevFlags            = 
CreateFlags.HardwareVertexProcessing;
 
-               public static int           FormWidth           = 800;
-               public static int           FormHeight          = 600;
+               public static ushort        Team                = 1;
 
-               public static string        PlayerName          = "player";
-               public static ushort        Team                = 2;
-
                public static bool          ClientStart         = true;
                public static string        ClientConnect       = "pleep.com";
                public static ushort        ClientPort          = 
ServerConfig.DEFAULTPORT;
                        
-               public static bool          ServerStart         = true;
+               public static bool          ServerStart         = false;
 
                public static TimeSpan      ConsoleOpen         = new 
TimeSpan(0,0,0,0,500);
                public static TimeSpan      ClientKeyRepeat     = new 
TimeSpan(0,0,0,0,200);
@@ -82,6 +100,15 @@
                IndexBuffer       iFieldBorderIndex = null;
                Material          iFieldMaterial;
                
+               VertexBuffer      iGoalVerts        = null;
+               IndexBuffer       iGoalIndex1       = null;
+               IndexBuffer       iGoalBorderIndex1 = null;
+               Material          iGoalMaterial1;
+               
+               IndexBuffer       iGoalIndex2       = null;
+               IndexBuffer       iGoalBorderIndex2 = null;
+               Material          iGoalMaterial2;
+
                Mesh              iBall             = null;
                Material          iBallMaterial;
 
@@ -90,6 +117,29 @@
 
                Hashtable         iAssets           = null;
 
+               // ball is on fire
+               ParticleSystem    iBallParticleSystem   = null;
+               Texture           iBallParticleTexture  = null;
+               int                               iBallNumberParticlesToEmit = 
1;
+               public enum ParticleColors { White, Red, Green, Blue, 
NumColors};
+               ParticleColors    iBallParticleColor = ParticleColors.White;
+               public System.Drawing.Color[] g_clrColor =
+               {
+                       System.Drawing.Color.White,
+                       System.Drawing.Color.Firebrick,
+                       System.Drawing.Color.MediumSeaGreen,
+                       System.Drawing.Color.DodgerBlue
+               };
+
+               System.Drawing.Color[] g_clrColorFade =
+               {
+                       System.Drawing.Color.WhiteSmoke,
+                       System.Drawing.Color.Pink,
+                       System.Drawing.Color.LightSeaGreen,
+                       System.Drawing.Color.LightCyan
+               };
+               // end ball fire
+
                DateTime          iLastPlayerInfoRequest = new DateTime(0);
 
                public Skorpion()
@@ -120,7 +170,7 @@
 
                        CreateDevice();
 
-                       
GlobalState.Client.Net.connect(ClientConfig.ClientConnect, 
ClientConfig.ClientPort, ClientConfig.PlayerName, ClientConfig.Team);
+                       
GlobalState.Client.Net.connect(ClientConfig.ClientConnect, 
ClientConfig.ClientPort, RegConfig.PlayerName, ClientConfig.Team);
 
                        while(ServerState.Live)
                        {
@@ -207,6 +257,25 @@
 
                public void RestoreDeviceObjects(object sender, EventArgs e)
                {
+                       // particles
+                       iBallParticleSystem = new ParticleSystem(512, 2048);
+                       iBallParticleSystem.Radius = 3; //0.03f;
+                       iBallParticleSystem.ParticlesLimit = 1024;
+                       iBallParticleSystem.NumParticlesToEmit = 1;     
+                       iBallParticleSystem.EmitVelocity = 88.0f;
+                       iBallParticleTexture = TextureLoader.FromFile(  iDevice,
+                               System.IO.Directory.GetCurrentDirectory() + 
"\\assets\\Particle.bmp",
+                               D3DX.Default,
+                               D3DX.Default,
+                               D3DX.Default,
+                               0,
+                               Format.Unknown,
+                               Pool.Managed,
+                               Filter.Triangle|Filter.Mirror,
+                               Filter.Triangle|Filter.Mirror,
+                               0);
+                       iBallParticleSystem.RestoreDeviceObjects(iDevice);
+
                        iDevice.RenderState.Lighting = true;
                        iDevice.RenderState.ZBufferEnable = true;
                        iDevice.RenderState.DitherEnable = false;
@@ -217,19 +286,58 @@
                        iDevice.RenderState.DestinationBlend = 
Blend.InvSourceAlpha;
 
                        iDevice.Lights[0].Type = LightType.Directional;
-                       iDevice.Lights[0].Direction = new 
Microsoft.DirectX.Vector3(-0.2f, -1f, -0.4f);
+                       iDevice.Lights[0].Direction = new 
Microsoft.DirectX.Vector3(-0.2f, -0.7f, -0.4f);
                        iDevice.Lights[0].Diffuse = Color.White;
                        iDevice.Lights[0].Enabled = true;
-                       iDevice.Lights[0].Commit();
+                       // iDevice.Lights[0].Commit();
 
                        iDevice.Lights[1].Type = LightType.Directional;
-                       iDevice.Lights[1].Direction = new 
Microsoft.DirectX.Vector3(0.2f, -1f, 0.4f);
+                       iDevice.Lights[1].Direction = new 
Microsoft.DirectX.Vector3(0.2f, -0.7f, 0.4f);
                        iDevice.Lights[1].Diffuse = Color.White;
                        iDevice.Lights[1].Enabled = true;
-                       iDevice.Lights[1].Commit();
+                       // iDevice.Lights[1].Commit();
 
                        iDevice.RenderState.Ambient = 
System.Drawing.Color.FromArgb(0x404040);
 
+                       iGoalMaterial1 = new Material();
+                       Color gc1 = Color.DarkViolet;
+                       iGoalMaterial1.Emissive = gc1;
+                       iGoalMaterial1.Diffuse  = Color.White;
+
+                       iGoalMaterial2 = new Material();
+                       Color gc2 = Color.Pink;
+                       iGoalMaterial2.Emissive = gc2;
+                       iGoalMaterial2.Diffuse  = Color.White;
+
+                       // goal
+                       iGoalVerts = new VertexBuffer(typeof(PCVertex), 8, 
iDevice, Usage.WriteOnly, PCVertex.Format, Pool.Default);
+                       PCVertex[] gv = (PCVertex[])iGoalVerts.Lock(0, 0);
+                       gv[0].p = Universe.FieldDefintion.GoalA;
+                       gv[1].p = Universe.FieldDefintion.GoalB;
+                       gv[2].p = Universe.FieldDefintion.GoalC;
+                       gv[3].p = Universe.FieldDefintion.GoalD;
+                       gv[4].p = Universe.FieldDefintion.Goal2A;
+                       gv[5].p = Universe.FieldDefintion.Goal2B;
+                       gv[6].p = Universe.FieldDefintion.Goal2C;
+                       gv[7].p = Universe.FieldDefintion.Goal2D;
+                       for (int i=0; i<8; i++) 
+                       { 
+                               if (i<4) gv[i].color = 
Color.FromArgb(45+(i%4)*8, gc1.R, gc1.G, gc1.B).ToArgb();
+                               else     gv[i].color = 
Color.FromArgb(45+(i%4)*8, gc2.R, gc2.G, gc2.B).ToArgb();
+                       }
+
+                       iGoalVerts.Unlock();
+
+                       Int16[] goalIndex1 = { 0,1,2, 3,0,2 };
+                       iGoalIndex1 = ConstructIndexBuffer(goalIndex1);
+                       Int16[] goalBorderIndex1 = { 0,1, 1,2, 2,3, 3,0 };
+                       iGoalBorderIndex1 = 
ConstructIndexBuffer(goalBorderIndex1);
+                       
+                       Int16[] goalIndex2 = { 4,5,6, 7,4,6 };
+                       iGoalIndex2 = ConstructIndexBuffer(goalIndex2);
+                       Int16[] goalBorderIndex2 = { 4,5, 5,6, 6,7, 7,4 };
+                       iGoalBorderIndex2 = 
ConstructIndexBuffer(goalBorderIndex2);
+
                        iFieldMaterial = new Material();
                        Color fc = Color.MediumAquamarine;
                        iFieldMaterial.Emissive = fc;
@@ -247,7 +355,7 @@
                        v[6].p = Universe.FieldDefintion.G;
                        v[7].p = Universe.FieldDefintion.H;
                        for (int i=0; i<8; i++)
-                               v[i].color = Color.FromArgb(10+i*6, fc.R, fc.G, 
fc.B).ToArgb();
+                               v[i].color = Color.FromArgb(25+(i%4)*12, fc.R, 
fc.G, fc.B).ToArgb();
                        iFieldVerts.Unlock();
 
                //      Int16[] fieldIndex = { 0,1,2, 3,0,2, 3,2,6, 7,3,6, 
2,1,5, 2,5,6,
@@ -273,8 +381,10 @@
                                
 
                        // ship
+                       Color sc = Color.Yellow;
                        iShipMaterial = new Material();
                        iShipMaterial.Diffuse = Color.White;
+       //              iShipMaterial.Emissive = Color.FromArgb(70, sc.R, sc.G, 
sc.B);  
 
                        // stars
                        iStars = Mesh.Sphere(iDevice, 1000.0f, 20, 20);
@@ -346,8 +456,23 @@
                public void Render()
                {
                        Ship Me = GlobalState.Client.Me;
-                       // LOG.debug(Me.Position.ToString());
+                       // LOG.debug(Me.Position.ToString())
 
+                       for (int i = 0; i < 
GlobalState.Client.CollisionsOut.Count; i++) 
+                       {
+                               skorpion.Vector3 v = 
((skorpion.GameClient.CollisionOut)(GlobalState.Client.CollisionsOut[i])).point;
+                               iDevice.Lights[2].Type = LightType.Point;
+                               iDevice.Lights[2].Diffuse = Color.White;
+                               iDevice.Lights[2].Range = 100.0f;
+                               iDevice.Lights[2].Position  = new 
Microsoft.DirectX.Vector3(v.X, v.Y, v.Z);
+                               iDevice.Lights[2].Attenuation1 = 0.4f;
+                               iDevice.Lights[2].Enabled = true;
+                               // iDevice.Lights[2].Commit();
+
+                               LOG.info("added light");
+                       }
+                       GlobalState.Client.CollisionsOut.Clear();
+
                        Vector3 ort     = GlobalState.Client.HoldCamera ? 
GlobalState.Client.LastOrientation : Me.Orientation;
                        Vector3 camPos  = Me.Position;
                        Vector3 camTarg = Me.Position + ort; 
@@ -367,9 +492,9 @@
                        }
                        else if (GlobalState.CamNum == 4)
                        {
-                               camPos  = new Vector3(0,76,0);
+                               camPos  = new Vector3(0,750,0);
                                camTarg = new Vector3(0,0,0);
-                               camUp   = new Vector3(0,0,-1);
+                               camUp   = new Vector3(0,-0.1f,-0.9f);
                        }
 
                        iDevice.Clear(ClearFlags.Target|ClearFlags.ZBuffer, 
System.Drawing.Color.Black, 1.0f, 0);
@@ -390,6 +515,29 @@
                        iDevice.RenderState.Lighting = true;
                        iDevice.RenderState.ZBufferEnable = true;
 
+                       // draw sparks erupting from the ball
+                       foreach(Entity e2 in 
GlobalState.Client.ThisFrame.Values)
+                               //foreach(Entity e in 
(Entity)GlobalState.Client.Universe.Entities[2])
+                       {
+                               if (e2.Type == Ball.TYPE)
+                               {
+                                       iDevice.Transform.World = 
Matrix.Translation(0,0,0);
+
+                                       iBallParticleSystem.Update(.03F,
+                                               
g_clrColor[(int)iBallParticleColor],
+                                               
g_clrColorFade[(int)iBallParticleColor],
+                                               e2.Position, e2.Velocity);
+                                       iDevice.RenderState.ZBufferWriteEnable 
= false;
+                                       iDevice.RenderState.AlphaBlendEnable = 
true;
+                                       iDevice.RenderState.SourceBlend = 
Blend.One;
+                                       iDevice.RenderState.DestinationBlend = 
Blend.One;
+                                       iDevice.SetTexture(0, 
iBallParticleTexture);
+                                       iBallParticleSystem.Render(iDevice);
+                                       iDevice.RenderState.ZBufferWriteEnable 
= true;
+                                       iDevice.RenderState.AlphaBlendEnable = 
false;
+                               }
+                       }
+                       
                        // draw ball(s) ?
                        // should sort entitys by type
                        iDevice.TextureState[0].ColorOperation = 
TextureOperation.SelectArg1;
@@ -405,6 +553,9 @@
                                }
                        }
 
+                       iDevice.RenderState.SourceBlend = Blend.SourceAlpha;
+                       iDevice.RenderState.DestinationBlend = 
Blend.InvSourceAlpha;
+
                        // draw field
                        iDevice.Transform.World = Matrix.Identity;
                        iDevice.Material = iFieldMaterial;
@@ -435,6 +586,43 @@
                        iDevice.RenderState.AlphaBlendEnable = false;
                        iDevice.RenderState.Lighting = true;
 
+                       // draw goals
+                       iDevice.Transform.World = Matrix.Identity;
+                       iDevice.Material = iGoalMaterial1;
+                       iDevice.VertexFormat = PCVertex.Format;
+                       iDevice.RenderState.Lighting = false;
+                       iDevice.RenderState.AlphaBlendEnable = true;
+                       iDevice.RenderState.ZBufferWriteEnable = false;
+                       iDevice.TextureState[0].ColorOperation = 
TextureOperation.SelectArg1;
+                       iDevice.TextureState[0].ColorArgument1 = 
TextureArgument.Diffuse;
+                       iDevice.TextureState[0].ColorArgument2 = 
TextureArgument.TextureColor;
+                       iDevice.TextureState[0].AlphaOperation = 
TextureOperation.SelectArg1;
+                       iDevice.TextureState[0].AlphaArgument1 = 
TextureArgument.Diffuse;
+                       iDevice.TextureState[0].AlphaArgument2 = 
TextureArgument.TextureColor;
+                       iDevice.SetStreamSource(0, iGoalVerts, 0, 
PCVertex.StrideSize);
+                       iDevice.Indices = iGoalBorderIndex1;
+                       iDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 
0, 0, 8, 0, 4);
+                       iDevice.Indices = iGoalBorderIndex2;
+                       iDevice.Material = iGoalMaterial2;
+                       iDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 
0, 0, 8, 0, 4);
+
+                       iDevice.RenderState.CullMode = Cull.None;               
        
+                       iDevice.TextureState[0].ColorOperation = 
TextureOperation.SelectArg1;
+                       iDevice.TextureState[0].ColorArgument1 = 
TextureArgument.Diffuse;
+                       iDevice.TextureState[0].ColorArgument2 = 
TextureArgument.TextureColor;
+                       iDevice.TextureState[0].AlphaOperation = 
TextureOperation.SelectArg1;
+                       iDevice.TextureState[0].AlphaArgument1 = 
TextureArgument.Diffuse;
+                       iDevice.TextureState[0].AlphaArgument2 = 
TextureArgument.TextureColor;
+                       iDevice.Indices = iGoalIndex2;
+                       
iDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 2);
+                       iDevice.Indices = iGoalIndex1;
+                       iDevice.Material = iGoalMaterial1;
+                       
iDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 2);
+
+                       iDevice.RenderState.ZBufferWriteEnable = true;
+                       iDevice.RenderState.AlphaBlendEnable = false;
+                       iDevice.RenderState.Lighting = true;
+
                        // draw ships
                        iDevice.RenderState.AlphaBlendEnable = true;
                        iDevice.TextureState[0].ColorOperation = 
TextureOperation.Modulate;

Modified: trunk/skorpion/skorpion.csproj
===================================================================
--- trunk/skorpion/skorpion.csproj      2006-11-07 21:30:44 UTC (rev 116)
+++ trunk/skorpion/skorpion.csproj      2006-11-12 05:47:56 UTC (rev 117)
@@ -163,6 +163,11 @@
                     BuildAction = "EmbeddedResource"
                 />
                 <File
+                    RelPath = "ParticleSystem.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "PlayerList.cs"
                     SubType = "Code"
                     BuildAction = "Compile"





reply via email to

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