Ejemplo n.º 1
0
 /// <summary>
 /// Change the amount of building count in given category.
 /// </summary>
 /// <param name="category"></param>
 /// <param name="value"></param>
 public static void ChangeCategoryCount(BuildingCategory category, int value)
 {
     if (buildingCounts[category] + value <= 0)
     {
         buildingCounts[category] = 0;
     }
     buildingCounts[category] += value;
 }
Ejemplo n.º 2
0
 public BuildingMap(GameObject model, Type buildingType, BuildingCategory category, string name, uint cost)
 {
     Model        = model;
     BuildingType = buildingType;
     Category     = category;
     Name         = name;
     Cost         = cost;
 }
Ejemplo n.º 3
0
 private void AddBuff(BuildingCategory category, PropsBuffConfigData data)
 {
     if (!this.m_CategoryBuffs.ContainsKey(category))
     {
         this.m_CategoryBuffs.Add(category, new List <PropsBuffConfigData>());
     }
     this.m_CategoryBuffs[category].Add(data);
 }
Ejemplo n.º 4
0
        public async Task <BuildingCategory> AddBuildingType(BuildingCategory buildingType)
        {
            var bldgTypeToAdd = _mapper.Map <BuildingCategory>(buildingType);

            await _buildingCategoryRepo.Insert(bldgTypeToAdd);

            await _buildingCategoryRepo.SaveAsync();

            return(bldgTypeToAdd);
        }
Ejemplo n.º 5
0
    void GetBuildings(BuildingCategory category)
    {
        Buildings = BuildingLibrary.GetBuildingsForCategory(category);

        max = (int)Math.Ceiling(Buildings.Count / 6f);



        GenerateBuildingButtons();
    }
Ejemplo n.º 6
0
        private static Vector3 GetPositionForElement(BuildingCategory category, int index)
        {
            Vector3 categoryPos = category.transform.localPosition;

            float angle = category.Offset + category.Spacing * index;

            //(Quaternion.Euler(Vector3.back * angle) * Vector3.up) * wheel.Distance

            return(Quaternion.Euler(Vector3.back * angle) * (categoryPos + categoryPos.normalized * category.Distance));
        }
        void openCategoryTab(BuildingCategory category)
        {
            for (int i = 0; i < categoryButtons.Length; i++)
            {
                categoryButtons[i].SetActive(i == (int)category);
            }

            currentIcons = buildingIcons[category];

            currentCategory = category;
        }
Ejemplo n.º 8
0
    public List <Transform> GetBuildingsTransformOfCategory(BuildingCategory buildingCategory)
    {
        List <Transform>  result    = new List <Transform>();
        List <GameObject> buildings = this.GetBuildingsOfCategory(buildingCategory);

        foreach (GameObject building in buildings)
        {
            result.Add(this.m_CachedTransformDict[building]);
        }
        return(result);
    }
Ejemplo n.º 9
0
    public List <BuildingBuff> GetBuffs(BuildingCategory category)
    {
        List <BuildingBuff> result = new List <BuildingBuff>();

        if (this.m_CategoryBuffs.ContainsKey(category))
        {
            foreach (PropsBuffConfigData buffData in this.m_CategoryBuffs[category])
            {
                result.Add(this.ConstructBuff(buffData));
            }
        }
        return(result);
    }
Ejemplo n.º 10
0
        public void InitializePanels(int category)
        {
            buildButton.onClick.RemoveAllListeners();

            selectedID       = -1;
            selectedCategory = (BuildingCategory)category;

            List <BlueprintIdPair> buildingBlueprints = new List <BlueprintIdPair>();

            for (int i = 0; i < unlockedBuildings.Count; i++)
            {
                if (registry.BuildingRegistry[unlockedBuildings[i]].type == selectedCategory)
                {
                    buildingBlueprints.Add(new BlueprintIdPair(unlockedBuildings[i], registry.BuildingRegistry[unlockedBuildings[i]]));
                }
            }

            if (buildingBlueprints.Count == 0)
            {
                return;
            }

            for (int i = 0; i < 3; i++)
            {
                BlueprintIdPair[] tieredBlueprints = buildingBlueprints.Where(b => b.blueprint.tier == i + 1).ToArray();
                RectTransform     parentPanel      = panels[i];

                List <BuildingButtonTemplate> buttonTemplates = new List <BuildingButtonTemplate>();
                buttonTemplates.AddRange(parentPanel.GetComponentsInChildren <BuildingButtonTemplate>());

                int lengthDifference = tieredBlueprints.Length - buttonTemplates.Count;

                for (int diff = lengthDifference; diff < 0; diff++)
                {
                    buttonTemplates[tieredBlueprints.Length - (diff + 1)].gameObject.SetActive(false);
                }

                for (int h = 0; h < lengthDifference; h++)
                {
                    BuildingButtonTemplate newTemplate = Instantiate(template, parentPanel);
                    buttonTemplates.Add(newTemplate);
                }

                for (int j = 0; j < buttonTemplates.Count; j++)
                {
                    buttonTemplates[i].Initialize(this, tieredBlueprints[i].blueprint, tieredBlueprints[i].id);
                }

                SelectBuildingToBuild(-1);
            }
        }
