Exemplo n.º 1
0
        public GameMap createRandomDungeonMap(int x, int y, int features, int seed)
        {
            Map map = MapMaker.create(x, y);

            object[] parameters = new object[DungeonGen.DUNGEON_PARAMS_SIZE];

            parameters[DungeonGen.DUNGEON_PARAMS_XSIZE]         = x;
            parameters[DungeonGen.DUNGEON_PARAMS_YSIZE]         = y;
            parameters[DungeonGen.DUNGEON_PARAMS_SEED]          = seed;
            parameters[DungeonGen.DUNGEON_PARAMS_FEATURE_COUNT] = features;

            MapMaker.Parameters = parameters;

            MapMaker.generate(map, MapType.DUNGEON);

            GameMap gameMap = new GameMap(map);

            Entity e = ecs_instance.create();

            ecs_instance.add_component(e, gameMap);

            ecs_instance.tag_manager.tag_entity("MAP", e);

            ecs_instance.resolve(e);

            return(gameMap);
        }
Exemplo n.º 2
0
        public Entity createTestMeleeWeapon()
        {
            Entity e = ecs_instance.create();

            Item item = new Item("TestMeleeWeapon", 0, 100);

            item.Lethality  = 10;
            item.Speed      = 5;
            item.MinRange   = 0;
            item.MaxRange   = 48;
            item.ItemType   = ItemType.WEAPON;
            item.WeaponType = WeaponType.MELEE;
            item.DamageType = DamageType.SLASHING;


            //Weapon weapon = new Weapon(10, 5, 0, 48, WeaponType.MELEE, DamageType.SLASHING);
            //weapon.MeleeWeaponType = MeleeWeaponType.Sword;

            ecs_instance.add_component(e, item);
            //i_ECSInstance.entity_manager.add_component(e, weapon);

            ecs_instance.resolve(e);
            return(e);
        }
Exemplo n.º 3
0
        /// <summary>
        /// creates a timed dialog
        /// </summary>
        /// <param name="caller"></param>
        /// <param name="dialog"></param>
        /// <param name="origin"></param>
        /// <param name="name"></param>
        /// <param name="duration"></param>
        public static void createTimedDialogWindow(Entity caller, String dialog, Vector2 origin, String name, int duration)
        {
            Entity e = ecs_instance.create();

            DialogTimer timer = new DialogTimer(duration, ecs_instance);

            GForm form = new GForm();

            form.caller       = caller;
            form.owner        = e;
            form.ecs_instance = ecs_instance;
            form.bounds       = new Rectangle((int)origin.X, (int)origin.Y, 100, 50);

            GCanvas canvas = new GCanvas();

            canvas.caller       = caller;
            canvas.owner        = e;
            canvas.ecs_instance = ecs_instance;
            canvas.bounds       = new Rectangle((int)origin.X, (int)origin.Y, 200, 200);

            GTextBox textBox = new GTextBox();

            textBox.caller           = caller;
            textBox.owner            = e;
            textBox.ecs_instance     = ecs_instance;
            textBox.bounds           = new Rectangle((int)origin.X, (int)origin.Y, 100, 10);
            textBox.font_name        = "StartScreen";
            textBox.background_name  = "frame";
            textBox.border           = 10;
            textBox.text             = dialog;
            textBox.text_color       = Color.White;
            textBox.autosize         = true;
            textBox.center_text      = true;
            textBox.background_color = Color.Black;
            textBox.transparency     = 0.75f;

            textBox.updating += timer.updateHandler;

            canvas.controls.Add(textBox);

            form.canvas_controls.Add(canvas);

            UserInterface ui = new UserInterface(form);

            //assign component and issue refresh
            ecs_instance.add_component(e, ui);
            ecs_instance.resolve(e);
        }
