Esempio n. 1
0
    public virtual bool HandleGoods(GoodsCollection inventory)
    {
        for (int i = 0; i < Workers; i++)
        {
            //check required materials
            foreach (Good good in MaterialsRequired.Keys)
            {
                if (inventory[good] < MaterialsRequired[good])
                {
                    return(false);
                }
            }

            //+- goods
            foreach (Good good in inventory.Keys.ToArray())
            {
                if (MaterialsRequired.ContainsKey(good))
                {
                    inventory[good] -= MaterialsRequired[good];
                }

                if (MaterialsProduced.ContainsKey(good))
                {
                    inventory[good] += MaterialsProduced[good];
                }
            }

            BuildingEffect?.Invoke(inventory);
        }

        return(true);
    }
Esempio n. 2
0
        static Factory()
        {
            effects = new BuildingEffect[4];

            effects[0] = new BuildingEffect("Money +5", new LightSequence("*"), Add5, true);
            effects[1] = new BuildingEffect("Money +20", new LightSequence("***"), Add20, false);
            effects[2] = new BuildingEffect("Clean technology", new LightSequence("GG"), Clean, true);
            effects[3] = new BuildingEffect("Cleaner technology", new LightSequence("GGGG"), Cleaner, true);
        }
Esempio n. 3
0
        private string GetTrapEffectName(SubTag subTag)
        {
            MainTag           mainTag  = MainTag.Trap;
            BuildingEffect    building = GetComponent <BuildingEffect>();
            SkillComponentTag skill    = building.GetEffect(mainTag, subTag);
            int data = building.GetPowerDuration(mainTag, subTag);

            return(GetComponent <ConvertSkillMetaInfo>()
                   .GetBuildingEffectName(skill, data));
        }
Esempio n. 4
0
 public static void TriggerBuildingEffects(Building building, BuildingEffect effect)
 {
     foreach (var card in effect.givenCards)
     {
         Player.instance.Draw(card);
     }
     TriggerBasics(effect.givenResources);
     foreach (var res in effect.givenResources)
     {
         if (res.IsResource("Repair"))
         {
             building.RepairAll();
         }
     }
 }
Esempio n. 5
0
        private void ActiveTrap_EndingTurn(object sender,
                                           StartOrEndTurnEventArgs e)
        {
            if (!GetComponent <LocalManager>().MatchID(e.ObjectID))
            {
                return;
            }

            while (trapTags.Count > 0)
            {
                BuildingEffect building
                    = GameCore.AxeManCore.GetComponent <BuildingEffect>();
                MainTag           mainTag = MainTag.Trap;
                SubTag            subTag  = trapTags.Pop();
                SkillComponentTag skill   = building.GetEffect(mainTag, subTag);
                int data = building.GetPowerDuration(mainTag, subTag);

                GetComponent <ActorStatus>().AddStatus(skill,
                                                       new EffectData(data, data));
                AddLog(subTag);
            }
        }
Esempio n. 6
0
        private string GetAltarEffectName(SubTag subTag)
        {
            MainTag           mainTag  = MainTag.Altar;
            BuildingEffect    building = GetComponent <BuildingEffect>();
            SkillComponentTag skill    = building.GetEffect(mainTag, subTag);
            int data = building.GetPowerDuration(mainTag, subTag);

            switch (subTag)
            {
            case SubTag.FireAltar:
            case SubTag.WaterAltar:
            case SubTag.AirAltar:
            case SubTag.EarthAltar:
                return(GetComponent <ConvertSkillMetaInfo>()
                       .GetBuildingEffectName(skill, data));

            case SubTag.LifeAltar:
                return(data.ToString());

            default:
                return(null);
            }
        }
Esempio n. 7
0
        public override void Initialize(int x, int y)
        {
            base.Initialize(x, y, WIDTH, HEIGHT, GetTexture());

            Name = "Research Center";
            activatedResearch = NO_RESEARCH;

            effects = new BuildingEffect[1];
            effects[0] = new BuildingEffect("Current Task", new LightSequence(), StandardEffect, true);
        }
Esempio n. 8
0
    public void GetCombination(List <int> list)
    {
        //MAKE COMBINATIONS
        List <BuildingEffect> buildingsEffects = new List <BuildingEffect>();

        int            count = (int)Math.Pow(2, list.Count);
        BuildingEffect buildingEffect;

        for (int i = 1; i <= count - 1; i++)
        {
            string str = Convert.ToString(i, 2).PadLeft(list.Count, '0');
            buildingEffect = new BuildingEffect();
            for (int j = 0; j < str.Length; j++)
            {
                if (str[j] == '1')
                {
                    if (list[j] > 4)
                    {
                        buildingEffect.Decreases[(int)propertyMap[list[j]]] = -0.01f;
                    }
                    else
                    {
                        buildingEffect.Increases[(int)propertyMap[list[j]]] = 0.01f;
                    }
                }
            }


            buildingsEffects.Add(buildingEffect);
        }

        //FILTER CONFLICTING BUILDINGS
        List <BuildingEffect> deleteList = new List <BuildingEffect>();

        for (int i = 0; i < buildingsEffects.Count; i++)
        {
            buildingEffect = buildingsEffects[i];
            for (int j = 0; j < buildingEffect.Increases.Count; j++)
            {
                if (buildingEffect.Increases[j] != 0 && buildingEffect.Decreases[j] != 0)
                {
                    deleteList.Add(buildingEffect);
                }
            }
        }
        for (int i = 0; i < deleteList.Count; i++)
        {
            buildingsEffects.Remove(deleteList[i]);
        }

        //SET PRICE
        List <BuildingModel> buildings = new List <BuildingModel>();

        for (int i = 0; i < buildingsEffects.Count; i++)
        {
            buildings.Add(new BuildingModel());

            int price = 0;
            for (int j = 0; j < buildingsEffects[i].Increases.Count; j++)
            {
                if (buildingsEffects[i].Increases[j] != 0)
                {
                    buildings[i].Effects.Add((R)j, buildingsEffects[i].Increases[j]);
                    price += GetPrice(j, true);
                }
                if (buildingsEffects[i].Decreases[j] != 0)
                {
                    buildings[i].Effects.Add((R)j, buildingsEffects[i].Decreases[j]);
                    price += GetPrice(j, false);
                }
            }

            buildings[i].UnlockCost = price;
            buildings[i].BuildCost  = price / 2;
            buildings[i].Effects.Add(R.Minerals, -1 * (price / 100));
            buildings[i].State = BuildingState.LOCKED;
        }

        //SORT BY PRICE
        buildings.Sort(Comparison);
        for (int i = 0; i < buildings.Count; i++)
        {
            buildings[i].Name  = "Building " + i;
            buildings[i].Index = i;
        }


        //SAVE TO FILE
        File.WriteAllText(
            Application.persistentDataPath + "-Buildings.json",
            JsonConvert.SerializeObject(buildings)
            );

        Debug.Log("DONE Generating Buildings");
    }
Esempio n. 9
0
 public BuildingMaker(BuildingEffect buildingE)
 {
     build = buildingE;
             type = buildingE.name;
 }
Esempio n. 10
0
 public BuildingEffect makeBuilding(BuildingEffect building)
 {
     buildings.Add(building);
     return building;
 }