public override void Update()
        {
            if (this.Active)
            {
                this.Position += Velocity;
                m_LifeTick    += TICK;

                if (m_LifeTick > 2.0f)
                {
                    m_LifeTick    = 0.0f;
                    this.Active   = false;
                    this.Velocity = Vector2.Zero;
                }

                // Check Collisions
                foreach (GameObject go in m_CollisionObjects)
                {
                    if (go.Active)
                    {
                        if (this.Bounds().Intersects(go.Bounds()))
                        {
                            go.Active = false;

                            // If this object is not set to update and send out packets every frame then can force it here as they need to know its not active
                            if (!go.IsUpdatable())
                            {
                                PacketDefs.PlayerInputUpdatePacket updatePacket = new PacketDefs.PlayerInputUpdatePacket(
                                    go.UnqId(), go.Position.X, go.Position.Y, go.FrameX(), go.FrameY(), go.Active);
                                ServerManager.instance.SendAllUdp(fastJSON.JSON.ToJSON(
                                                                      updatePacket, PacketDefs.JsonParams()));
                            }

                            this.Active = false;

                            // Add exp for killimg enemy
                            GameClient client = ServerManager.instance.GetClient(InvokedBy);
                            if (client != null)
                            {
                                client.localExpCache += 2;

                                // Send TCP pack with new exp update, note* only hit the database to increment exp when the level is finished
                                PacketDefs.UpdateExpPacket flp = new PacketDefs.UpdateExpPacket(client.localExpCache, PacketDefs.ID.OUT_TCP_ExpQueery);
                                ServerManager.instance.SendTcp(client.tcpSocket, fastJSON.JSON.ToJSON(flp, PacketDefs.JsonParams()));
                            }
                        }
                    }
                }
            }
        }
        private void CheckCollisions()
        {
            // ---- Resolve collision ----
            bool contactLeft = false, contactRight = false, contactYbottom = false, contactYtop = false;

            Vector2 predicted_speed = this.Velocity;;
            float   projectedMoveX, projectedMoveY, originalMoveX, originalMoveY;

            originalMoveX = predicted_speed.X;
            originalMoveY = predicted_speed.Y;

            // This needs to be from the qyadtree
            foreach (GameObject colTest in GameSimulation.instance.GetObjects())
            {
                if ((colTest.TypeId() == GameObjectType.Wall || colTest.TypeId() == GameObjectType.DestructablePlatform) && colTest.Active)
                {
                    for (int dir = 0; dir < 4; dir++)
                    {
                        if (dir == UP && predicted_speed.Y > 0)
                        {
                            continue;
                        }
                        if (dir == DOWN && predicted_speed.Y < 0)
                        {
                            continue;
                        }
                        if (dir == LEFT && predicted_speed.X > 0)
                        {
                            continue;
                        }
                        if (dir == RIGHT && predicted_speed.X < 0)
                        {
                            continue;
                        }

                        projectedMoveX = (dir >= LEFT ? predicted_speed.X : 0);
                        projectedMoveY = (dir < LEFT ? predicted_speed.Y : 0);

                        while ((colTest.Bounds().Contains(this.points[dir * 2].X + (int)this.Position.X + (int)projectedMoveX,
                                                          this.points[dir * 2].Y + (int)this.Position.Y + (int)projectedMoveY)
                                ||
                                colTest.Bounds().Contains(this.points[dir * 2 + 1].X + (int)this.Position.X + (int)projectedMoveX,
                                                          this.points[dir * 2 + 1].Y + (int)this.Position.Y + (int)projectedMoveY)))
                        {
                            if (dir == UP)
                            {
                                projectedMoveY++;
                            }
                            if (dir == DOWN)
                            {
                                projectedMoveY--;
                            }
                            if (dir == LEFT)
                            {
                                projectedMoveX++;
                            }
                            if (dir == RIGHT)
                            {
                                projectedMoveX--;
                            }
                        }

                        if (dir >= LEFT && dir <= RIGHT)
                        {
                            predicted_speed.X = projectedMoveX;
                        }
                        if (dir >= UP && dir <= DOWN)
                        {
                            predicted_speed.Y = projectedMoveY;
                        }
                    }

                    // Resolve contact
                    if (predicted_speed.Y > originalMoveY && originalMoveY < 0)
                    {
                        contactYtop = true;
                    }

                    if (predicted_speed.Y < originalMoveY && originalMoveY > 0)
                    {
                        contactYbottom = true;
                    }

                    if (predicted_speed.X - originalMoveX < -0.01f)
                    {
                        contactRight = true;
                    }

                    if (predicted_speed.X - originalMoveX > 0.01f)
                    {
                        contactLeft = true;
                    }

                    // Resolve collision from contact
                    if (contactYbottom)
                    {
                        this.Velocity.Y = 0;
                        this.Grounded   = true;
                    }
                    else if (contactYtop)
                    {
                        this.Velocity.Y = 0;
                    }

                    if (contactLeft || contactRight)
                    {
                        this.Velocity.X = 0;
                    }
                }
                else if (colTest.TypeId() == GameObjectType.Exit)
                {
                    if (this.Bounds().Intersects(colTest.Bounds()))
                    {
                        // Stop updating this object
                        Active = false;

                        // Send Back to previous position
                        this.Position = Player.SpawnPosition();
                        this.Velocity = Vector2.Zero;

                        GameClient client = ServerManager.instance.GetClient(m_ClientId);
                        if (client != null)
                        {
                            client.inGame = false;

                            // NOTE** This is the only time we want to update the database (when they finish the level)
                            client.localExpCache += 30;

                            // Give this client some experience on database
                            ServerManager.instance.UpdateClientExpDB(client.userName, client.localExpCache);

                            // Send him back to the lobby : TODO Get EXP from DB
                            PacketDefs.UpdateExpPacket flp = new PacketDefs.UpdateExpPacket(client.localExpCache, PacketDefs.ID.OUT_TCP_FinishLevel);
                            ServerManager.instance.SendTcp(client.tcpSocket, fastJSON.JSON.ToJSON(flp, PacketDefs.JsonParams()));

                            if (!GameSimulation.instance.ArePeopleInGame())
                            {
                                // No one is in-game so clear data
                                GameSimulation.instance.ScheduleClearGameData();
                                return;
                            }
                        }
                    }
                }
                else if (colTest.TypeId() == GameObjectType.GoldSkull)
                {
                    if (this.Bounds().Intersects(colTest.Bounds()) && colTest.Active)
                    {
                        colTest.Active = false;

                        // Send out a packet here informing them it's deactivated (rather than using standward way and doing it every frame)
                        PacketDefs.PlayerInputUpdatePacket updatePacket = new PacketDefs.PlayerInputUpdatePacket(
                            colTest.UnqId(), colTest.Position.X, colTest.Position.Y, colTest.FrameX(), colTest.FrameY(), colTest.Active);
                        ServerManager.instance.SendAllUdp(fastJSON.JSON.ToJSON(
                                                              updatePacket, PacketDefs.JsonParams()));

                        // Add exp for collecting skull
                        GameClient client = ServerManager.instance.GetClient(m_ClientId);
                        if (client != null)
                        {
                            client.localExpCache += 10;

                            // Send TCP pack with new exp update, note* only hit the database to increment exp when the level is finished
                            PacketDefs.UpdateExpPacket flp = new PacketDefs.UpdateExpPacket(client.localExpCache, PacketDefs.ID.OUT_TCP_ExpQueery);
                            ServerManager.instance.SendTcp(client.tcpSocket, fastJSON.JSON.ToJSON(flp, PacketDefs.JsonParams()));
                        }
                    }
                }
                else if (IsHazard(colTest.TypeId()))
                {
                    if (!m_Hurt)
                    {
                        if (this.Bounds().Intersects(colTest.Bounds()) && colTest.Active)
                        {
                            //if (Math.Abs(Velocity.X) >= 1.0f)
                            //{
                            Velocity = new Vector2(-(float)m_Facing * 10, -20);
                            //}
                            //else
                            //{
                            //  Velocity.Y = -30.0f;
                            //}

                            m_Hurt    = true;
                            Grounded  = true;
                            m_Health -= 1;

                            // Send UDP pack with new health
                            PacketDefs.PlayerHealthPacket hp = new PacketDefs.PlayerHealthPacket(m_Health);
                            ServerManager.instance.SendUdp(m_ClientId, fastJSON.JSON.ToJSON(hp, PacketDefs.JsonParams()));
                        }
                    }
                }
            }
        }