Exemplo n.º 4
0
        public void createFollower(Vector2 position, Entity target, float distance)
        {
            Entity e = ecs_instance.create();

            ecs_instance.add_component(e, new Position(position, new Vector2(16)));
            ecs_instance.add_component(e, new Velocity(4f));
            ecs_instance.add_component(e, new Sprite("characters\\herr_von_speck_sheet", "characters\\normals\\herr_von_speck_sheet_normals", 32, 32, 0, 0));
            ecs_instance.add_component(e, new AiBehavior(new FollowerBehavior(e, target, distance, ecs_instance)));         //new FollowPath(e, target, distance, n_EcsInstance)));
            ecs_instance.add_component(e, new MapCollidable());
            ecs_instance.add_component(e, new Heading());
            ecs_instance.add_component(e, new Transform());
            ecs_instance.add_component(e, new Aggrivation());
            ecs_instance.add_component(e, new APath());

            /*
             * //setup pathing agent
             * BusAgent busAgent = new BusAgent();
             * busAgent.Agent = new Agent();
             * busAgent.Agent.Entity = e;
             *
             * Activity activity = new Activity();
             * activity.ActivityName = "activity1";
             * activity.ComponentName = "PATH_FINDER";
             * activity.InitialActivity = true;
             * activity.NextActivity = "activity1";
             *
             * AgentProcess process = new AgentProcess();
             * process.ProcessName = "path process";
             * process.Activities.Add(activity.ActivityName, activity);
             *
             * busAgent.Agent.AgentProcess = process;
             *
             * n_ECSInstance.entity_manager.add_component(e, busAgent);
             */

            //create info
            Information info = new Information();

            info.Name           = "TEST FOLLOWER";
            info.GeneralGroup   = "BAT";
            info.VariationGroup = "NONE";
            info.UniqueGroup    = "NONE";
            ecs_instance.add_component(e, info);

            //create life
            Life life = new Life();

            life.IsAlive        = true;
            life.DeathLongevity = 500;
            ecs_instance.add_component(e, life);

            //create interactions
            Interactable interact = new Interactable();

            interact.SupportedInteractions.PROJECTILE_COLLIDABLE = true;
            interact.SupportedInteractions.ATTACKABLE            = true;
            interact.SupportedInteractions.MELEE_ACTIONABLE      = true;
            interact.SupportedInteractions.AWARDS_VICTORY        = true;
            interact.SupportedInteractions.CAUSES_ADVANCEMENT    = true;
            interact.SupportedInteractions.MAY_ADVANCE           = false;
            ecs_instance.add_component(e, interact);

            //create test equipment
            ItemFactory iFactory = new ItemFactory(ecs_instance);

            ecs_instance.add_component(e, iFactory.createTestEquipment());

            int skillLevel = 25;

            //setup experiences
            Knowledges knowledges = new Knowledges();

            knowledges.GeneralKnowledge.Add("HUMAN", new Knowledge {
                Name = "", Value = skillLevel, KnowledgeType = KnowledgeType.General
            });
            knowledges.GeneralKnowledge.Add("BAT", new Knowledge {
                Name = "", Value = skillLevel, KnowledgeType = KnowledgeType.General
            });
            knowledges.VariationKnowledge.Add("NONE", new Knowledge {
                Name = "", Value = 0f, KnowledgeType = KnowledgeType.General
            });
            knowledges.UniqueKnowledge.Add("NONE", new Knowledge {
                Name = "", Value = 0f, KnowledgeType = KnowledgeType.General
            });
            ecs_instance.add_component(e, knowledges);

            //setup attributes
            Statistics statistics = new Statistics();

            statistics.Focus = new Statistic {
                Name = "FOCUS", Value = skillLevel, StatType = StatType.FOCUS
            };
            statistics.Endurance = new Statistic {
                Name = "ENDURANCE", Value = skillLevel, StatType = StatType.ENDURANCE
            };
            statistics.Mind = new Statistic {
                Name = "MIND", Value = skillLevel, StatType = StatType.MIND
            };
            statistics.Muscle = new Statistic {
                Name = "MUSCLE", Value = skillLevel, StatType = StatType.MUSCLE
            };
            statistics.Perception = new Statistic {
                Name = "PERCEPTION", Value = skillLevel, StatType = StatType.PERCEPTION
            };
            statistics.Personality = new Statistic {
                Name = "PERSONALITY", Value = skillLevel, StatType = StatType.PERSONALITY
            };
            statistics.Quickness = new Statistic {
                Name = "QUICKNESS", Value = skillLevel, StatType = StatType.QUICKNESS
            };
            ecs_instance.add_component(e, statistics);

            //create health
            Health health = new Health(statistics.Endurance.Value * 3);

            health.RecoveryAmmount = statistics.Endurance.Value / 5;
            health.RecoveryRate    = 1000;
            ecs_instance.add_component(e, health);

            //setup skills
            Skills skills = new Skills();

            skills.Ranged = new Skill {
                Name = "RANGED", Value = skillLevel, SkillType = SkillType.Offensive
            };
            skills.Avoidance = new Skill {
                Name = "AVOIDANCE", Value = skillLevel, SkillType = SkillType.Defensive
            };
            skills.Melee = new Skill {
                Name = "MELEE", Value = skillLevel, SkillType = SkillType.Offensive
            };
            ecs_instance.add_component(e, skills);

            Factions factions = new Factions();

            factions.OwnerFaction = new Faction {
                Name = "ALLY", Value = 100, FactionType = FactionType.Ally
            };
            factions.KnownFactions.Add("WILDERNESS", new Faction {
                Name = "WILDERNESS", Value = -10, FactionType = FactionType.Wilderness
            });
            factions.KnownFactions.Add("PLAYER", new Faction {
                Name = "PLAYER", Value = 100, FactionType = FactionType.Player
            });
            ecs_instance.add_component(e, factions);


            ecs_instance.add_component(e, EntityFactory.createLight(true, 3, new Vector3(position, 10), 0.5f, new Vector4(1, 1, 1, 1)));


            ecs_instance.resolve(e);
        }
