コード例 #1
0
        /// <summary>
        /// Extracts the inputted child from this container, but keeps it alive for insertion into another
        /// </summary>
        /// <param name="childToExtract">The child we wish to extract from this container</param>
        public K ExtractChild <K>(K childToExtract) where K : T
        {
            DebugUtils.AssertNotNull(childToExtract);

            ObjectsToRemove.Add(childToExtract);
            return(childToExtract);
        }
コード例 #2
0
        private void RespawnUnknownObjects()
        {
            var unknownSpawnPositions = Game.GetObjectsByCustomId("SpawnUnknown");

            if (unknownSpawnPositions.Length == 0)
            {
                return;
            }
            for (int i = 0; i < unknownSpawnPositions.Length; i++)
            {
                var trigger = unknownSpawnPositions[i];
                if (trigger == null)
                {
                    return;
                }
                var position = trigger.GetWorldPosition();
                if (position == null)
                {
                    return;
                }
                var index = GlobalRandom.Next(0, PossibleUnknownObjects.Count);
                var obj   = Game.CreateObject(PossibleUnknownObjects[index], position);
                ObjectsToRemove.Add(obj);
            }
        }
コード例 #3
0
        /// <summary>
        /// Add all the objects in ObjectsToAdd to ActiveObjects, then update ActiveObjects before deleting objects in ObjectsToRemove
        /// </summary>
        /// <param name="elapsedGameTime">The seconds that have elapsed since the last update loop</param>
        public override void Update(float elapsedGameTime)
        {
            // Always call the super class' function - it will deal with whether it should run it itself
            base.Update(elapsedGameTime);

            // Add the objects and then clear the list - it is only a temporary holder
            ActiveObjects.AddRange(ObjectsToAdd);
            ObjectsToAdd.Clear();

            // Loop through the active object
            foreach (T obj in ActiveObjects)
            {
                if (obj.ShouldUpdate)
                {
                    // Update the object
                    obj.Update(elapsedGameTime);
                }
            }

            // Remove all the objects that are no longer alive
            ActiveObjects.RemoveAll(x => x.IsAlive == false);

            // Remove all the objects we have marked to remove
            foreach (T obj in ObjectsToRemove)
            {
                ActiveObjects.Remove(obj);
            }
            ObjectsToRemove.Clear();    // Clear the list - it is only a temporary holder
        }
コード例 #4
0
            public void SpawnStreetsweeper(TPlayer player)
            {
                var streetSweeper = Game.CreateObject("Streetsweeper", new Vector2(player.Position.X, WorldTop)) as IObjectStreetsweeper;

                streetSweeper.SetOwnerTeam(player.Team);
                streetSweeper.SetOwnerPlayer(player.User.GetPlayer());
                ObjectsToRemove.Add(streetSweeper);
            }
コード例 #5
0
 public void Add(T instance)
 {
     if (ObjectsToRemove.Contains(instance))
     {
         ObjectsToRemove.Remove(instance);
     }
     if (!ObjectsToAdd.Contains(instance))
     {
         ObjectsToAdd.Add(instance);
     }
 }
コード例 #6
0
ファイル: GameEngine.cs プロジェクト: ekov1/TelerikAcademy
        public static void RemoveObjects()
        {
            foreach (var obj in ObjectsToRemove)
            {
                RemoveObject(obj);

                if (obj.Type == WorldObjectType.BonusBox)
                {
                    spawnedBonuses -= 1;
                }
            }

            ObjectsToRemove.Clear();
        }
コード例 #7
0
        /// <summary>
        /// Notifies connected clients of new alert from system
        /// </summary>
        /// <param name="data"></param>
        public int NotifyConnectedClients(string data)
        {
            int       count           = 0;
            ArrayList ObjectsToRemove = null;

            for (int x = 0; x < this.socketClientList.Count; x++)
            {
                try
                {
                    SocketClient socket = (SocketClient)this.socketClientList[x];

                    if (socket.ClientSocket.Connected == true &&
                        socket.SendNotification(data) == true)
                    {
                        count++;
                    }
                    else
                    {
                        if (ObjectsToRemove == null)
                        {
                            ObjectsToRemove = new ArrayList();
                        }

                        ObjectsToRemove.Add(socket);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error:SocketServer: While in NotifyConnectedClients" +
                                      e.Message);
                    System.Diagnostics.Debugger.Break();
                }
            }

            if (ObjectsToRemove != null)
            {
                foreach (SocketClient socket in ObjectsToRemove)
                {
                    socket.Disconnect();
                    socketClientList.Remove(socket);
                    socket.Dispose();
                }
            }


            return(count);
        }
