Ejemplo n.º 1
0
        public async Task CreateBuildingTest(string name, bool status)
        {
            BuildingPrototype buildingPrototype = new BuildingPrototype(name);
            bool result = await apiController.createBuilding(buildingPrototype) > 0;

            Assert.AreEqual(status, result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Asynchronicznie tworzy i dodaje do bazy nowy budynek z podanego opisu
        /// </summary>
        /// <param name="building">Opis budynku</param>
        /// <returns>Identyfikator liczbowy nowo dodanego budynku lub -1 jeśli nie udało się dodać budynku do bazy danych</returns>
        public async Task <int> createBuilding(BuildingPrototype building)
        {
            var    uri     = "/addNewBuilding";
            string data    = ConvertDataToJSON(building);
            var    content = PreperDataToSend(data);

            return(await SendRequest(uri, content));
        }
Ejemplo n.º 3
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        BuildingPrototype prototype = GameManager.Instance.World.GetBuildingPrototype(PrototypeName);

        if (prototype != null)
        {
            GameManager.Instance.Tooltip.SetText(
                GameManager.Instance.GetText(prototype.DescriptionKey), 0.1f);
        }
    }
Ejemplo n.º 4
0
    public static GameObject CreateHologram(HologramData data)
    {
        GameObject hologram = Instantiate(new GameObject("Hologram"));

        Hologram          hologramComponent          = hologram.AddComponent <Hologram>();
        BuildingPrototype buildingPrototypeComponent = hologram.AddComponent <BuildingPrototype>();
        SpriteRenderer    spriteRenderer             = hologram.AddComponent <SpriteRenderer>();

        spriteRenderer.sortingLayerName = "Buildings";
        spriteRenderer.sortingOrder     = 100;
        spriteRenderer.sprite           = data.hologramSprite;
        spriteRenderer.color            = data.canBuildColor;

        hologramComponent.spriteRenderer = spriteRenderer;
        hologramComponent.hologramData   = data;

        return(hologram);
    }
    public ConstructionSite(Building building, BuildingPrototype buildingPrototype, bool deconstruction)
    {
        Building  = building;
        Prototype = buildingPrototype;
        world     = GameManager.Instance.World;

        constructionTime = Prototype.ConstructionTime;

        Halted = false;

        if (deconstruction)
        {
            CanAbort      = false;
            Stage         = ConstructionStage.Deconstruction;
            stageTimeLeft = constructionTime;
        }
        else
        {
            CanAbort = true;

            if (Prototype.ConstructionWithoutScaffolding)
            {
                Stage = ConstructionStage.Construction;
                LoadRequiredResourcesForConstruction();
                stageTimeLeft = constructionTime;
            }
            else
            {
                Stage = ConstructionStage.ScaffoldingConstruction;
                LoadRequiredResourcesForScaffoldingConstruction();
                stageTimeLeft = StaticData.ScaffoldingConstructionTime;
            }
        }

        if (ConstructionStorage == null)
        {
            ConstructionStorage = new StorageWithRequirements(Building, null);
        }
        if (DeconstructionStorage == null)
        {
            DeconstructionStorage = new Storage(Building, null, true);
        }
    }
Ejemplo n.º 6
0
    public Building(BuildingPrototype buildingPrototype, Rotation buildingRotation,
                    List <Tile> tiles, Tile accessTile, Tile secondAccessTile)
    {
        Prototype = buildingPrototype;

        Rotation = buildingRotation;
        Tiles    = tiles;

        if (Prototype.HasAccessTile)
        {
            this.accessTile    = accessTile;
            accessTileRotation = Prototype.NormalizedAccessTileRotation.Rotate(buildingRotation);
        }

        if (Prototype.HasSecondAccessTile && secondAccessTile != null)
        {
            this.secondAccessTile    = secondAccessTile;
            secondAccessTileRotation = Prototype.NormalizedSecondAccessTileRotation.Rotate(buildingRotation);
        }
    }
Ejemplo n.º 7
0
    public void SetBuildingType(string type)
    {
        currentPrototype = world.GetBuildingPrototype(type);

        if (currentPrototype == null)
        {
            return;
        }

        currentRotation = currentPrototype.StartingRotation;

        if (currentPrototype.MultipleBuildMode)
        {
            BuildMode = BuildMode.Multiple;
        }
        else
        {
            BuildMode = BuildMode.Single;
        }

        InputManager.SetBuildMode(true);
    }
Ejemplo n.º 8
0
        public Building(Neuron parentNeuron, BuildingPrototype prototype, Planet planet, HexTileCoord coord,
                        IReadOnlyList <Modifier> modifiers = null)
        {
            _neuron = parentNeuron.LinkNewChildNeuron();

            Name     = prototype.Name;
            HexCoord = coord;

            _planet = planet;

            YieldFromBuilding  = prototype.BuildingYield;
            UpkeepFromBuilding = prototype.BuildingUpkeep;

            var resourceData = GameDataStorage.Instance.GetGameData <GameFactorResourceData>();
            var slotData     = GameDataStorage.Instance.GetGameData <PopSlotData>();

            // Initialize yield kind
            var yieldKind = new HashSet <string>();

            foreach (var kv in prototype.BasePopSlots)
            {
                foreach (var k in slotData[kv.Key].YieldFactorKind.Where(x => resourceData.AllResourceSet.Contains(x)))
                {
                    yieldKind.Add(k);
                }
            }

            YieldResourceKind = yieldKind;

            // Initialize modifiers
            if (modifiers != null)
            {
                foreach (var m in modifiers)
                {
                    if (!m.ModifierInfo.GameFactorAmount.Keys.Any(x =>
                                                                  x == "Happiness" && m.ModifierInfo.TopHolder == ModifierHolderKind.Building ||
                                                                  x == "AnyResource" || yieldKind.Contains(x)))
                    {
                        continue;
                    }
                    _modifiers.Add(m);
                    ApplyModifierChange(m, true);
                }
            }

            // Initialize slots
            foreach (var kv in prototype.BasePopSlots)
            {
                var p = slotData[kv.Key];

                var slot = new PopSlot(_neuron, this, p);
                for (var i = 0; i < kv.Value; i++)
                {
                    _popSlots.Add(slot);
                }
            }

            // Initialize adjacency bonus
            var adj = prototype.AdjacencyBonus;

            AdjacencyBonusMaxLevel = adj.MaxLevel;
            AdjacencyBonusPerLevel = adj.BonusPerLevel;
            AdjacencyBonusDict     = adj.BonusChangeInfo;

            _neuron.Subscribe <BuildingConstructedSignal>(OnBuildingConstructedSignal);
            _neuron.Subscribe <GameCommandSignal>(OnGameCommandSignal);
        }
Ejemplo n.º 9
0
    public static List <BuildingPrototype> LoadPrototypes()
    {
        List <BuildingPrototype> prototypes = new List <BuildingPrototype>(24);
        BuildingPrototype        bp;

        // -----------------------------------
        // SPACESHIP
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Spaceship";
        bp.DescriptionKey = "SpaceshipDesc";

        bp.CanBeBuiltOnRock = true;

        bp.NormalizedTilePositions = new List <TilePosition>()
        {
            new TilePosition(0, 0, 0), new TilePosition(2, 0, 0),
            new TilePosition(0, 1, 0), new TilePosition(1, 1, 0), new TilePosition(2, 1, 0),
            new TilePosition(0, 2, 0), new TilePosition(1, 2, 0), new TilePosition(2, 2, 0),
            new TilePosition(0, 3, 0), new TilePosition(1, 3, 0), new TilePosition(2, 3, 0),
            new TilePosition(0, 4, 0), new TilePosition(1, 4, 0), new TilePosition(2, 4, 0),
        };

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(1, 0, 0);
        bp.NormalizedAccessTileRotation = Rotation.N;

        bp.MaxStorage     = 24;
        bp.InitialStorage = new Dictionary <int, int>()
        {
            { 1, 12 },
            { 5, 6 },
            { 6, 6 }
        };

        bp.CanBeDeconstructed = false;

        prototypes.Add(bp);


        // -----------------------------------
        // ORE DEPOSIT
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "OreDeposit";
        bp.DescriptionKey = "OreDepositDesc";

        bp.CanBeBuiltOnRock = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 1);

        bp.ConstructionWithoutScaffolding = true;

        bp.IsNaturalDeposit = true;

        bp.ProductionTime    = 4f;
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 3, 1 }
        };
        bp.ProductionCyclesLimitMin = MinOreAmountInDeposit;
        bp.ProductionCyclesLimitMax = MaxOreAmountInDeposit;

        bp.NeedGrowthPerSecond = new Dictionary <string, float>()
        {
            { "Health", 0.02f },
            { "Condition", 0.01f }
        };

        prototypes.Add(bp);


        // -----------------------------------
        // CRYSTALS DEPOSIT
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "CrystalsDeposit";
        bp.DescriptionKey = "CrystalsDepositDesc";

        bp.CanBeBuiltOnSand = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 1);

        bp.ConstructionWithoutScaffolding = true;

        bp.IsNaturalDeposit = true;

        bp.ProductionTime    = 4f;
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 0, 1 }
        };
        bp.ProductionCyclesLimitMin = MinCrystalsAmountInDeposit;
        bp.ProductionCyclesLimitMax = MaxCrystalsAmountInDeposit;

        bp.NeedGrowthPerSecond = new Dictionary <string, float>()
        {
            { "Health", 0.02f },
            { "Condition", 0.01f }
        };

        prototypes.Add(bp);


        // -----------------------------------
        // STAIRS
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Stairs";
        bp.DescriptionKey = "StairsDesc";

        bp.CanBeBuiltOnSand = true;

        bp.NormalizedTilePositions = new List <TilePosition>()
        {
            new TilePosition(1, 0, 0), new TilePosition(2, 0, 0)
        };

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition       = new TilePosition(0, 0, 1);
        bp.NormalizedAccessTileRotation       = Rotation.E;
        bp.HasSecondAccessTile                = true;
        bp.NormalizedSecondAccessTilePosition = new TilePosition(3, 0, 0);
        bp.NormalizedSecondAccessTileRotation = Rotation.W;

        bp.ConstructionTime      = 1f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 1 }
        };
        bp.ConstructionWithoutScaffolding = true;

        bp.MousePivotPoint = new TilePosition(1, 0, 0);

        prototypes.Add(bp);


        // -----------------------------------
        // PLATFORM
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Platform";
        bp.DescriptionKey = "PlatformDesc";

        bp.CanBeBuiltOnSand = true;

        bp.MultipleBuildMode = true;

        bp.AllowRotation = false;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 1);

        bp.MovementCost             = 0.75f;
        bp.WalkableOnTop            = true;
        bp.CanBeAccessedFromTop     = true;
        bp.DisallowDiagonalMovement = true;
        bp.MovementCostOnTop        = 2f;

        bp.ConstructionTime      = 0.5f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 1 }
        };
        bp.ConstructionWithoutScaffolding = true;

        bp.CanBeDeconstructed = false;

        prototypes.Add(bp);


        // -----------------------------------
        // SLAB
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Slab";
        bp.DescriptionKey = "SlabDesc";

        bp.CanBeBuiltOnSand     = true;
        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.MultipleBuildMode = true;

        bp.AllowRotation = false;

        bp.MovementCost      = 0.5f;
        bp.AllowToBuildOnTop = true;
        bp.HasAccessTile     = false;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 1);

        bp.ConstructionTime      = 0.5f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 1 }
        };
        bp.ConstructionWithoutScaffolding = true;

        prototypes.Add(bp);


        // -----------------------------------
        // GREENHOUSE
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Greenhouse";
        bp.DescriptionKey = "GreenhouseDesc";

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 2);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(0, -1, 0);
        bp.NormalizedAccessTileRotation = Rotation.N;

        bp.ProductionTime    = 4f;
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 4, 3 }
        };

        bp.ConstructionTime      = 6f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 2 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 2 }
        };

        bp.HidesCharacter = true;

        prototypes.Add(bp);


        // -----------------------------------
        // STORAGE
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Storage";
        bp.DescriptionKey = "StorageDesc";

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 1);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(0, -1, 0);
        bp.NormalizedAccessTileRotation = Rotation.N;

        bp.ConstructionTime      = 6f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 2 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 2 }
        };

        bp.MaxStorage = 18;

        prototypes.Add(bp);


        // -----------------------------------
        // HEALING CHAMBER
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "HealingChamber";
        bp.DescriptionKey = "HealingChamberDesc";

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(2, 2);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition       = new TilePosition(0, 2, 0);
        bp.NormalizedAccessTileRotation       = Rotation.S;
        bp.HasSecondAccessTile                = true;
        bp.NormalizedSecondAccessTilePosition = new TilePosition(1, 2, 0);
        bp.NormalizedSecondAccessTileRotation = Rotation.S;

        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 5, 1 }
        };
        bp.NeedFulfilled            = "Health";
        bp.ServiceDuration          = 6f;
        bp.NeedFulfillmentPerSecond = 1f / bp.ServiceDuration;

        bp.ConstructionTime      = 6f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 3 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 3 }
        };

        bp.MousePivotPoint  = new TilePosition(1, 1, 0);
        bp.StartingRotation = Rotation.S;

        bp.HidesCharacter = true;

        prototypes.Add(bp);


        // -----------------------------------
        // QUARTERS
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Quarters";
        bp.DescriptionKey = "QuartersDesc";

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(3, 3);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(1, -1, 0);
        bp.NormalizedAccessTileRotation = Rotation.N;

        bp.ConstructionTime      = 10f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 3 }, { 2, 1 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 3 }
        };

        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 6, 1 }
        };
        bp.NeedFulfilled            = "Hunger";
        bp.ServiceDuration          = 5f;
        bp.NeedFulfillmentPerSecond = 1f / bp.ServiceDuration;

        bp.HidesCharacter = true;

        prototypes.Add(bp);


        // -----------------------------------
        // METALWORKS
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Metalworks";
        bp.DescriptionKey = "MetalworksDesc";

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 2);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(0, 2, 0);
        bp.NormalizedAccessTileRotation = Rotation.S;

        bp.StartingRotation = Rotation.N;

        bp.ConstructionTime      = 4f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 2 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 2 }
        };

        bp.ProductionTime    = 4f;
        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 3, 1 }
        };
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 1, 4 }
        };

        bp.NeedGrowthPerSecond = new Dictionary <string, float>()
        {
            { "Health", 0.01f },
            { "Condition", 0.01f }
        };

        prototypes.Add(bp);


        // -----------------------------------
        // REFINERY
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Refinery";
        bp.DescriptionKey = "RefineryDesc";

        bp.CanBeBuiltOnSand = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(2, 2);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(2, 1, 0);
        bp.NormalizedAccessTileRotation = Rotation.W;

        bp.StartingRotation = Rotation.E;

        bp.ConstructionTime      = 8f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 3 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 3 }
        };

        bp.ProductionTime    = 6f;
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 2, 4 }
        };

        bp.NeedGrowthPerSecond = new Dictionary <string, float>()
        {
            { "Health", 0.01f },
            { "Condition", 0.005f }
        };

        prototypes.Add(bp);


        // -----------------------------------
        // LABORATORY
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "Laboratory";
        bp.DescriptionKey = "LaboratoryDesc";

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(2, 2);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(1, 2, 0);
        bp.NormalizedAccessTileRotation = Rotation.S;

        bp.StartingRotation = Rotation.S;

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.ConstructionTime      = 6f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 2 }, { 2, 1 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 2 }
        };

        bp.ProductionTime    = 4f;
        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 2, 1 }, { 4, 1 }
        };
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 5, 2 }
        };

        bp.NeedGrowthPerSecond = new Dictionary <string, float>()
        {
            { "Health", 0.01f },
            { "Condition", 0.005f }
        };

        prototypes.Add(bp);


        // -----------------------------------
        // FOOD SYNTHESIZER
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "FoodSynthesizer";
        bp.DescriptionKey = "FoodSynthesizerDesc";

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 2);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(0, -1, 0);
        bp.NormalizedAccessTileRotation = Rotation.N;

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.ConstructionTime      = 5f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 2 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 2 }
        };

        bp.ProductionTime    = 3f;
        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 4, 2 }
        };
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 6, 2 }
        };

        prototypes.Add(bp);


        // -----------------------------------
        // ROBOT FACTORY
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "RobotFactory";
        bp.DescriptionKey = "RobotFactoryDesc";

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(3, 3);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition       = new TilePosition(1, 3, 0);
        bp.NormalizedAccessTileRotation       = Rotation.S;
        bp.HasSecondAccessTile                = true;
        bp.NormalizedSecondAccessTilePosition = new TilePosition(1, -1, 0);
        bp.NormalizedSecondAccessTileRotation = Rotation.S;

        bp.StartingRotation = Rotation.W;

        bp.ConstructionTime      = 10f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 4 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 4 }
        };

        bp.ProductionTime    = 7f;
        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 1, 1 }, { 7, 2 }
        };
        bp.ProducesRobot = true;

        prototypes.Add(bp);


        // -----------------------------------
        // PARTS FACTORY
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "PartsFactory";
        bp.DescriptionKey = "PartsFactoryDesc";

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(2, 4);

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(-1, 0, 0);
        bp.NormalizedAccessTileRotation = Rotation.E;

        bp.ConstructionTime      = 10f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 3 }, { 2, 2 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 3 }
        };

        bp.ProductionTime    = 4f;
        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 1, 1 }, { 2, 1 }
        };
        bp.ProducedResources = new Dictionary <int, int>()
        {
            { 7, 2 }
        };

        prototypes.Add(bp);


        // -----------------------------------
        // REPAIR STATION
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "RepairStation";
        bp.DescriptionKey = "RepairStationDesc";

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 2);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(0, -1, 0);
        bp.NormalizedAccessTileRotation = Rotation.N;

        bp.StartingRotation = Rotation.E;

        bp.ConstructionTime      = 5f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 2 }, { 7, 1 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 2 }
        };

        bp.ConsumedResources = new Dictionary <int, int>()
        {
            { 7, 1 }
        };
        bp.NeedFulfilled            = "Condition";
        bp.ServiceDuration          = 4f;
        bp.NeedFulfillmentPerSecond = 1f / bp.ServiceDuration;

        bp.HidesCharacter = true;

        prototypes.Add(bp);


        // -----------------------------------
        // CRYSTAL STORAGE
        // -----------------------------------

        bp                = new BuildingPrototype();
        bp.Type           = "CrystalStorage";
        bp.DescriptionKey = "CrystalStorageDesc";

        bp.NormalizedTilePositions = BuildingPrototype.GetNormalizedTilePositions(1, 1);

        bp.HasAccessTile = true;
        bp.NormalizedAccessTilePosition = new TilePosition(0, -1, 0);
        bp.NormalizedAccessTileRotation = Rotation.N;

        bp.CanBeBuiltOnRock     = true;
        bp.CanBeBuiltOnPlatform = true;

        bp.ConstructionTime      = 5f;
        bp.ConstructionResources = new Dictionary <int, int>()
        {
            { 1, 2 }, { 7, 1 }
        };
        bp.ResourcesFromDeconstruction = new Dictionary <int, int>()
        {
            { 1, 2 }
        };

        bp.MaxStorage          = 12;
        bp.RestrictedResources = new List <int>()
        {
            1, 2, 3, 4, 5, 6, 7, 8
        };

        prototypes.Add(bp);

        return(prototypes);
    }
