Пример #1
0
    public UT_BuildingMechanics(List <DAT_Building> buildings)
    {
        m_graphBuildings = new UT_DirectedGraph <BuildingStats>();

        // add nodes
        foreach (DAT_Building building in buildings)
        {
            BuildingStats temp = new BuildingStats();
            temp.data         = building;
            temp.availability = 0;

            m_graphBuildings.AddNode(temp);
        }

        // set connections
        m_graphBuildings.Foreach((UT_Node <BuildingStats> node) =>
        {
            BuildingStats stats = node.GetData();

            foreach (DAT_Building.BuildDependency dep in stats.data.dependencies)
            {
                UT_Node <BuildingStats> temp = GetNode(dep.unlocksBuilding);
                m_graphBuildings.AddConnection(node, temp);
            }
        });

        GetPathLengths(5);
        GetPathLengths(1);
        GetPathLengths(33);
        m_graphBuildings.Foreach((UT_Node <BuildingStats> node) => {
            Debug.Log(node.GetData().data.name + " level: " + node.GetData().buildingLevel);
        });
    }
Пример #2
0
        private void parseListXML(string xml)
        {
            bool      endOfList = false;
            XmlReader reader    = XmlReader.Create(new StringReader(xml));

            while (!endOfList)
            {
                try
                {
                    reader.ReadToFollowing("Building");
                    buildingTypes.Add(reader.ReadElementContentAsString());
                }
                catch
                {
                    endOfList = true;
                }
            }
            reader.Close();

            foreach (string s in buildingTypes)
            {
                BuildingStats stats = new BuildingStats();
                statsDict.Add(s, stats);

                string xmlBuilding = readFile(BASE_DIR + s + ".xml");

                readBuildingXML(xmlBuilding);

                Console.WriteLine(stats.ToString());
            }
        }
Пример #3
0
 void Start()
 {
     statsPrefab       = Resources.Load <GameObject>("Prefabs/Level/AttackBuildingStats");
     muzzleFlashPrefab = Resources.Load <GameObject>("Prefabs/MuzzleFlash");
     spriteRenderer    = GetComponent <SpriteRenderer>();
     stats             = ((GameObject)Instantiate(statsPrefab)).GetComponent <BuildingStats>();
 }
 /// <summary>
 /// Constructor that defines the requirements for a Building.
 /// </summary>
 /// <param name="unitReqs">List of UnitStats of Units needed.</param>
 /// <param name="buildingReqs">List of BuildingStats of Buildings needed.</param>
 /// <param name="bstats">BuildingStats of the kind of Building the requirements are being defined for.</param>
 public ReqList(List <UnitStats> unitReqs, List <BuildingStats> buildingReqs, BuildingStats bstats)
 {
     this.unitReqs     = unitReqs;
     this.buildingReqs = buildingReqs;
     this.bstats       = bstats;
     type = ReqType.Building;
 }
Пример #5
0
        private void readBuildingXML(string xml)
        {
            XmlReader reader = XmlReader.Create(new StringReader(xml));

            reader.ReadToFollowing("type");
            string type = reader.ReadElementContentAsString();

            reader.ReadToFollowing("width");
            short width = (short)reader.ReadElementContentAsInt();

            reader.ReadToFollowing("height");
            short height = (short)reader.ReadElementContentAsInt();

            reader.ReadToFollowing("maxHealth");
            short maxHealth = (short)reader.ReadElementContentAsInt();

            reader.ReadToFollowing("buildCycles");
            short buildCycles = (short)reader.ReadElementContentAsInt();

            reader.ReadToFollowing("dropOffResources");
            bool dropOffResources = reader.ReadElementContentAsBoolean();

            BuildingStats stats = statsDict[type];

            stats.buildingType     = type;
            stats.width            = width;
            stats.height           = height;
            stats.maxHealth        = maxHealth;
            stats.buildCycles      = buildCycles;
            stats.dropOffResources = dropOffResources;
        }
