Inheritance: Entity, IHasModel
Exemplo n.º 1
0
        public static Entity Clone(Entity entity)
        {
            Entity clone = null;

            if (entity is StaticModelEntity)
            {
                StaticModelEntity modelentity = entity as StaticModelEntity;
                clone = new StaticModelEntity(modelentity.GetModel());
            }

            if (entity is WallModelEntity)
            {
                WallModelEntity wallentity = entity as WallModelEntity;
                clone = new WallModelEntity(wallentity.GetModel());
            }

            if (entity is AnimatedModelEntity)
            {
                AnimatedModelEntity modelentity = entity as AnimatedModelEntity;
                clone = new AnimatedModelEntity(modelentity.GetModel());
            }

            if (entity is Billboard)
            {
                Billboard billboard = entity as Billboard;
                clone = new Billboard(billboard.region);
            }

            if (clone != null)
            {
                CopyFrom(entity, clone);
            }

            return(clone);
        }
Exemplo n.º 2
0
        public static Entity Clone(Entity entity)
        {
            Entity clone = null;

            if (entity is StaticModelEntity)
            {
                StaticModelEntity modelentity = entity as StaticModelEntity;
                clone = new StaticModelEntity(modelentity.GetModel());
            }

            if (entity is WallModelEntity)
            {
                WallModelEntity wallentity = entity as WallModelEntity;
                clone = new WallModelEntity(wallentity.GetModel());
            }

            if (entity is AnimatedModelEntity)
            {
                AnimatedModelEntity modelentity = entity as AnimatedModelEntity;
                clone = new AnimatedModelEntity(modelentity.GetModel());
            }

            if (entity is Billboard)
            {
                Billboard billboard = entity as Billboard;
                clone = new Billboard(billboard.region);
            }

            if (clone != null)
                CopyFrom(entity, clone);

            return clone;
        }
Exemplo n.º 3
0
        public Entity CreateFromAsset(object asset)
        {
            Entity entity = null;

            if (asset is Model)
            {
                Model model = asset as Model;

                if (model.Tag is SkinningData)
                    entity = new AnimatedModelEntity(model);
                else
                    entity = new StaticModelEntity(model);
            }
            else if (asset is Texture2D)
            {
                Texture2D texture = asset as Texture2D;
                entity = new Billboard(texture);
            }

            return entity;
        }
Exemplo n.º 4
0
        public void Load()
        {
            entities.Clear();

            XmlLevel xmllevel = XmlHelper.Load(id);
            List<XmlEntity> xmlentities = xmllevel.entities;

            for (int i = 0; i < xmlentities.Count; i++)
            {
                XmlEntity xmlentity = xmlentities[i];
                Entity entity = null;

                if (xmlentity.type == "static_model")
                {
                    Model model = (Model)Resources.GetObject(xmlentity.asset);
                    entity = new StaticModelEntity(model);
                }

                if (xmlentity.type == "animated_model")
                {
                    Model model = (Model)Resources.GetObject(xmlentity.asset);
                    entity = new AnimatedModelEntity(model);
                }

                if (xmlentity.type == "wall_model")
                {
                    Model model = (Model)Resources.GetObject(xmlentity.asset);
                    entity = new WallModelEntity(model);
                }

                if (xmlentity.type == "billboard")
                {
                    Texture2D texture = (Texture2D)Resources.GetObject(xmlentity.asset);
                    entity = new Billboard(texture);
                    ((Billboard)entity).color = xmlentity.color;
                }

                if (entity == null)
                    continue;

                entity.position = xmlentity.position;
                entity.rotation = xmlentity.rotation;
                entity.size = xmlentity.size;

                Add(entity);
            }
        }
Exemplo n.º 5
0
        public Hyades(InputDevice input)
        {
            this.input = input;
            instance = this;

            background_music = Resources.background_music.CreateInstance();
            background_music.IsLooped = true;
            background_music.Play();

            player = new Player(input);
            player.position.Z = 2.0f;

            camera = new FirstPersonCamera(player);
            camera.width = Application.WIDTH;
            camera.height = Application.HEIGHT;
            camera.near = 0.1f;
            camera.far = 500;
            camera.fov = 1.1f;

            level = new Level();
            level.Load();

            Skybox skybox = new Skybox(player);
            level.Add(skybox);

            StaticModelEntity birthstone = new StaticModelEntity(Resources.rock_model);
            birthstone.position = Vector3.Zero;
            birthstone.rotation.X = 1.11592329f;
            birthstone.rotation.Y = 0.188416481f;
            birthstone.rotation.Z = 1.31485772f;
            birthstone.size = new Vector3(0.0006f);
            AmbientEntityBubblesLogic birthstone_logic = new AmbientEntityBubblesLogic(birthstone, 80, 10);
            level.Add(birthstone);

            for (int i = 0; i < 10; i++)
            {
                Bubble bubble = new Bubble(0.03f + (float)rand.NextDouble()*0.02f);
                bubble.SetPosition(new Vector2(-50000, 0));
                bubble.SetVelocity(new Vector2(0, -1.0f));
                level.Add(bubble);
            }

            Enemy enemy;
            for (int i = 0; i < 2; i++)
            {
                enemy = new Fish();
               // enemy.size *= 0.1f;
                enemy.size *= (((float)rand.NextDouble())) * 0.06f + 0.05f;
               // enemy.size.Z *= 0.2f;
                //enemy.position.Z = (((float)rand.NextDouble()) -0.5f)*2;
                enemy.SetPosition(new Vector2(-50000, 0));
                level.Add(enemy);
            }

            for (int i = 0; i < 1; i++)
            {
                enemy = new Octopus();
                enemy.size *= 0.1f;
                enemy.SetPosition(new Vector2(-50000, -10));
                level.Add(enemy);
            }

            character = new Character(player, input);
            character.SetPosition(new Vector2(0, 0));
            level.Add(character);
            Enemy.player = character;

            particlemanager = ParticleManager.GetInstance();

            AmbientParticleLogic ambient_logic = new AmbientParticleLogic(character, 10);

            for (int i = 0; i < 400; i++)
            {
                ambient_logic.Emit();
            }

            AmbientCircleParticleLogic ambient_circle_logic = new AmbientCircleParticleLogic(character, 20);

            for (int i = 0; i < 10; i++)
            {
                ambient_circle_logic.Emit();
            }

            WormParticleLogic worm_logic = new WormParticleLogic(character, 10);

            for (int i = 0; i < 20; i++)
            {
                worm_logic.Emit();
            }

            Update(0);
        }