Ejemplo n.º 10
0
 public BuildingQueueElement(BuildingPrototype prototype, HexTileCoord coord, bool isUpgrading = false)
 {
     Prototype   = prototype;
     Coord       = coord;
     IsUpgrading = isUpgrading;
 }
Ejemplo n.º 11
0
    public void ShowPreview(TilePosition position, Rotation rotation, BuildingPrototype prototype)
    {
        bool isPositionValid = World.IsValidBuildingPosition(position, rotation, prototype);

        GameObject model = null;
        for (int i = 0; i < buildingDisplay.Length; i++)
        {
            if (buildingDisplay[i] != null && buildingDisplay[i].Type == prototype.Type)
            {
                if (isPositionValid)
                {
                    model = buildingDisplay[i].PreviewModel;
                }
                else
                {
                    model = buildingDisplay[i].InvalidPreviewModel;
                }
                break;
            }
        }
        if (model == null)
        {
            model = DebugBuildingPreviewPrefab;
        }

        GameObject preview = SimplePool.Spawn(
            model,
            new Vector3(position.X, position.Height * LevelHeightOffset, position.Y),
            Quaternion.identity);

        if (isPositionValid && prototype.HasAccessTile)
        {
            TilePosition arrowPosition = prototype.NormalizedAccessTilePosition;

            accessArrow = SimplePool.Spawn(
                AccessArrowPrefab,
                new Vector3(position.X + arrowPosition.X,
                            (position.Height + arrowPosition.Height) * LevelHeightOffset,
                            position.Y + arrowPosition.Y),
                Quaternion.identity);

            RotateGameObject(accessArrow, prototype.NormalizedAccessTileRotation);

            accessArrow.transform.SetParent(preview.transform);
        }

        if (isPositionValid && prototype.HasSecondAccessTile)
        {
            TilePosition arrowPosition = prototype.NormalizedSecondAccessTilePosition;

            secondAccessArrow = SimplePool.Spawn(
                AccessArrowPrefab,
                new Vector3(position.X + arrowPosition.X,
                            (position.Height + arrowPosition.Height) * LevelHeightOffset,
                            position.Y + arrowPosition.Y),
                Quaternion.identity);

            RotateGameObject(secondAccessArrow, prototype.NormalizedSecondAccessTileRotation);

            secondAccessArrow.transform.SetParent(preview.transform);
        }

        RotateGameObject(preview, rotation);

        preview.transform.SetParent(PreviewsParent.transform);
        previewObjects.Add(preview);
    }
Ejemplo n.º 12
0
 public Blueprint(string nameText, BuildingPrototype prototype, Bundle cost)
 {
     Cost      = cost;
     Prototype = prototype;
     NameText  = nameText;
 }