Пример #6
0
        public Bot(GameState gameState)
        {
            this.gameState = gameState;
            mapHeight      = gameState.GameDetails.MapHeight;
            mapWidth       = gameState.GameDetails.MapWidth;

            attackStats   = gameState.GameDetails.BuildingsStats[BuildingType.Attack];
            defenseStats  = gameState.GameDetails.BuildingsStats[BuildingType.Defense];
            energyStats   = gameState.GameDetails.BuildingsStats[BuildingType.Energy];
            minimumEnergy = Math.Min(attackStats.Price, Math.Min(defenseStats.Price, energyStats.Price));
            maximumEnergy = Math.Max(attackStats.Price, Math.Max(defenseStats.Price, energyStats.Price));

            myAttackBuildings  = GetBuildings(PlayerType.A, BuildingType.Attack);
            myDefenceBuildings = GetBuildings(PlayerType.A, BuildingType.Defense);
            myEnergyBuildings  = GetBuildings(PlayerType.A, BuildingType.Energy);

            enemyAttackBuildings  = GetBuildings(PlayerType.B, BuildingType.Attack);
            enemyDefenceBuildings = GetBuildings(PlayerType.B, BuildingType.Defense);
            enemyEnergyBuildings  = GetBuildings(PlayerType.B, BuildingType.Energy);
            enemyAttacks          = GetEnemyAttacks();

            random = new Random((int)DateTime.Now.Ticks);

            player = gameState.Players.Single(x => x.PlayerType == PlayerType.A);
        }
Пример #7
0
 private void OnTriggerEnter(Collider hit)
 {
     /* if (hit.gameObject.tag == "RED_PLAYER" && !isLocalPlayer)
      * {
      *   player = hit.gameObject.GetComponent<PlayerStats>();
      *   player.CmdRemoveHealth(damageToPlayer);
      *   Debug.Log("Red Player Hit");
      *
      * }
      * if (hit.gameObject.tag == "BLUE_PLAYER" && !isLocalPlayer)
      * {
      *   player = hit.gameObject.GetComponent<PlayerStats>();
      *   player.CmdRemoveHealth(damageToPlayer);
      *   Debug.Log("Blue Player Hit");
      *
      * }*/
     if (hit.gameObject.tag == "RED_BUILDING_HQ")
     {
         building = hit.gameObject.GetComponent <BuildingStats>();
         building.RemoveHealth(damageToBuildings);
         Debug.Log("Take that building scum!");
     }
     if (hit.gameObject.tag == "BLUE_BUILDING_HQ")
     {
         building = hit.gameObject.GetComponent <BuildingStats>();
         building.RemoveHealth(damageToBuildings);
         Debug.Log("Take that building scum!");
     }
     if (hit.gameObject.tag == "EnemyAI")
     {
         //HEALTH = hit.GetComponent<EnemyAI>();
         //HEALTH.RemoveHealth(damageToPlayer);
         print("Enemy Ouch");
     }
 }
Пример #8
0
    public void SetUp(BuildingStats _stats)
    {
        isConstructing        = true;
        patron                = _stats;
        spriteRenderer.sprite = _stats.building_sprite;
        if (construction == null)
        {
            construction = new Construction();
        }
        construction.stockRequired = _stats.buildCost.Copy();
        construction.stockCurrent  = new ResourceStack(0, 0, 0);
        construction.needRessource = true;

        if (currentStock == null)
        {
            currentStock = new ResourceStack(0, 0, 0);
        }
        maxStock = _stats.stock.Copy();
        workers  = new Worker[_stats.workerRequired];
        for (int x = 0; x < workers.Length; x++)
        {
            if (workers[x] == null)
            {
                workers[x] = new Worker();
            }
        }
        workerSize            = _stats.workerRequired;
        structurePointCurrent = 1;
        GameState.instance.buildingsOnMap.Add(this);
        isActive = true;
    }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        SceneCEO sceo = GameObject.Find("SceneCEO").GetComponent <SceneCEO>();

        for (int i = 0; i < sceo.spawnedManagerList.Count; i++)
        {
            if (sceo.spawnedManagerList[i].GetComponent <SwarmMovementManager>() != null)
            {
                friendlySwarmManager = sceo.spawnedManagerList[i].GetComponent <SwarmMovementManager>();
            }
        }

        //rubbleFab = Resources.Load<GameObject>("Prefabs/Rubble");
        barrelObj   = Resources.Load <GameObject>("Prefabs/OilBarrel");
        barrelObjBG = Resources.Load <GameObject>("Prefabs/OilBarrelBG");
        fireObj     = Resources.Load <GameObject>("Prefabs/FireParticle");
        rubbleSpr   = Resources.Load <Sprite>("Images/Gas_Station_Destroy");
        if (stats == null)
        {
            Debug.Log(Time.time + " " + gameObject.name + " missing stats");
        }
        statsObj = (Instantiate(stats) as GameObject).GetComponent <BuildingStats>();

        DoInitialSpawn();


        GetComponent <SpriteRenderer>().sortingOrder = -(int)((transform.position.y + ySortingOffset) * 100);
    }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     buttonImage     = GetComponent <Button>().GetComponent <Image>();
     uICommander     = GetComponentInParent <UICommander>();
     soundCantAfford = GetComponentInParent <AudioSource>();
     team            = GetComponentInParent <Team>();
     stats           = GetComponentInChildren <BuildingStats>();
 }
 /// <summary>
 /// Contructor. Given an xml string and a BuildingStats object, this constructor will create a ReqList object for the
 /// Building defined by bstats based on the requirements described in the xml string.
 /// </summary>
 /// <param name="xml"></param>
 /// <param name="bstats"></param>
 public ReqList(string xml, BuildingStats bstats)
 {
     this.unitReqs     = new List <UnitStats>();
     this.buildingReqs = new List <BuildingStats>();
     this.bstats       = bstats;
     type = ReqType.Building;
     readReqXML(xml);
 }
