Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the WorldContext class.
 /// </summary>
 /// <param name="entityManager">The entity manager.</param>
 /// <param name="physics">The physics world.</param>
 /// <param name="resources">The game resources.</param>
 /// <param name="currentTime">The current game time.</param>
 public WorldContext(EntityManager entityManager, World physics, ResourceManager resources, TimeSpan currentTime)
 {
     this.EntityManager = entityManager;
     this.Physics = physics;
     this.Resources = resources;
     this.CurrentTime = currentTime;
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the InputSystem class.
 /// </summary>
 /// <param name="entityManager">The EntityManager for the world that this system belongs to.</param>
 /// <param name="graphics">The graphics device.</param>
 public InputSystem(EntityManager entityManager, GraphicsDevice graphics)
     : base(entityManager)
 {
     this.graphics = graphics;
     this.prevMouseState = null;
     this.prevEntityWithFocus = null;
 }
 /// <summary>
 /// Transform the given EntityManager into a state that is ready for serialization.
 /// </summary>
 /// <param name="entityManager">The EntityManager to transform.</param>
 public void TransformPreSave(EntityManager entityManager)
 {
     // Perform all transformations
     foreach (IEntityTransformer transformer in this.transformerList)
     {
         transformer.TransformPreSave(entityManager);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the DebugDrawSystem class.
        /// </summary>
        /// <param name="entityManager">The EntityManager for the world that this system belongs to.</param>
        /// <param name="world">The physics world.</param>
        /// <param name="graphics">The graphics device.</param>
        /// <param name="content">The content manager.</param>
        public DebugDrawSystem(
            EntityManager entityManager,
            World world,
            GraphicsDevice graphics,
            ContentManager content)
            : base(entityManager)
        {
            this.debugView = new DebugViewXNA(world);
            this.debugView.LoadContent(graphics, content);

            // Set the debug flags
            ////this.debugView.AppendFlags(DebugViewFlags.AABB);
            ////this.debugView.AppendFlags(DebugViewFlags.CenterOfMass);
            ////this.debugView.AppendFlags(DebugViewFlags.ContactNormals);
            ////this.debugView.AppendFlags(DebugViewFlags.ContactPoints);
            ////this.debugView.AppendFlags(DebugViewFlags.Controllers);
            ////this.debugView.AppendFlags(DebugViewFlags.DebugPanel);
            ////this.debugView.AppendFlags(DebugViewFlags.Joint);
            ////this.debugView.AppendFlags(DebugViewFlags.Pair);
            ////this.debugView.AppendFlags(DebugViewFlags.PerformanceGraph);
            ////this.debugView.AppendFlags(DebugViewFlags.PolygonPoints);
            ////this.debugView.AppendFlags(DebugViewFlags.Shape);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the SpriteSystem class.
        /// </summary>
        /// <param name="entityManager">The EntityManager for the world that this system belongs to.</param>
        /// <param name="resources">The game resources.</param>
        /// <param name="graphics">The graphics device.</param>
        public SpriteSystem(EntityManager entityManager, ResourceManager resources, GraphicsDevice graphics)
            : base(entityManager)
        {
            this.resources = resources;
            this.graphics = graphics;

            // Load the lighting shader
            this.lightShader = (Effect)this.resources.Load<Effect>("Shader\\LightShader");

            // Create a 1x1 white texture
            this.whiteTexture = new Texture2D(this.graphics, 1, 1);
            this.whiteTexture.SetData<Color>(new Color[] { Color.White });

            // Create the blend state for additive blending with the max blend function
            this.blendStateAdditiveMax = new BlendState()
            {
                ColorSourceBlend = Blend.One,
                ColorDestinationBlend = Blend.One,
                ColorBlendFunction = BlendFunction.Max,
                AlphaSourceBlend = Blend.One,
                AlphaDestinationBlend = Blend.One,
                AlphaBlendFunction = BlendFunction.Max
            };
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the PhysicsSystem class.
 /// </summary>
 /// <param name="entityManager">The EntityManager for the world that this system belongs to.</param>
 /// <param name="world">The physics world.</param>
 public PhysicsSystem(EntityManager entityManager, World world)
     : base(entityManager)
 {
     this.world = world;
 }
 /// <summary>
 /// Save the level with the given level number.
 /// </summary>
 /// <param name="entityManager">The entity manager of the level to be saved.</param>
 /// <param name="levelNum">The level number.</param>
 /// <returns>True if the level was saved.</returns>
 protected override bool DoSaveLevel(EntityManager entityManager, int levelNum)
 {
     return this.entityDataAdapter.SaveLevel(entityManager, levelNum);
 }
Esempio n. 8
0
        private IEntity CreateEntityObj(EntityType etype, EntityCreateData data)
        {
            IEntity en = null;

            switch (etype)
            {
            case EntityType.EntityType_Player:
            {
                Player player = new Player();
                if (player != null)
                {
                    player.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(player);
                    if (data.bMainPlayer)
                    {
                        EntitySystem.m_ClientGlobal.MainPlayer = player;
                    }

                    player.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }
                en = player;
                break;
            }

            case EntityType.EntityType_Monster:
            {
                Monster monster = new Monster();
                if (monster != null)
                {
                    monster.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(monster);
                    monster.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = monster;
                break;
            }

            case EntityType.EntityType_NPC:
            {
                NPC npc = new NPC();
                if (npc != null)
                {
                    npc.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(npc);
                    npc.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = npc;
                break;
            }

            case EntityType.EntityTYpe_Robot:
            {
                Robot robot = new Robot();
                if (robot != null)
                {
                    robot.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(robot);
                    robot.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = robot;
                break;
            }

            case EntityType.EntityType_Item:     // 物品
            {
                Item item = new Item();
                if (item != null)
                {
                    item.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(item);
                    item.Create(data, ColliderCheckType.ColliderCheckType_null);
                }

                en = item;
                break;
            }

            case EntityType.EntityType_Pet:     // 宠物
            {
                Pet pet = new Pet();
                if (pet != null)
                {
                    pet.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(pet);
                    pet.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = pet;
                break;
            }

            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // 家园对象
            case EntityType.EntityType_Plant:     // 植物
            {
                Plant plant = new Plant();
                if (plant != null)
                {
                    plant.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(plant);
                    plant.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = plant;
                break;
            }

            case EntityType.EntityType_Animal:     // 动物
            {
                Animal animal = new Animal();
                if (animal != null)
                {
                    animal.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(animal);
                    animal.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = animal;
                break;
            }

            case EntityType.EntityType_Tree:     // 许愿树
            {
                Tree tree = new Tree();
                if (tree != null)
                {
                    tree.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(tree);
                    tree.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = tree;
                break;
            }

            case EntityType.EntityType_Minerals:     // 矿产
            {
                Minerals mine = new Minerals();
                if (mine != null)
                {
                    mine.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(mine);
                    mine.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = mine;
                break;
            }

            case EntityType.EntityType_Soil:     // 土地
            {
                Soil soil = new Soil();
                if (soil != null)
                {
                    soil.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(soil);
                    soil.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = soil;
                break;
            }

            case EntityType.EntityType_Puppet:     // 木偶
            {
                Puppet puppet = new Puppet();
                if (puppet != null)
                {
                    puppet.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(puppet);
                    puppet.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = puppet;
                break;
            }

            case EntityType.EntityType_Box:
            {
                //UnityEngine.Sprite sp;


                Box box = new Box();
                if (box != null)
                {
                    box.SetUID(MakeUID(etype, data.ID));
                    EntityManager.Instance().AddEntity(box);
                    box.Create(data, ColliderCheckType.ColliderCheckType_CloseTerrain | ColliderCheckType.ColliderCheckType_Wall);
                }

                en = box;
                break;
            }
            }

            //if(en!=null)
            //{
            //    Client.stCreateEntity createEntity = new Client.stCreateEntity();
            //    createEntity.uid = en.GetUID();
            //    Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_CREATEENTITY, createEntity);
            //}

            return(en);
        }
Esempio n. 9
0
 public IEntity GetEntity(long uid)
 {
     return(EntityManager.Instance().GetEntity(uid));
 }
Esempio n. 10
0
        public void RemoveEntity(long uid)
        {
            IEntity en = EntityManager.Instance().GetEntity(uid);

            RemoveEntity(en);
        }
Esempio n. 11
0
 internal EntityRef(EntityManager manager, Entity entity)
 {
     _manager = manager; _entity = entity;
 }