Ejemplo n.º 1
0
        public IEnt CreateCell(GridCom gridCom, int i, int j, float width, float height)
        {
            var cellName = "Cell:" + i + "," + j;
            var newCell  = Engine.Instance.CreateEnt(gridCom.Owner, cellName, Tags.GRID_CELL);

            newCell.Subject = new GameSubject();

            var infoCom = newCell.AddCom
                          (
                new CellInfoCom()
            {
                Cords = new Vector2i(i, j),
                Type  = CellInfoCom.CellType.Nothing
            }
                          );

            ((GameSubject)newCell.Subject).AddObv(infoCom);

            newCell.PostionCom.LocalPostion = new Vector2f(j, i);

            newCell.AddCom
            (
                new DrawRectCom()
            {
                OutlineColor  = new Color(byte.MaxValue, byte.MaxValue, byte.MaxValue),
                LineThickness = 0,
                Priority      = DrawLayer.GRID_OVERLAY
            }
            );

            newCell.AddCom
            (
                new CellInputCom()
            );

            var cellBackgroundEnt = Engine.Instance.CreateEnt(newCell, "Background: " + cellName);
            var background        = cellBackgroundEnt.AddCom
                                    (
                new DrawRectCom()
            {
                Priority = DrawLayer.GRID_BACKGROUND
            }
                                    );

            var cellBackgroundTopEnt = Engine.Instance.CreateEnt(newCell, "BackgroundTop: " + cellName);
            var backgroundTop        = cellBackgroundTopEnt.AddCom
                                       (
                new DrawRectCom()
            {
                Priority = DrawLayer.GRID_BACKGROUND_TOP
            }
                                       );

            infoCom.Background    = background;
            infoCom.BackgroundTop = backgroundTop;



            return(newCell);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public IEnt CreateFootSolider(GridCom grid, int i, int j)
 {
     return(CreateFootSolider(grid, i, j, FactionToCreate, UnitTypeToCreate));
 }