Пример #12
0
    public void UpdatePerDay()
    {
        m_graphBuildings.Foreach((UT_Node <BuildingStats> node) =>
        {
            node.GetData().overallMood      = 0;
            node.GetData().availability     = 0;
            node.GetData().createdInstances = 0;
        });

        List <IBuilding> buildings = M_BuildingManager.SGetBuildings();

        foreach (IBuilding building in buildings)
        {
            if (building is IBuildingHouse)
            {
                GetNode(building.GetData().id).GetData().createdInstances++;
                continue;
            }
            if (!(building is IBuildingProduction))
            {
                continue;
            }

            IBuildingProduction     prod = (IBuildingProduction)building;
            UT_Node <BuildingStats> node = GetNode(building.GetData().id);
            node.GetData().overallMood  += prod.GetMood();
            node.GetData().createdInstances++;

            if (prod.IsWorking())
            {
                M_WaresManager.SAddProductiveBuilding(prod.GetId(), prod.GetProducedWareType());
            }
            else
            {
                M_WaresManager.SRemoveProductiveBuilding(prod.GetId(), prod.GetProducedWareType());
            }
        }

        m_graphBuildings.Foreach((UT_Node <BuildingStats> node) =>
        {
            BuildingStats stats = node.GetData();
            foreach (DAT_Building.BuildDependency dep in stats.data.dependencies)
            {
                if (stats.overallMood > dep.requiredMood)
                {
                    UT_Node <BuildingStats> tempNode = GetNode(dep.unlocksBuilding);
                    tempNode.GetData().availability += 1;
                    if (tempNode.GetData().availability == tempNode.GetAdjacent().Count &&
                        m_currentBuildingsLevel < tempNode.GetData().buildingLevel)
                    {
                        m_currentBuildingsLevel = tempNode.GetData().buildingLevel;
                    }
                }
            }
        });
    }
Пример #13
0
 public BuildingStats(BuildingStats source) //Deep copy
 {
     id                          = source.id;
     cost                        = source.cost;
     type                        = source.type;
     constructionTime            = source.constructionTime;
     requireResourcesToConstruct = source.requireResourcesToConstruct;
     minBudget                   = source.minBudget;
     maxBudget                   = source.maxBudget;
 }
Пример #14
0
 public BuildingStats(BuildingStats source) //Deep copy
 {
     id   = source.id;
     cost = source.cost;
     type = source.type;
     constructionDuration = source.constructionDuration;
     capacity             = source.capacity;
     minBudget            = source.minBudget;
     maxBudget            = source.maxBudget;
 }
Пример #15
0
    BuildingStats GenerateStats(int floors)
    {
        var buildingStats = new BuildingStats
        {
            ValuePerFloor = valuePerStoryHeight,
            FloorCount    = floors,
        };

        return(buildingStats);
    }
Пример #16
0
 public void ShowStats()
 {
     buildingStats = BuildingPrefab.GetComponent <BuildingStats>();
     //  healthScript = BuildingPrefab.GetComponent<HealthScript>();
     //   txtName.text = buildingStats.Name;
     //   txtDamage.text = "Damage: " + buildingStats.Damage;
     //    txtHealth.text = "Health: " + healthScript.MaxHealth;
     txtCost.text = buildingStats.Wood + " Wood, " + buildingStats.Stone + " Stone";
     //txtStoneCost.text = "Stone: " + buildingStats.Stone;
 }
