Exemple #1
0
        public static Entity recreatePlayer(PlayerState playerHolder, Position position)
        {
            Entity e = ecs_instance.create();

            ecs_instance.add_component(e, position);
            //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());

            /* LIKELY NOT NEEDED
             * GameSession.PlayerState.Attributes.setEntityId(e.Id);
             * GameSession.PlayerState.Factions.setEntityId(e.Id);
             * GameSession.PlayerState.Health.setEntityId(e.Id);
             * GameSession.PlayerState.Information.setEntityId(e.Id);
             * GameSession.PlayerState.Interactable.setEntityId(e.Id);
             * GameSession.PlayerState.Knowledges.setEntityId(e.Id);
             * GameSession.PlayerState.Life.setEntityId(e.Id);
             * GameSession.PlayerState.Skills.setEntityId(e.Id);
             */

            ecs_instance.add_component(e, playerHolder.Information);
            ecs_instance.add_component(e, playerHolder.Life);
            ecs_instance.add_component(e, playerHolder.Interactable);

            ItemFactory iFactory = new ItemFactory(ecs_instance);

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

            ecs_instance.add_component(e, playerHolder.Knowledges);
            ecs_instance.add_component(e, playerHolder.Statistics);
            ecs_instance.add_component(e, playerHolder.Health);
            ecs_instance.add_component(e, playerHolder.Skills);
            ecs_instance.add_component(e, playerHolder.Factions);

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

            ecs_instance.resolve(e);

            return(e);
        }
Exemple #2
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);
        }