Beispiel #1
0
        public GameActionTabModel(IGameAction[] gameActions, GameActionGuiController parent)
        {
            this.parent = parent;

            GameActionTabItems = new GameActionTabItem[GAME_ACTIONS_PER_TAB];

            int column = 0;
            int row    = 0;

            for (int i = 0; i < gameActions.Length; i++)
            {
                IGameAction gameAction = gameActions[i];
                FloatCoords location   = new FloatCoords()
                {
                    x = column * (ItemWidth + HMoatSize) + HMoatSize,
                    y = row * (ItemWidth + VMoatSize) + VMoatSize
                };

                location += parent.View.Coords;

                ViewValues viewValues = new ViewValues(gameAction.IconValues.Image, ItemWidth, ItemWidth);
                gameAction.IconValues = viewValues;

                GameActionTabItems[i] = new GameActionTabItem(gameAction, location);
                column++;

                if (column < COLUMNS)
                {
                    continue;
                }

                column = 0;
                row++;
            }
        }
Beispiel #2
0
 protected GuiViewImage(FloatCoords location, ViewValues viewValues)
 {
     Coords  = location;
     Width   = viewValues.Width;
     Height  = viewValues.Height;
     Texture = viewValues.Image;
 }
        public SelectMapAction_GameAction(GameActionSelector.MapActionSelector selector, IMapAction mapAction, ViewValues iconValues)
        {
            IconValues = iconValues;
            Clicked   += () =>
            {
                if (mapAction == null)
                {
                    return;
                }

                selector.Select(mapAction);
            };
        }
Beispiel #4
0
 public GameAction(ViewValues iconValues)
 {
     IconValues = iconValues;
 }
Beispiel #5
0
        //FIXME split into multiple methods, GetBuildingDef, GetResourceFactoryDef, etc.
        //FIXME this is horribly designed. Do the above.
        // get the Def from a given building
        public static TStructureDef GetBuildingDef <TStructureDef>(int buildingId) where TStructureDef : BuildingDef
        {
            DBConn = OpenConnection("DefDex.db");

            string query = "SELECT * FROM BuildingDef WHERE Id=@i";

            bool isResourceFactory = IsBuildingResourceFactory(buildingId);

            BuildingDef buildingDef = new BuildingDef();

            if (isResourceFactory)
            {
                ResourceFactoryDef factoryDef = new ResourceFactoryDef
                {
                    ResourceType = GetResourceBuildingValues(buildingId)
                };
                buildingDef = factoryDef;
            }

            bool isTrainingStructure = IsStructureTrainingEntity(buildingId);

            if (isTrainingStructure)
            {
                TrainingStructureDef factoryDef = new TrainingStructureDef
                {
                    TrainableDefs = GetTrainingEntityTrainables(buildingId).ToList()
                };
                buildingDef = factoryDef;
            }

            using (SqliteCommand cmd = new SqliteCommand(query, DBConn))
            {
                cmd.Parameters.Add(new SqliteParameter("@i", buildingId));

                using (SqliteDataReader reader = cmd.ExecuteReader())
                {
                    if (!reader.Read())
                    {
                        throw new BuildingNotFoundException(buildingId);
                    }


                    //buildingDef.HPDef.CurrentHP = int.Parse(reader["CurrentHp"].ToString());
                    //buildingDef.HPDef.MaxHP = int.Parse(reader["MaxHp"].ToString());

                    ViewValues viewValues = new ViewValues(
                        reader["image"].ToString(),
                        float.Parse(reader["width"].ToString()),
                        float.Parse(reader["height"].ToString())
                        );

                    buildingDef.ViewValues = viewValues;

                    buildingDef.BuildingShape = BuildingShapeCalculator.GetShapeFromString(reader["shape"].ToString());

                    buildingDef.Cost       = float.Parse(reader["Cost"].ToString());
                    buildingDef.UpkeepCost = float.Parse(reader["Upkeep"].ToString());

                    buildingDef.ViewRange = int.Parse(reader["ViewRange"].ToString());

                    buildingDef.ConstructionTime = uint.Parse(reader["ConstructionTime"].ToString());
                }
            }

            return((TStructureDef)buildingDef);
        }
 protected MapAction(TActionDef actionDef, ViewValues iconValues)
 {
     ActionDef       = actionDef;
     IconValues      = iconValues;
     CurrentCooldown = actionDef.CooldownTime;
 }