Пример #1
0
        public IEnt CreatePlayerInput()
        {
            var result = Engine.Instance.CreateEnt();

            result.AddCom
            (
                new PlayerInputCom()
            {
                TurnHandlerEnt = WorldEnt,
                GridEnt        = WorldEnt.GetCom <WorldCom>().Grid.Owner
            }
            );

            return(result);
        }
Пример #2
0
        public IEnt CreateDebugInfo()
        {
            var font = new ECS.Graphics.Font()
            {
                FileLocation = "calibri.ttf"
            };

            var debugEnt = Engine.Instance.CreateEnt();

            debugEnt.Subject           = new DebugSubject();
            debugEnt.PostionCom.LocalX = 10;
            debugEnt.PostionCom.LocalY = 10;


            var debugCom = debugEnt.AddCom(new UpdateDebugInfoCom());

            ((DebugSubject)debugEnt.Subject).AddObv(debugCom);

            debugEnt.AddCom
            (
                new PerfMessureCom()
            );

            debugEnt.AddCom
            (
                new DebugInputCom()
            );

            debugEnt.AddCom
            (
                new RenderTextCom()
            {
                Font     = font,
                Color    = new Color(byte.MaxValue, 0, 0),
                Floating = true,
                Priority = DrawLayer.UI
            }
            );

            Engine.Instance.Window.Camera.Subject.AddObv(debugCom);
            WorldEnt.GetCom <TurnHandlerCom>().DebugSubject = (DebugSubject)debugEnt.Subject;

            return(debugEnt);
        }
Пример #3
0
        public IEnt CreateFootSolider(GridCom grid, int i, int j, Faction factionToCreate, UnitType unitTypeToCreate)
        {
            var ent = Engine.Instance.CreateEnt
                      (
                WorldEnt,
                "FootSoilder:" + (_footSolider++).ToString() + " " + Utility.GetEnumName(unitTypeToCreate) + " " + Utility.GetEnumName(factionToCreate),
                new List <string>()
            {
                Tags.UNIT
            }
                      );

            Color hatColour;

            switch (factionToCreate)
            {
            case Faction.Red:
                hatColour = Color.Red;
                break;

            case Faction.Blue:
                hatColour = Color.Blue;
                break;

            case Faction.Green:
                hatColour = Color.Green;
                break;

            default:
                throw new System.NotImplementedException();
            }

            var statusShowEnt = Engine.Instance.CreateEnt(ent);

            ent.Subject = new GameSubject();

            statusShowEnt.AddCom
            (
                new DrawRectCom()
            {
                Priority = DrawLayer.UNITS_INFO_TOP
            }
            );

            var unitCom = ent.AddCom
                          (
                new UnitInfoCom()
            {
                Type    = unitTypeToCreate,
                Faction = factionToCreate
            }
                          );

            ((GameSubject)ent.Subject).AddObv(unitCom);

            var unitActionCom = ent.AddCom
                                (
                new UnitActionContCom()
                                );

            ((GameSubject)ent.Subject).AddObv(unitActionCom);

            if (factionToCreate != WorldEnt.GetCom <WorldCom>().PlayerFaction)
            {
                var regAiCom = ent.AddCom(new RegularSoliderAICom());
                ((GameSubject)ent.Subject).AddObv(regAiCom);
            }

            var progressBarEnt = CreateProgressBar(ent);

            progressBarEnt.PostionCom.LocalScale = new Vector2f(0.9f, 0.4f);
            progressBarEnt.PostionCom.LocalY     = -0.2f;
            progressBarEnt.PostionCom.LocalX     = 0.1f;

            var progressBarCom = progressBarEnt.GetCom <ProgressBarCom>();

            progressBarCom.Background.FillColor = Color.Red;
            progressBarCom.Forground.FillColor  = Color.Green;

            var healthCom = ent.AddCom
                            (
                new HealthCom()
            {
                MaxHealth    = unitCom.MaxHealth,
                HealthBarCom = progressBarCom
            }
                            );

            ent.AddCom
            (
                new DrawRectCom()
            {
                FillColor = unitCom.BaseColor,
                Priority  = DrawLayer.UNITS
            }
            );

            var hat = Engine.Instance.CreateEnt(ent);

            hat.PostionCom.LocalScale   = new Vector2f(0.8f, 0.8f);
            hat.PostionCom.LocalPostion = new Vector2f(0.2f, 0.2f);
            hat.AddCom
            (
                new DrawRectCom()
            {
                OutlineColor  = hatColour,
                LineThickness = 0.1f,
                Priority      = DrawLayer.UNITS_TOP
            }
            );

            grid.AddEnt(ent, i, j);
            return(ent);
        }