Пример #17
0
        public void ShowTooltip(BuildingStats stats, Color colorMoney, Color colorOil)
        {
            Name.text        = stats.Name;
            Hotkey.text      = "[" + stats.Hotkey + "]";
            Description.text = stats.Description;
            CostMoney.text   = stats.costMoney.ToString();
            CostOil.text     = stats.costOil.ToString();

            CostMoney.color = colorMoney;
            CostOil.color   = colorOil;
        }
Пример #18
0
 bool CanBuild(BuildingStats stats)
 {
     if (stats == null)
     {
         return(true);
     }
     if (stats == building?.Stats)
     {
         return(false);
     }
     return(StorageHelper.HasAll(ResourceManager.GetInstance, stats.ConstructionCost));
 }
 public void Load()
 {
     currentBuilding      = GameControllerScript.Instance.currentBuilding;
     numberOfInteractions = currentBuilding.settings.interactions;
     nazwaBudynku.text    = currentBuilding.settings.buildingName;
     buildingIcon.sprite  = currentBuilding.settings.icon;
     for (int i = 0; i < numberOfInteractions; i++)
     {
         GameObject card = Instantiate(cardPrefab, interactionsContainer.transform);
         card.GetComponent <CardBuildInterDisplay>().id = i;
     }
 }
Пример #20
0
    public List <DAT_Ware.Type> GetAvailableWares(int a, int b)
    {
        List <DAT_Ware.Type> wares = new List <DAT_Ware.Type>();

        m_graphBuildings.Foreach((UT_Node <BuildingStats> node) => {
            BuildingStats stats = node.GetData();
            if (stats.data is DAT_BuildingProd && stats.buildingLevel >= a && stats.buildingLevel <= b)
            {
                wares.Add(((DAT_BuildingProd)stats.data).producedWare);
            }
        });

        return(wares);
    }
Пример #21
0
        public Bot(GameState gameState)
        {
            this._gameState = gameState;
            this._mapHeight = gameState.GameDetails.MapHeight;
            this._mapWidth  = gameState.GameDetails.MapWidth;

            this._attackStats  = gameState.GameDetails.BuildingsStats[BuildingType.Attack];
            this._defenseStats = gameState.GameDetails.BuildingsStats[BuildingType.Defense];
            this._energyStats  = gameState.GameDetails.BuildingsStats[BuildingType.Energy];

            this._random = new Random((int)DateTime.Now.Ticks);

            _player = gameState.Players.Single(x => x.PlayerType == PlayerType.A);
        }
Пример #22
0
        public Bot(GameState gameState)
        {
            this.gameState = gameState;
            this.mapHeight = gameState.GameDetails.MapHeight;
            this.mapWidth  = gameState.GameDetails.MapWidth;

            this.attackBuilding  = gameState.GameDetails.BuildingsStats[BuildingType.Attack];
            this.defenseBuilding = gameState.GameDetails.BuildingsStats[BuildingType.Defense];
            this.energyBuilding  = gameState.GameDetails.BuildingsStats[BuildingType.Energy];

            this.random = new Random((int)DateTime.Now.Ticks);

            myPlayer = gameState.Players.Single(x => x.PlayerType == PlayerType.A);
        }
Пример #23
0
    public List <DAT_Building> GetAvailableBuildings()
    {
        List <DAT_Building> res = new List <DAT_Building>();

        m_graphBuildings.Foreach((UT_Node <BuildingStats> node) =>
        {
            BuildingStats stats = node.GetData();
            if (stats.availability == node.GetInAdjacent().Count)
            {
                res.Add(stats.data);
            }
        });

        return(res);
    }
Пример #24
0
    public void SellMenuStats()
    {
        if (!playerStats)
        {
            NewPlayer();
        }

        buildingStats        = BuildingPrefab.GetComponent <BuildingStats>();
        healthScript         = BuildingPrefab.GetComponent <HealthScript>();
        txtName.text         = buildingStats.Name + " Level " + buildingStats.Level;
        txtDamage.text       = "Damage: " + buildingStats.Damage;
        txtUpgradePrice.text = "Upgrade: Wood: " + buildingStats.GetUpgradeWood() + ", Stone: " +
                               buildingStats.GetUpgradeStone();
        UpdateRepairCostAndHealth();
    }