Exemplo n.º 5
0
        public override void LoadContent()
        {
            //create backdrop
            UIFactory.createFrame(null, new Point(0, 0), s_Container.GraphicsDevice.Viewport.Height, s_Container.GraphicsDevice.Viewport.Width, "Title");


            //create menu
            Entity e = ecs_instance.create();

            int   border   = 10;
            int   spacing  = 5;
            int   height   = 38;
            int   width    = 100;
            Point screen   = new Point(s_Container.GraphicsDevice.Viewport.Width, s_Container.GraphicsDevice.Viewport.Height);
            Point location = new Point(screen.X / 2 - (width + 2 * border) / 2, screen.Y / 2);

            s_ButtonMenu = new ButtonMenu(e, null, ecs_instance, 3, location, height, width, border, spacing);


            s_ButtonMenu.init();

            s_ButtonMenu.Frame.background_name  = "frame";
            s_ButtonMenu.Frame.background_color = Color.Black;
            s_ButtonMenu.Frame.transparency     = 0.75f;

            s_ButtonMenu.Buttons[0].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[0].background_color = Color.Gray;
            s_ButtonMenu.Buttons[0].transparency     = 1f; //0.75f;
            s_ButtonMenu.Buttons[0].border           = 10;
            s_ButtonMenu.Buttons[0].font_name        = "General";
            s_ButtonMenu.Buttons[0].autosize         = false;
            s_ButtonMenu.Buttons[0].center_text      = true;
            s_ButtonMenu.Buttons[0].text             = "New Game";
            s_ButtonMenu.Buttons[0].text_color       = Color.White;
            s_ButtonMenu.Buttons[0].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[0].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[0].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[0].mouse_click     += OnMouseClickNewGame;

            s_ButtonMenu.Buttons[1].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[1].background_color = Color.Gray;
            s_ButtonMenu.Buttons[1].transparency     = 1f;
            s_ButtonMenu.Buttons[1].border           = 10;
            s_ButtonMenu.Buttons[1].font_name        = "General";
            s_ButtonMenu.Buttons[1].autosize         = false;
            s_ButtonMenu.Buttons[1].center_text      = true;
            s_ButtonMenu.Buttons[1].text             = "World Gen";
            s_ButtonMenu.Buttons[1].text_color       = Color.White;
            s_ButtonMenu.Buttons[1].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[1].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[1].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[1].mouse_click     += OnMouseClickWorldGen;

            s_ButtonMenu.Buttons[2].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[2].background_color = Color.Gray;
            s_ButtonMenu.Buttons[2].transparency     = 1f;
            s_ButtonMenu.Buttons[2].border           = 10;
            s_ButtonMenu.Buttons[2].font_name        = "General";
            s_ButtonMenu.Buttons[2].autosize         = false;
            s_ButtonMenu.Buttons[2].center_text      = true;
            s_ButtonMenu.Buttons[2].text             = "Exit Game";
            s_ButtonMenu.Buttons[2].text_color       = Color.White;
            s_ButtonMenu.Buttons[2].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[2].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[2].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[2].mouse_click     += OnMouseClickExit;


            s_ButtonMenu.assemble();

            UserInterface ui = new UserInterface(s_ButtonMenu.Form);

            ecs_instance.add_component(e, ui);

            ecs_instance.resolve(e);

            //load the json start screen file
            s_json = s_JsonManager.loadJSON(GameConfig.root_dir + "/Content/json/start_screen.v");

            //create mouse pointer
            s_Frame = UIFactory.createMousePointer(InputManager.getMousePosition(), 10, 10, "pointer", OnMousePointerUpdate);

            //early entity reslove
            ecs_instance.resolve_entities();

            //load system content
            ecs_instance.system_manager.systems_load_content();

            base.LoadContent();
        }
