Exemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            root.update(gameTime);

            foreach (KeyValuePair <string, CActor> kvp in actors)
            {
                //first get messages from the commNet
                if (CMasterControl.commNet[(int)_address].Count() > 0)
                {
                    CActorPacket[] packetData = new CActorPacket[CMasterControl.commNet[(int)_address].Count()];
                    CMasterControl.commNet[(int)_address].CopyTo(packetData);

                    var group = from packets in packetData
                                where kvp.Key == packets.actor
                                select packets;

                    foreach (var result in group)
                    {
                        //pass the message to the actor
                        CActor temp = kvp.Value;
                        passMessage(ref temp, (uint)result.userEventID, result.getParams());
                        CMasterControl.commNet[(int)_address].Remove(result);
                    }
                }

                //update position relative to the root
                if (kvp.Value._followRoot)
                {
                    kvp.Value.position += root.distanceFromLastFrame;
                }

                //update
                kvp.Value.update(gameTime);
            }
        }
Exemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            if (root.killMe)
            {
                _destroyActors(_softDelete);
                enabled = false;
            }

            if (enabled)
            {
                //update the root's old position and then update the actor
                _checkCommNet(root.name, root);
                root.update(gameTime);
                //List<CActor> _actors = actors.Values.ToList();

                for (int i = 0; i < actors.Count; i++)
                {
                    CActor actor = actors.Values.ElementAt(i);
                    if (actor.killMe)
                    {
                        removeActor(actor, true);
                        continue;
                    }
                    //first get messages from the commNet
                    _checkCommNet(actor.name, actor);

                    //update
                    actor.update(gameTime);
                }
                //remove any actors that are to be removed
                for (int i = 0; i < _removeThese.Count(); i++)
                {
                    removeActor(_removeThese[i]);
                }

                _removeThese.Clear();
            }
        }