コード例 #8
0
ファイル: GameCore.cs プロジェクト: Juansero29/SFDScripts
 public void RemoveObjects()
 {
     string[]  name    = { "WpnMineThrown", "SupplyCrate00", "MetalRailing00", "WpnGrenadesThrown" };
     IObject[] objects = GlobalGame.GetObjectsByName(name);
     for (int i = 0; i < objects.Length; i++)
     {
         objects[i].Remove();
     }
     for (int i = 0; i < ObjectsToRemove.Count; i++)
     {
         if (ObjectsToRemove[i] != null)
         {
             ObjectsToRemove[i].Remove();
         }
     }
     ObjectsToRemove.Clear();
 }
コード例 #9
0
            public void CallReinforcement(TPlayer player)
            {
                Area area = GlobalGame.GetCameraArea();

                for (int i = 0; i < PlayerList.Count; i++)
                {
                    TPlayer pl = PlayerList[i];
                    if (pl != null && pl.IsActive() && pl != player && pl.Team == player.Team && !pl.IsAlive())
                    {
                        float   x           = GlobalRandom.Next((int)(area.Left + area.Width / 5), (int)(area.Right - area.Width / 5));
                        float   y           = WorldTop + 50;
                        IObject crate       = GlobalGame.CreateObject("SupplyCrate00", new Vector2(x, y));
                        IObject platf       = GlobalGame.CreateObject("Lift00A", new Vector2(x, y - 10));
                        IObject leftBorder  = GlobalGame.CreateObject("Lift00A", new Vector2(x - 10, y), (float)Math.PI / -2);
                        IObject rightBorder = GlobalGame.CreateObject("Lift00A", new Vector2(x + 10, y), (float)Math.PI / 2);
                        leftBorder.SetBodyType(BodyType.Dynamic);
                        rightBorder.SetBodyType(BodyType.Dynamic);
                        IObjectDestroyTargets destroy = (IObjectDestroyTargets)GlobalGame.CreateObject("DestroyTargets", new Vector2(x, y));
                        platf.SetMass(1e-3f);
                        leftBorder.SetMass(1e-3f);
                        rightBorder.SetMass(1e-3f);
                        IObjectWeldJoint joint = (IObjectWeldJoint)GlobalGame.CreateObject("WeldJoint", new Vector2(x, y));
                        joint.AddTargetObject(crate);
                        joint.AddTargetObject(platf);
                        joint.AddTargetObject(rightBorder);
                        joint.AddTargetObject(leftBorder);
                        destroy.AddTriggerDestroyObject(crate);
                        destroy.AddObjectToDestroy(joint);
                        destroy.AddObjectToDestroy(platf);
                        destroy.AddObjectToDestroy(leftBorder);
                        destroy.AddObjectToDestroy(rightBorder);
                        ObjectsToRemove.Add(destroy);
                        ObjectsToRemove.Add(platf);
                        ObjectsToRemove.Add(joint);
                        ObjectsToRemove.Add(leftBorder);
                        ObjectsToRemove.Add(rightBorder);
                        pl.Equipment.Clear();
                        pl.Armor.SetId(0);
                        pl.Revive(100, false, true, x, y);
                        player.AddExp(5, 5);
                    }
                }
            }
コード例 #10
0
 public TThrownWeapon(IObject obj, int id)
 {
     Id = id;
     if (Id == 2 || Id == 3)
     {
         ThrownWeaponObject = GlobalGame.CreateObject("DrinkingGlass00", obj.GetWorldPosition(), obj.GetAngle(), obj.GetLinearVelocity(), obj.GetAngularVelocity());
         ObjectsToRemove.Add(ThrownWeaponObject);
         obj.Remove();
     }
     else
     {
         ThrownWeaponObject = obj;
     }
     Position = ThrownWeaponObject.GetWorldPosition();
     if (Id == 2 || Id == 3)
     {
         TicksUntilExplosion = 100;
     }
     if (Id == 2)
     {
         SmokeCount = 400;
     }
 }
コード例 #11
0
 public void Clear()
 {
     ObjectsToAdd.Clear();
     ObjectsToRemove.Clear();
     ObjectsToUpdate.Clear();
 }