Пример #25
0
        private void DoSimulation(BuildingStats stats, double elapsed)
        {
            var wChanges = mActionChanges;

            mActionChanges = new Changes();

            var wPersons = mBuildingRepository.GetPersons(PersonState.Hired);

            // Person

            // Project

            wChanges.Stats = stats;
            SendMessage(wChanges);
        }
        private void readBuildingXML(string xml)
        {
            XmlReader reader = XmlReader.Create(new StringReader(xml));

            reader.ReadToFollowing("type");
            string type = reader.ReadElementContentAsString();

            BuildingStats stats = statsDict[type];

            reader.ReadToFollowing("width");
            byte width = (byte)reader.ReadElementContentAsInt();

            reader.ReadToFollowing("height");
            byte height = (byte)reader.ReadElementContentAsInt();

            reader.ReadToFollowing("maxHealth");
            short maxHealth = (short)reader.ReadElementContentAsInt();

            reader.ReadToFollowing("dropOffResources");
            bool dropOffResources = reader.ReadElementContentAsBoolean();

            reader.ReadToFollowing("canProduce");
            bool canProduce = reader.ReadElementContentAsBoolean();

            // Read in what Units this Building can produce.
            bool endOfList = false;

            while (!endOfList)
            {
                try
                {
                    reader.ReadToFollowing("Unit");
                    string unitType = reader.ReadElementContentAsString();
                    stats.productionTypes.Add(unitType);
                }
                catch
                {
                    endOfList = true;
                }
            }

            stats.buildingType     = type;
            stats.width            = width;
            stats.height           = height;
            stats.maxHealth        = maxHealth;
            stats.dropOffResources = dropOffResources;
            stats.canProduce       = canProduce;
        }