Exemplo n.º 6
0
        /// <summary>
        /// create an attack
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="defender"></param>
        /// <param name="attackType"></param>
        public static void createAttack(Entity attacker, Entity defender, AttackType attackType)
        {
            Entity e = ecs_instance.create();

            ecs_instance.add_component(e, new Attack(attacker, defender, attackType));

            ecs_instance.resolve(e);
        }
Exemplo n.º 7
0
        public static Entity createPlayer(int skillLevel)
        {
            Entity e = ecs_instance.create();

            GameMap gameMap = ComponentMapper.get <GameMap> (ecs_instance.tag_manager.get_entity_by_tag("MAP"));
            Vector2 pos     = MapFactory.findSafeLocation(gameMap);

            //ECSInstance.entity_manager.add_component(e, new Position(new Vector2(576f, 360f),new Vector2(12.5f)));
            ecs_instance.add_component(e, new Position(pos, new Vector2(16)));
            //ECSInstance.entity_manager.add_component(e, new Position(new Vector2(0, 0), new Vector2(12.5f)));
            ecs_instance.add_component(e, new Velocity(4f));
            ecs_instance.add_component(e, new Controllable());
            //ECSInstance.entity_manager.add_component(e, new Sprite("characters\\lor_lar_sheet", "characters\\normals\\lor_lar_sheet_normals",32,32,0,0));;

            ecs_instance.add_component(e, AnimationFactory.createPlayerAnimation());
            ecs_instance.add_component(e, new CameraFocus(75));
            ecs_instance.add_component(e, new MapCollidable());
            ecs_instance.add_component(e, new Heading());
            ecs_instance.add_component(e, createLight(true, 8, new Vector3(new Vector2(576f, 360f), 10), 0.5f, new Vector4(1, 1, .6f, 1)));
            ecs_instance.add_component(e, new Transform());

            Information info = new Information();

            info.GeneralGroup   = "HUMAN";
            info.VariationGroup = "NONE";
            info.UniqueGroup    = "NONE";
            info.Name           = "PLAYER";
            ecs_instance.add_component(e, info);

            //create life
            Life life = new Life();

            life.IsAlive        = true;
            life.DeathLongevity = 1000;
            ecs_instance.add_component(e, life);

            //create interactions
            Interactable interact = new Interactable();

            interact.SupportedInteractions.PROJECTILE_COLLIDABLE = true;
            interact.SupportedInteractions.ATTACKABLE            = true;
            interact.SupportedInteractions.MAY_RECEIVE_VICTORY   = true;
            interact.SupportedInteractions.MAY_ADVANCE           = true;
            interact.SupportedInteractions.CAUSES_ADVANCEMENT    = false;
            interact.SupportedInteractions.AWARDS_VICTORY        = false;
            ecs_instance.add_component(e, interact);

            //create test equipment
            ItemFactory iFactory = new ItemFactory(ecs_instance);

            ecs_instance.add_component(e, iFactory.createTestEquipment());

            //setup experiences
            Knowledges knowledges = new Knowledges();

            knowledges.GeneralKnowledge.Add("HUMAN", new Knowledge {
                Name = "", Value = skillLevel, KnowledgeType = KnowledgeType.General
            });
            knowledges.GeneralKnowledge.Add("BAT", new Knowledge {
                Name = "", Value = skillLevel, KnowledgeType = KnowledgeType.General
            });
            knowledges.VariationKnowledge.Add("NONE", new Knowledge {
                Name = "", Value = 0f, KnowledgeType = KnowledgeType.General
            });
            knowledges.UniqueKnowledge.Add("NONE", new Knowledge {
                Name = "", Value = 0f, KnowledgeType = KnowledgeType.General
            });
            ecs_instance.add_component(e, knowledges);

            //setup attributes
            Statistics statistics = new Statistics();

            statistics.Focus = new Statistic {
                Name = "FOCUS", Value = skillLevel, StatType = StatType.FOCUS
            };
            statistics.Endurance = new Statistic {
                Name = "ENDURANCE", Value = skillLevel, StatType = StatType.ENDURANCE
            };
            statistics.Mind = new Statistic {
                Name = "MIND", Value = skillLevel, StatType = StatType.MIND
            };
            statistics.Muscle = new Statistic {
                Name = "MUSCLE", Value = skillLevel, StatType = StatType.MUSCLE
            };
            statistics.Perception = new Statistic {
                Name = "PERCEPTION", Value = skillLevel, StatType = StatType.PERCEPTION
            };
            statistics.Personality = new Statistic {
                Name = "PERSONALITY", Value = skillLevel, StatType = StatType.PERSONALITY
            };
            statistics.Quickness = new Statistic {
                Name = "QUICKNESS", Value = skillLevel, StatType = StatType.QUICKNESS
            };
            ecs_instance.add_component(e, statistics);

            //create health
            Health health = new Health(statistics.Endurance.Value * 5);            // new Health(5000);//

            health.RecoveryAmmount = statistics.Endurance.Value / 5;
            health.RecoveryRate    = 1000;
            ecs_instance.add_component(e, health);

            //setup skills
            Skills skills = new Skills();

            skills.Ranged = new Skill {
                Name = "RANGED", Value = skillLevel, SkillType = SkillType.Offensive
            };
            skills.Avoidance = new Skill {
                Name = "AVOIDANCE", Value = skillLevel, SkillType = SkillType.Defensive
            };
            skills.Melee = new Skill {
                Name = "MELEE", Value = skillLevel, SkillType = SkillType.Offensive
            };
            ecs_instance.add_component(e, skills);

            Factions factions = new Factions();

            factions.OwnerFaction = new Faction {
                Name = "PLAYER", Value = 100, FactionType = FactionType.Player
            };
            factions.KnownFactions.Add("WILDERNESS", new Faction {
                Name = "WILDERNESS", Value = -10, FactionType = FactionType.Wilderness
            });
            factions.KnownFactions.Add("ALLY", new Faction {
                Name = "ALLY", Value = 100, FactionType = FactionType.Ally
            });
            ecs_instance.add_component(e, factions);

            GameSession.PlayerState              = new PlayerState();
            GameSession.PlayerState.Statistics   = statistics;
            GameSession.PlayerState.Factions     = factions;
            GameSession.PlayerState.Health       = health;
            GameSession.PlayerState.Information  = info;
            GameSession.PlayerState.Interactable = interact;
            GameSession.PlayerState.Knowledges   = knowledges;
            GameSession.PlayerState.Life         = life;
            GameSession.PlayerState.Skills       = skills;

            ecs_instance.tag_manager.tag_entity("PLAYER", e);

            ecs_instance.resolve(e);

            return(e);
        }