Ejemplo n.º 11
0
    private void ConstructCharacter(GameObject characterPrefab, Vector3 position, BuildingCategory favoriteCategory,
                                    int hp, int armorCategory, float moveVelocity, TargetType type, float attackCD, int attackValue, float attackScope,
                                    int damageScope, float middleSpeed, int attackCategory, TargetType targetType, float pushFactor, float pushAttenuateFactor)
    {
        GameObject army = GameObject.Instantiate(characterPrefab) as GameObject;

        army.transform.position = position;
        army.transform.parent   = this.m_ParentNode;

        CharacterAI ai = army.GetComponent <CharacterAI>();

        ai.BattleMapData       = BattleMapData.Instance;
        ai.BattleSceneHelper   = this.m_SceneHelper;
        ai.FavoriteCategory    = favoriteCategory;
        ai.PushFactor          = pushFactor;
        ai.PushAttenuateFactor = pushAttenuateFactor;

        ai.SetIdle(true);

        CharacterHPBehavior hpBehavior = army.GetComponent <CharacterHPBehavior>();

        hpBehavior.TotalHP       = hp;
        hpBehavior.ArmorCategory = armorCategory;
        if (hpBehavior is KodoHPBehavior)
        {
            KodoHPBehavior kodoHP = hpBehavior as KodoHPBehavior;
            kodoHP.Factory = this;
        }

        CharacterPropertyBehavior property = army.GetComponent <CharacterPropertyBehavior>();

        property.CharacterType = CharacterType.Invader;
        property.MoveVelocity  = moveVelocity;
        property.Type          = type;

        AttackBehavior attackBehavior = army.GetComponent <AttackBehavior>();

        attackBehavior.BulletParent   = this.m_BulletParent;
        attackBehavior.AttackCD       = Mathf.FloorToInt(attackCD * ClientConfigConstants.Instance.TicksPerSecond);
        attackBehavior.AttackValue    = attackValue;
        attackBehavior.AttackScope    = attackScope;
        attackBehavior.DamageScope    = damageScope;
        attackBehavior.BulletFlySpeed = middleSpeed;
        attackBehavior.AttackCategory = attackCategory;
        attackBehavior.TargetType     = targetType;
        BattleSceneHelper.Instance.ConstructActor
            (army, PositionConvertor.GetActorTileIndexFromWorldPosition(army.transform.position));
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Apply interest rate to given category after build.
    /// </summary>
    /// <param name="category"></param>
    private void ApplyInterestToBuildingCategory(BuildingCategory category)
    {
        List <Building> markForChange = new List <Building>();

        foreach (var item in SessionManager.availableBuildings)
        {
            if ((BuildingCategory)item.Key.data.category == category)
            {
                markForChange.Add(item.Key);
            }
        }

        foreach (var building in markForChange)
        {
            SessionManager.instance.ChangeBuildCost(building, CalculateBuildingCostWithInterest(building));
        }
    }
Ejemplo n.º 13
0
        public static void ApplyForCategory(BuildingCategory category)
        {
            Vector3 categoryPos = category.transform.localPosition;
            var     wheel       = category.GetComponentInParent <BuildingWheel>();

            if (!wheel)
            {
                return;
            }

            var pieces = category.transform.GetComponentsInChildren <BuildingPiece>();

            for (int i = 0; i < pieces.Length; i++)
            {
                pieces[i].transform.position = wheel.transform.TransformPoint(GetPositionForElement(category, i)) + (Vector3)pieces[i].DesiredOffset;
            }
        }
Ejemplo n.º 14
0
 public BuildingType(int id, string name, GameObject prefab, BuildingCategory buildingCategory, float energyConsumption, List <ResourcesManager.ResourceAmount> cost, BuildingLocationType buildingLocationType, string imageName, int maxTier, int unlockedAtLevelNb, string description, List <ResourcesManager.UpgradeCost> upgradeCosts, List <SpecializedUpgrade> specializedUpgrades, bool hasRange, bool producesEnergy, List <Building.BuildingStat> specificStats, bool isUnique)
 {
     this.id                   = id;
     this.name                 = name;
     this.prefab               = prefab;
     this.energyConsumption    = energyConsumption;
     this.resourceCosts        = cost;
     this.buildingLocationType = buildingLocationType;
     this.buildingImage        = Resources.Load <Sprite>("Images/Buildings/" + imageName);   // Place the building image with the correct name in this folder
     this.maxTier              = maxTier;
     this.isUnlocked           = (unlockedAtLevelNb == 0) ? true : false;
     this.unlockedAtLevelNb    = unlockedAtLevelNb;
     this.description          = description;
     this.upgradeCosts         = upgradeCosts;
     this.specializedUpgrades  = specializedUpgrades;
     this.hasRange             = hasRange;
     this.producesEnergy       = producesEnergy;
     this.specificStats        = specificStats;
     this.isUnique             = isUnique;
     this.buildingCategory     = buildingCategory;
 }
Ejemplo n.º 15
0
    public static List <BuildingMap> GetBuildingsForCategory(BuildingCategory category)
    {
        if (category == BuildingCategory.All)
        {
            return(Buildings);
        }
        else
        {
            List <BuildingMap> map = new List <BuildingMap>(); //this will get the time period list

            foreach (BuildingMap buildingMap in Buildings)
            {
                if (buildingMap.Category == category)
                {
                    map.Add(buildingMap);
                }
            }

            return(map);
        }
    }
Ejemplo n.º 16
0
    public void InitialBuff(List <BattleBuffParameter> buffs)
    {
        foreach (BattleBuffParameter buff in buffs)
        {
            PropsBuffConfigData configData = ConfigInterface.Instance.PropsConfigHelper.GetPropsData(buff.RelatedPropsType).
                                             FunctionConfigData as PropsBuffConfigData;
            this.m_Buffs.Add(configData);

            BuildingCategory relatedCategory = (BuildingCategory)configData.RelatedBuildingCategory;

            if (relatedCategory == BuildingCategory.Any)
            {
                this.AddBuff(BuildingCategory.None, configData);
                this.AddBuff(BuildingCategory.Resource, configData);
                this.AddBuff(BuildingCategory.Defense, configData);
            }
            else
            {
                this.AddBuff(relatedCategory, configData);
            }
        }
    }
Ejemplo n.º 17
0
 public GameObject GetNearestBuildingOfCategory(Vector3 characterPosition, BuildingCategory buildingCategory)
 {
     if (buildingCategory == BuildingCategory.Any || !this.m_BuildingsCategoryDict.ContainsKey(buildingCategory))
     {
         return(this.GetNearestBuildingExcludeType(characterPosition, BuildingType.Wall));
     }
     else
     {
         float      nearestDistanceSqr = 100000000;
         GameObject result             = null;
         foreach (GameObject building in this.m_BuildingsCategoryDict[buildingCategory])
         {
             Vector3 buildingPosition = this.m_CachedTransformDict[building].position;
             float   distanceSqr      = Vector2.SqrMagnitude(buildingPosition - characterPosition);
             if (distanceSqr < nearestDistanceSqr)
             {
                 nearestDistanceSqr = distanceSqr;
                 result             = building;
             }
         }
         return(result);
     }
 }
Ejemplo n.º 18
0
    public List <GameObject> GetBuildingsOfCategory(BuildingCategory buildingCategory)
    {
        List <GameObject> result = new List <GameObject>();

        if (buildingCategory == BuildingCategory.Any)
        {
            foreach (KeyValuePair <BuildingType, List <GameObject> > item in this.m_Buildings)
            {
                if (item.Key != BuildingType.Wall)
                {
                    result.AddRange(item.Value);
                }
            }
        }
        else
        {
            if (this.m_BuildingsCategoryDict.ContainsKey(buildingCategory))
            {
                result.AddRange(this.m_BuildingsCategoryDict[buildingCategory]);
            }
        }
        return(result);
    }
Ejemplo n.º 19
0
        public async Task <IActionResult> AddBuildingType([FromBody] BuildingCategory buildingType)
        {
            await _buildingService.AddBuildingType(buildingType);

            return(Ok());
        }