Пример #27
0
    public bool CanBuy()
    {
        BuildingStats buildingStats = SelectedBuilding.GetComponent <BuildingStats>();
        PlayerStats   playerStats   = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStats>();

        if (playerStats != null)
        {
            if (buildingStats.Stone <= playerStats.Stone && buildingStats.Wood <= playerStats.Wood && CanBuild())
            {
                playerStats.Stone -= buildingStats.Stone;
                playerStats.Wood  -= buildingStats.Wood;
                return(true);
            }
            return(false);
        }
        return(false);
    }
        private bool playerHasBuilding(Player.Player player, BuildingStats bstats)
        {
            List <Entity> entities = player.getEntities();

            foreach (Entity e in entities)
            {
                if (e.entityType == Entity.EntityType.Building)
                {
                    Building b = (Building)e;
                    if (b.stats.buildingType == bstats.buildingType)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #29
0
        public Bot(GameState gameState, List <Command> history)
        {
            this.gameState = gameState;
            mapHeight      = gameState.GameDetails.MapHeight;
            mapWidth       = gameState.GameDetails.MapWidth;
            frontLine      = mapWidth / 2 - 1;

            attackPrefab  = gameState.GameDetails.BuildingsStats[BuildingType.Attack];
            defensePrefab = gameState.GameDetails.BuildingsStats[BuildingType.Defense];
            energyPrefab  = gameState.GameDetails.BuildingsStats[BuildingType.Energy];

            previousCommands = history;

            random = new Random((int)DateTime.Now.Ticks);

            player = gameState.Players.Single(x => x.PlayerType == PlayerType.A);
            enemy  = gameState.Players.Single(x => x.PlayerType == PlayerType.B);
        }
        private void parseListXML(string xml)
        {
            bool      endOfList = false;
            XmlReader reader    = XmlReader.Create(new StringReader(xml));

            while (!endOfList)
            {
                try
                {
                    reader.ReadToFollowing("Requirements");
                    string type = reader.GetAttribute("type");

                    if (type.ToUpper().Equals("BUILDING"))
                    {
                        string        btype  = reader.GetAttribute("btype");
                        BuildingStats bstats = BuildingFactory.Instance.getStats(btype);
                        if (bstats != null)
                        {
                            string  innerXML = reader.ReadInnerXml();
                            ReqList reqList  = new ReqList(innerXML, bstats);
                            this.buildingReqs.Add(bstats, reqList);
                        }
                    }
                    else if (type.ToUpper().Equals("UNIT"))
                    {
                        string    utype  = reader.GetAttribute("utype");
                        UnitStats ustats = UnitFactory.Instance.getStats(utype);

                        if (ustats != null)
                        {
                            string  innerXML = reader.ReadInnerXml();
                            ReqList reqList  = new ReqList(innerXML, ustats);
                            this.unitReqs.Add(ustats, reqList);
                        }
                    }
                }
                catch
                {
                    endOfList = true;
                }
            }
            reader.Close();
        }
Пример #31
0
        public GameObjectStats GetObjectStats(string name)
        {
            if (xDocument == null)
            {
                throw new NullReferenceException("GameObjectStatsReader was not initialized");
            }

            GameObjectStats gameObjectStats = null;
            foreach (XElement xElement in xDocument.Root.Elements())
            {
                if (xElement.Attribute("Name").Value == name)
                {
                    float fgetter;
                    int igetter;
                    bool bgetter;
                    switch (xElement.Attribute("Type").Value)
                    {
                        case "GameObject":
                            if (gameObjectStats == null)
                            {
                                gameObjectStats = new GameObjectStats();
                            }
                            gameObjectStats.Name = xElement.Attribute("Name").Value;
                            GameObjectFactory.ObjectClass objectClass;
                            GameObjectFactory.ObjectClass.TryParse(xElement.Attribute("Type").Value, out objectClass);
                            gameObjectStats.Type = objectClass;
                            foreach(XElement xel in xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "Effect"))
                            {
                                gameObjectStats.Effects.Add(xel.Value);
                            }
                            foreach (XElement xel in xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "SubModel"))
                            {
                                Vector3 pos, rot, sc;

                                if(xel.Attribute("Position") != null)
                                {
                                    ParseVector3(xel.Attribute("Position").Value, out pos);
                                }
                                else
                                {
                                    pos = Vector3.Zero;
                                }
                                if (xel.Attribute("Rotation") != null)
                                {
                                    ParseVector3(xel.Attribute("Rotation").Value, out rot);
                                }
                                else
                                {
                                    rot = Vector3.Zero;
                                }
                                if (xel.Attribute("Scale") != null)
                                {
                                    ParseVector3(xel.Attribute("Scale").Value, out sc);
                                }
                                else
                                {
                                    sc = Vector3.One;
                                }

                                gameObjectStats.SubElements.Add(new SubElement(xel.Value, pos, rot, sc));
                            }
                            break;

                        case "Unit":
                            if (gameObjectStats == null)
                            {
                                gameObjectStats = new UnitStats();
                            }

                            float.TryParse(
                                xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "Speed").First().Value, out fgetter);
                            ((UnitStats)gameObjectStats).Speed = fgetter;
                            float.TryParse(
                                xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "TurnRadius").First().Value, out fgetter);
                            ((UnitStats)gameObjectStats).TurnRadius = fgetter;
                            goto case "GameObject";

                        case "Infantry":
                            if (gameObjectStats == null)
                            {
                                gameObjectStats = new InfantryStats();
                            }
                            goto case "Unit";

                        case "Vehicle":
                            if (gameObjectStats == null)
                            {
                                gameObjectStats = new VehicleStats();
                            }
                            Int32.TryParse(
                                xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "FrontWheelsCount").First().Value, out igetter);
                            ((VehicleStats)gameObjectStats).FrontWheelCount = igetter;
                            Int32.TryParse(
                                xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "RearWheelsCount").First().Value, out igetter);
                            ((VehicleStats)gameObjectStats).RearWheelCount = igetter;
                            Int32.TryParse(
                                xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "DoorCount").First().Value, out igetter);
                            ((VehicleStats)gameObjectStats).DoorCount = igetter;
                            Boolean.TryParse(
                                xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "HasTurret").First().Value, out bgetter);
                            ((VehicleStats)gameObjectStats).HasTurret = bgetter;
                            if (((VehicleStats)gameObjectStats).HasTurret)
                            {
                                Int32.TryParse(
                                    xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "WaterSourceCount").First().Value, out igetter);
                                ((VehicleStats)gameObjectStats).WaterSourceCount = igetter;
                            }
                            else
                            {
                                ((VehicleStats)gameObjectStats).WaterSourceCount = 0;
                            }
                            goto case "Unit";

                        case "Building":
                            if (gameObjectStats == null)
                            {
                                gameObjectStats = new BuildingStats();
                            }
                            goto case "GameObject";

                        case "StaticObject":
                            if (gameObjectStats == null)
                            {
                                gameObjectStats = new StaticObjectStats();
                            }
                            goto case "GameObject";

                        case "Civilian":
                            if (gameObjectStats == null)
                            {
                                gameObjectStats = new CivilianStats();
                            }
                            goto case "GameObject";
                    }
                    break;
                }
            }

            if(gameObjectStats == null)
            {
                throw new ArgumentException("Invalid Object name");
            }

            return gameObjectStats;
        }
Пример #32
0
 public void Init(BuildingType type, BuildingDefinition bd, int x, int y)
 {
     stats = new BuildingStats(bd, x, y);
 }