Exemple #1
0
    public void UpdateBuilding()
    {
        name.text = buildingType.ToString();

        /*effect.text="";
         * list=Building.GetValidProduct(buildingType);
         * if(list.Count==0)
         * {
         *      for(int j=1;j<=Building.GetMaxLevel(buildingType);j++)
         *                      effect.text+="Lv."+j+"    "+Building.GetDescription(buildingType,ItemType.NUM,j)+"\n";
         * }
         * else
         * {
         *      for(int i=0;i<list.Count;i++)
         *      {
         *              for(int j=1;j<=Building.GetMaxLevel(buildingType);j++)
         *                      effect.text+="Lv."+j+"    "+Building.GetDescription(buildingType,list[i],j)+"\n";
         *      }
         * }*/

        if ((sprite = Resources.Load("Image/galleryThings/buildings/" + buildingType.ToString(), typeof(Sprite)) as Sprite) != null)
        {
            image.sprite = sprite;
        }


        otherData   = otherDescriptionReader.GetBuildingData(buildingType);
        story.text  = otherData.description;
        effect.text = otherData.effect;
    }
    public void CapUpButtonInteraction()
    {
        int[] costs;
        switch (buildingType)
        {
        case BuildingType.Mason:
            costs = TownBuilding.GetCapUpCost_MasonClaypit(buildingLv);
            break;

        case BuildingType.Smith:
            costs = TownBuilding.GetCapUpCost_SmithMines(buildingLv);
            break;

        case BuildingType.Sawmill:
            costs = TownBuilding.GetCapUpCost_SawmillWoodlands(buildingLv);
            break;

        default:
            throw new System.Exception(buildingType.ToString() + " isn't a resource building!");
        }
        if (GameDataManager.Instance.SpendResourcesIfPossible(costs))
        {
            GameDataManager.Instance.UpgradeResourceCap(resource);
        }
        else
        {
            shell.SurrenderFocus();
            insufficientResourcesPopup.Open();
        }
    }
        private void ShowBuildingElement(BuildingSettings element)
        {
            EditorGUILayout.BeginVertical("box");
            {
                BuildingType saveKind = element.Type;
                element.Type = (BuildingType)EditorGUILayout.EnumPopup("Type Building:", element.Type);
                if (GUI.changed && saveKind != element.Type)
                {
                    if (UsingType.Contains("bt_" + saveKind.ToString()))
                    {
                        UsingType.Remove("bt_" + saveKind.ToString());
                    }
                    UsingType.Add("bt_" + element.Type.ToString());
                }

                element.Material = (Material)EditorGUILayout.ObjectField("Material", element.Material, typeof(Material));

                if (element.Material == null)
                {
                    DisplayErrorMEssage("Not setting material");
                }


                element.IsVolumetric = EditorGUILayout.Toggle("IsVolumetric", element.IsVolumetric);

                EditorGUILayout.LabelField("BuildingHeight");
                EditorGUILayout.BeginHorizontal("box");
                element.MaximumBuildingHeight = EditorGUILayout.IntField("Maximum", element.MaximumBuildingHeight);
                element.MinimumBuildingHeight = EditorGUILayout.IntField("Minimum", element.MinimumBuildingHeight);
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
Exemple #4
0
    //건물생성함수(건물타입, 생성위치) : 매개변수를 토대로 프리팹을 가져와서 인스턴스화 한다
    //건물생성함수는 빌딩ID("건물타입_시간")를 생성한다
    public BuildingBase BuildBuilding(BuildingType type, Vector3 position)
    {
        // 이 때의 시간은 WorldTime이 아닌,
        // Unix time stamp를 써야한다.
        string objID = $"{type.ToString()}_{s_uniqueID++}";

        var resource = Resources.Load($"Prefabs/Building/{type.ToString()}");

        if (resource == null)
        {
            Debug.Log($"{type.ToString()}가 없어..");
            return(null);
        }

        GameObject building = Instantiate(resource, position, Quaternion.identity) as GameObject;

        BuildingBase objectBase = building.GetComponent <BuildingBase>();

        objectBase.ObjectID     = objID;
        objectBase.buildingType = type;

        buildingList.Add(objID, objectBase);

        return(objectBase);
    }
Exemple #5
0
    // 사전 설치 오브젝트 생성.. 반투명하게 하고시픈뎅..
    public Transform BuildPreInstallBuilding(BuildingType type)
    {
        var resource = Resources.Load($"Prefabs/Building/{type.ToString()}_preInstall");

        if (resource == null)
        {
            Debug.Log($"{type.ToString()}가 없어..");
            return(null);
        }

        GameObject building = Instantiate(resource) as GameObject;

        return(building.GetComponent <Transform>());
    }
 public static GameObject GetBuildingPrefab(BuildingType buildingType)
 {
     if (buildingPrefabs == null)
     {
         buildingPrefabs = new Dictionary <BuildingType, GameObject>();
     }
     if (!buildingPrefabs.ContainsKey(buildingType))
     {
         GameObject go = Resources.Load <GameObject>("Planet/Colony/" + buildingType.ToString());
         buildingPrefabs.Add(buildingType, go);
     }
     Debug.Assert(buildingPrefabs[buildingType] != null, "找不到建筑预制体 : " + buildingType.ToString());
     return(buildingPrefabs[buildingType]);
 }
    /// <summary>
    /// Stores an ammount of a given resource in this building. Returns 0 if it is successful. If it returns more that that it
    /// means that the returned ammount of resources could not be stored in there.
    /// </summary>
    /// <param name="resource"></param>
    /// <param name="ammount"></param>
    /// <returns></returns>
    public virtual int Store(ResourceType resource, int ammount)
    {
        if (!allowedGoods.Contains(resource))
        {
            throw new System.Exception("Building " + BuildingType.ToString() + " does not allow this kind of resource: " +
                                       resource.ToString());
        }
        if (storedGoods.ContainsKey(resource))
        {
            storedGoods[resource] += ammount;
        }
        else
        {
            storedGoods.Add(resource, ammount);
        }

        int notStoredAmmount = 0;

        if (usedCapacity + ammount > maxCapacity)
        {
            notStoredAmmount = maxCapacity - usedCapacity + ammount;
        }
        //We dont care if it overflows, the property takes care of it.
        UsedCapacity += ammount;
        return(notStoredAmmount);
    }
Exemple #8
0
    GameObject Build(BuildingType bt)
    {
        buildingType.Add(bt);

        GameObject go = Instantiate(Resources.Load("Prefabs/Buildings/" + bt.ToString())) as GameObject;

        Transform parentTransform = null;

        switch (bt)
        {
        case BuildingType.Fountain: parentTransform = library.buildings.fountains;  break;

        case BuildingType.SafeCupol: parentTransform = library.buildings.safeCupols; break;

        case BuildingType.Pusher: parentTransform = library.buildings.pushers; break;

        case BuildingType.Healing: parentTransform = library.buildings.healings; break;

        case BuildingType.Wall: parentTransform = library.buildings.walls; break;

        case BuildingType.BlackHole: parentTransform = library.buildings.blackHoles; break;
        }

        go.transform.SetParent(parentTransform, false);
        go.GetComponent <RectTransform>().position = GetComponent <RectTransform>().position;

        library.audioController.Build();

        return(go);
    }
Exemple #9
0
        public override UpdateData GetSetupData(SubscriberLevel subscriber)
        {
            var data = new UpdateData(type.ToString())
            {
                { "type", type.ToString() },
                { "lvl", lvl },
                { "productionSeconds", (DateTime.Now - lastProduced).TotalSeconds }
            };


            if (Setting.educts.Count > 0)
            {
                data["orderedProductions"] = orderedProductions;
            }
            return(data);
        }
    private void ShowBuildingButtons()
    {
        int i = 0;

        for (; i < buildingsAvailable.Count(); ++i)
        {
            BuildingType buildingType = buildingsAvailable[i];
            Sprite       sprite       = Resources.Load("UI/Icons/" + buildingInfos[(int)buildingType].Icon, typeof(Sprite)) as Sprite;
            buyingButtons[i].GetComponent <Image>().sprite = sprite;
            string buttonName = buildingType.ToString();
            buttonName = buttonName.First().ToString() + buttonName.Substring(1).ToLower();
            buyingButtons[i].gameObject.SetActive(true);
            nameTextsButton[i].text = buttonName;
            if (!selectedCity.HasBuilding(buildingType))
            {
                costTextsButton[i].text = buildingInfos[(int)buildingType].ShieldCost + " shields";
            }
            else
            {
                costTextsButton[i].text = "Built already";
            }
        }

        for (; i < TOTAL_BUY_BUTTONS; ++i)
        {
            buyingButtons[i].gameObject.SetActive(false);
        }

        showUnitsButton.gameObject.SetActive(true);
        showBuildingsButton.gameObject.SetActive(false);
    }
Exemple #11
0
        // Создание префаба планетарной постройки
        public static GameObject CreateBuilding(Transform AParent, Vector3 APosition, BuildingType AType, int ALevel)
        {
            string LPrefabResName = "PL/Building/" + AType.ToString() + "/pfPLBuilding" + AType.ToString() + "Lvl" + ALevel.ToString();

            // И создадим
            return(Create(LPrefabResName, APosition));
        }
Exemple #12
0
 public void InitFacilityDisplay()
 {
     if ((sprite = Resources.Load("Image/galleryThings/buildings/" + type.ToString(), typeof(Sprite)) as Sprite) != null)
     {
         image.sprite = sprite;
     }
 }
Exemple #13
0
        /// <summary>
        /// Methose used to calculate chances we have to get items and schematics(didn't make it)
        /// </summary>
        /// <param name="town"></param>
        /// <returns></returns>
        public bool GetAnItem(Town town)
        {
            int chance = RndPicker.Rnd.Next(0, 100);

            if (chance <= 25)
            {
                int rndItemIndex = RndPicker.Rnd.Next(0, items.Length);
                town.AddItem(items[rndItemIndex]);

                int schematicChance = RndPicker.Rnd.Next(0, 100);

                if (schematicChance <= 5)
                {
                    int buildingLevel = 1;
                    if (dropAbleSchematic == BuildingType.Sanctum)
                    {
                        buildingLevel = town.SanctumLevel + 1;
                    }
                    else if (dropAbleSchematic == BuildingType.ArcheryRange)
                    {
                        buildingLevel = town.ArcheryRangeLevel + 1;
                    }
                    else if (dropAbleSchematic == BuildingType.Barrack)
                    {
                        buildingLevel = town.BarrackLevel + 1;
                    }
                    else if (dropAbleSchematic == BuildingType.Inn)
                    {
                        buildingLevel = town.InnLevel + 1;
                    }

                    string tempSchematic = dropAbleSchematic.ToString() + " schematic level " + buildingLevel.ToString();

                    CheckSchematic(ref tempSchematic, town, ref buildingLevel);


                    town.AddItem(tempSchematic);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #14
0
        public Building(Navnode node, BuildingType type)
        {
            Type       = type;
            texture    = buildingGraphics[Type];
            parentNode = node;

#if DEBUG
            Console.WriteLine("GENERATE " + Type.ToString());
#endif
        }
Exemple #15
0
    void updateTarget()
    {
        var a = Enum.GetValues(typeof(BuildingType));

        Debug.Assert(a.Length > 1);
        do
        {
            nextTarget = (BuildingType)a.GetValue(UnityEngine.Random.Range(0, a.Length));
        } while (nextTarget == previousTarget || !buildings.ContainsKey(nextTarget));
        debugText.text = "Next target: " + nextTarget.ToString();
    }
 public BuildingTypeData GetByType(BuildingType buildingType)
 {
     try
     {
         return(_buildingTypesData[buildingType]);
     }
     catch (Exception)
     {
         throw new BuildingTypeNotSetInPrefabException(buildingType.ToString());
     }
 }
    public OtherData GetBuildingData(BuildingType building)
    {
        // TODO: parser here
        OtherData data = new OtherData();

        string xpath = "/building/" + building.ToString();

        XmlElement node = (XmlElement)xmlDocBuilding.SelectSingleNode(xpath);

        if (node == null)
        {
            Debug.Log("On OtherDescriptionReader GetBuildingData: " + building.ToString() + " not found");
            return(null);
        }

        data.description = node["description"].InnerXml;
        data.effect      = node["effect"].InnerXml;

        return(data);
    }
Exemple #18
0
 private void buildBuilding(BuildingType type)
 {
     try {
         p.AddCommand(new BuildCommand(p, u_target, h_target, type));
     } catch (Exception e) {
         Notify(e.Message, Color.red);
     }
     EventManager.PostBuildEvent(new BuildEventArgs {
         name = type.ToString(), turns = type.BuildTotal() / type.BuildPerTurn()
     });
     state = State.Selected;
 }
Exemple #19
0
        static XmlNode writeBuildingNode(XmlDocument doc, BuildingType type)
        {
            XmlElement building = doc.CreateElement(type.ToString());

            foreach (CostType ctype in Enum.GetValues(typeof(CostType)))
            {
                var elem = costs[(int)ctype][(int)type].GetXmlElement(doc);
                elem.SetAttribute(xmlTypeString, ctype.ToString());
                building.AppendChild(elem);
            }
            building.SetAttribute(xmlRangeString, range[(int)type].ToString());
            return(building);
        }
Exemple #20
0
        public override UpdateData GetSetupData(SubscriberLevel subscriber)
        {
            UpdateData UpdateData = new UpdateData("event");

            if (subscriber == SubscriberLevel.Owner)
            {
                UpdateData["type"]          = "BuildingUpgrade";
                UpdateData["cityID"]        = cityID;
                UpdateData["BuildingType"]  = BuildingType.ToString();
                UpdateData["executesInSec"] = (executionTime - DateTime.Now).TotalSeconds;
            }
            return(UpdateData);
        }
Exemple #21
0
    // Use this for initialization
    void Start()
    {
        qty           = 0;
        qtyText.text  = "Qty: " + qty.ToString();
        costText.text = "$" + cost.ToString();
        descText.text = buildingType.ToString();

        button = transform.GetComponent <Button> ();

        //executes the ButtonClicked function when we click the button
        button.onClick.AddListener(this.ButtonClicked);

        //get a referance to our gamecontroller
        controller = GameObject.FindObjectOfType <GameController>();
    }
        public Building SpawnBuilding(BuildingType buildingType, FoundationType foundationType, SoilType soilType)
        {
            GameObject prefab   = buildingTierData.First(pair => pair.Key.Equals(buildingType)).Value[0].GetPrefab();
            GameObject instance = Instantiate(prefab, CachedTransform.position, CachedTransform.rotation, CachedTransform);

            instance.transform.Translate(buildingSpawnpoint, Space.World);

            instance.name = buildingType.ToString().InsertSpaceBeforeCapitals();

            Building building = instance.GetComponent <Building>();

            building.Initialize(buildingType,
                                GetBuildingData(buildingType, foundationType, soilType), GetFoundationData(foundationType), GetSoilData(soilType));

            return(building);
        }
        public CreateConstructionState(Unit unit, MapPosition mapPosition, BuildingType buildingType, TileDirection direction)
        {
            if (GameController.Instance.CanBeBuild.Contains(buildingType) == false)
            {
                Debug.LogError($"{unit.name} is trying to build {buildingType.ToString()}, but this type of building is not allowed.");
                // FIXME: Unit Behaviour does not handle correctly when state is stopped in constructor.
                StopState();
                return;
            }

            this.unit            = unit;
            tilePosition         = mapPosition;
            this.buildingType    = buildingType;
            this.direction       = direction;
            constructionPosition = Map.Instance.GetTile(tilePosition).transform.position;
        }
Exemple #24
0
    public void Init(BuildingType type, Vector2 position)
    {
        _cost = LevelConfiguration.Instance.GetCost(type);

        var typeName = type.ToString().ToLower();

        _nameText.text = typeName;
        _costText.text = _cost.ToString();

        var rectTransform = GetComponent <RectTransform>();

        rectTransform.anchoredPosition = position;

        _button.onClick.AddListener(() => { SetBuildModePanelCallback(type); });
        _button.onClick.AddListener(BuildPanel.Instance.HidePanel);
        _button.onClick.AddListener(BuildModePanel.Instance.ShowPanel);

        CheckIfCanAfford();
    }
    /// <summary>
    /// Test to see if the building has the required terrain for production.
    /// </summary>
    private void TestTerrain()
    {
        // If we want production speed based on percentage of valid tiles that would be done here.

        // Cycle through all the tiles that make up this building and check to see
        // if any of them are the required terrain type for this mode of production.
        foreach (HexTile hex in BuildingArea)
        {
            foreach (TerrainTypes terra in TerrainRequirement)
            {
                if (hex.TerrainType == terra)
                {
                    hasCorrectTerrain = true;
                }
            }
        }

        if (!hasCorrectTerrain)
        {
            // if the building doesn't have the correct terrain send a warning, with identification for the building.
            Debug.LogWarning("Missing Terrain Requirement: " + BuildingType.ToString() + ", Team: " + TeamID);
        }
    }
Exemple #26
0
    public Treasury Cost(BuildingType type, int lvl = -1)
    {
        if (lvl == -1)
        {
            lvl = buildings[(int)type];
        }
        if (lvl >= maxBuildingLevel)
        {
            return(new Treasury(1000000));
        }
        Treasury cost;

        switch (type)
        {
        case BuildingType.Infrastructure: cost = new Treasury(50, 50, 50, 0, 0); break;

        case BuildingType.Port: cost = new Treasury(50, 100, 20, 20, 0); break;

        case BuildingType.Trade: cost = new Treasury(200, 50, 0, 0, 0); break;

        case BuildingType.Walls: cost = new Treasury(100, 200, 100, 100, 0) * tree.wallsCostReduce; break;

        case BuildingType.Sawmill: cost = new Treasury(100, 100, 20, 20, 0); break;

        case BuildingType.Military: cost = new Treasury(100, 100, 10, 10, 0); break;

        case BuildingType.Pits: cost = new Treasury(100, 100, 20, 20, 0); break;

        case BuildingType.Farms: cost = new Treasury(100, 100, 10, 10, 0); break;

        case BuildingType.University: cost = new Treasury(400, 50, 10, 10, 0); break;

        default: throw new System.Exception("Bad Building type: " + type.ToString()); break;
        }

        return(cost * levelCoef[1 + lvl]);
    }
Exemple #27
0
        public static Rectangle GetSpriteRectangle(BuildingType bt, GameData.Owner owner = GameData.Owner.None)
        {
            StringBuilder result = new StringBuilder();

            switch (owner)
            {
            case GameData.Owner.None:
                break;

            case GameData.Owner.Red:
            case GameData.Owner.Blue:
            case GameData.Owner.Green:
            case GameData.Owner.Yellow:
                result.Append(owner.ToString());
                result.Append("_");
                break;

            default:
                break;
            }
            result.Append(bt.ToString());

            return(BuildingSprite[result.ToString().ToEnum <SpriteSheetBuilding>()]);
        }
Exemple #28
0
        public void SetBuildingType(BuildingType type)
        {
            buildingType = type;
            var building = buildingService.Building(buildingType);

            buildingName.text = StringUtil.Readable(buildingType.ToString());
            levelImg.sprite   = generalAtlas.GetSprite($"level_{building.level}");

            var lvl = 2;

            while (propertyService.Properties($"{buildingType}_BUILDING", lvl).IsEmpty() == false)
            {
                var btn = Instantiate(levelButtonPrefab, levelButtonCanvas);
                btn.buildingLevel = lvl;
                btn.SetLevelIcon(generalAtlas.GetSprite($"level_{lvl}"), lvl <= building.level);
                btn.AddClickListener(() =>
                {
                    SetLevel(btn.buildingLevel);
                });
                levelButtons.Add(btn);
                lvl++;
            }

            var maxLvl = lvl - 1;

            if (building.level == maxLvl)
            {
                SetLevel(maxLvl);
            }
            else
            {
                SetLevel(building.level + 1);
            }

            levelButtonCanvas.localPosition = new Vector3((building.level - 1) * -170f, 0, 0);
        }
        /// <summary>
        /// Construct the building class instance from the given properties.
        /// </summary>
        /// <param name="type" type="BuildingType">type</param>
        /// <param name="plot">The plot of land this building stands on, note it might be bigger than the
        /// actual buildings footprint, for example if it is part of a larger complex, limit the size of
        /// buildings to have a footprint of no more than 100 square meters.</param>
        /// <param name="flags"></param>
        /// <param name="owner">The owner of the building either a user, or company (group of companies) own buildings.</param>
        /// <param name="seed"></param>
        /// <param name="height">The height in floors of the building, not each floor is approximately 3 meters in size
        /// and thus buildings are limited to a maximum height of 100 floors.</param>
        public CityBuilding( BuildingType type, BuildingPlot plot, BuildingFlags flags, 
            UUID owner, IScene scene, string name ):base(owner,new Vector3(plot.xpos,21,plot.ypos),
            Quaternion.Identity, PrimitiveBaseShape.CreateBox(), name, scene)
        {
            //  Start the process of constructing a building given the parameters specified. For
            // truly random buildings change the following value (6) too another number, this is
            // used to allow for the buildings to be fairly fixed during research and development.
            buildingSeed = 6; // TODO FIX ACCESS TO THE CityModule.randomValue(n) code.
            buildingType = type;
            buildingPlot = plot;
            buildingFlags = flags;
            //  Has a valid owner been specified, if not use the default library owner (i think) of the zero uuid.
            if (!owner.Equals(UUID.Zero))
                buildingOwner = owner;
            else
                buildingOwner = UUID.Zero;

            //  Generate a unique value for this building and it's own group if it's part of a complex,
            // otherwise use the zero uuid for group (perhaps it should inherit from the city?)
            buildingUUID = UUID.Random();
            buildingGUID = UUID.Random();

            buildingCenter = new Vector3((plot.xpos + plot.width / 2), 21, (plot.ypos + plot.depth) / 2);
            if (name.Length > 0)
                buildingName = name;
            else
                buildingName = "Building" + type.ToString();
            //  Now that internal variables that are used by other methods have been set construct
            // the building based on the type, plot, flags and seed given in the parameters.
            switch (type)
            {
                case BuildingType.BUILDING_GENERAL:
                    OpenSim.Framework.MainConsole.Instance.Output("Building Type GENERAL", log4net.Core.Level.Info);
                    createBlocky();
                    break;
                case BuildingType.BUILDING_LOCALE:
                    /*
                    switch ( CityModule.randomValue(8) )
                    {
                        case 0:
                            OpenSim.Framework.MainConsole.Instance.Output("Locale general.", log4net.Core.Level.Info);
                            createSimple();
                            break;
                        case 1:
                            OpenSim.Framework.MainConsole.Instance.Output("locale 1", log4net.Core.Level.Info);
                            createBlocky();
                            break;
                    }
                    */
                    break;
                case BuildingType.BUILDING_CIVIL:
                    createTower();
                    break;
                case BuildingType.BUILDING_MILITARY:
                    break;
                case BuildingType.BUILDING_HEALTHCARE:
                    break;
                case BuildingType.BUILDING_SPORTS:
                    break;
                case BuildingType.BUILDING_ENTERTAINMENT:
                    break;
                case BuildingType.BUILDING_EDUCATION:
                    break;
                case BuildingType.BUILDING_RELIGIOUS:
                    break;
                case BuildingType.BUILDING_MUSEUM:
                    break;
                case BuildingType.BUILDING_POWERSTATION:
                    break;
                case BuildingType.BUILDING_MINEOILGAS:
                    break;
                case BuildingType.BUILDING_ZOOLOGICAL:
                    break;
                case BuildingType.BUILDING_CEMETARY:
                    break;
                case BuildingType.BUILDING_PRISON:
                    break;
                case BuildingType.BUILDING_AGRICULTURAL:
                    break;
                case BuildingType.BUILDING_RECREATION:
                    break;
                default:
                    createSimple();
                    break;
            }
        }
Exemple #30
0
	public bool BuildBuilding (BuildingType type, IVec2 Pos, int teamID, bool force)
	{
		bool isBuilding = false;

		if (CanBuild (type, Pos) || force) {
			Building newBuilding = new Building ();
			isBuilding = newBuilding.Build (type, Pos, teamID);
			if (isBuilding || force) {
				IVec2 offset = new IVec2();
				IVec2 size = Building.Sizes[type];
				for (offset.x = -size.x / 2; offset.x < size.x / 2; offset.x++) {
					for (offset.y = -size.y / 2; offset.y < size.y / 2; offset.y++) {
						IVec2 newPos = Pos + offset;
						entities [newPos.x, newPos.y] = newBuilding;
					}
				}

				GameObject obj = Instantiate (BuildingTile, Vector3.zero, Quaternion.Euler (Vector3.zero)) as GameObject;
				obj.renderer.material = Instantiate(GameObject.FindObjectOfType<MaterialSource>().getMaterialByName("Team" + (teamID + 1).ToString())) as Material;
				obj.renderer.material.mainTexture = GameObject.FindObjectOfType<MaterialSource>().getTextureByName(type.ToString());
				obj.transform.SetParent(chunks[Pos.x / 32, Pos.y / 32].transform);
				obj.transform.position = getTileCenterPos (Pos);
				Vector3 oldScale = obj.transform.localScale;
				obj.transform.localScale = new Vector3(size.x * oldScale.x, 1 * oldScale.y, size.y * oldScale.z);
				obj.name = "Building" + Buildings.Count + "(" + type.ToString() + ")";
				newBuilding.gameObject = obj;
				Buildings.Add(newBuilding);
				Players[teamID].Buildings.Add(newBuilding);
			}
		}

		return isBuilding;
	}
Exemple #31
0
 public void SetLocalizedName(BuildingType type, string value)
 {
     Set(nameof(BuildingType), type.ToString(), value);
 }
Exemple #32
0
 public string GetLocalizedName(BuildingType type)
 {
     return(Get(nameof(BuildingType), type.ToString()));
 }
        /// <summary>
        /// Gets power loss coefficient for given frequency and building type.
        /// </summary>
        public static int GetPowerLossCoefficient(BuildingType pType, double pFrequency)
        {
            IEnumerable<XElement> coefficients = XmlParser.GetElements("PowerLossCoefficient", pType.ToString());

            var coeffdesc = coefficients.ToDictionary(
                            k => double.Parse(k.Attribute("UpTo").Value) * GetFrequencyMetricsWithValues()[k.Attribute("Metric").Value],
                            v => int.Parse(v.Attribute("N").Value)).OrderBy(k => k.Key);

            var element = coeffdesc.FirstOrDefault(k => k.Key >= pFrequency);

            if (element.Key == 0 && element.Value == 0) // workaround - means that frequency is higher than any in xml
            {
                return coeffdesc.Last().Value;
            }
            else
            {
                return element.Value;
            }
        }