Exemple #1
0
 private void SetOtherSprite(Tile tile)
 {
     // Check Tile Is Null
     if (tile != null)
     {
         // Grab the building on that tile and check if null
         Building other = tile.GetInfrastructureItem();
         if (other != null)
         {
             // Check if that building has a dnyamic sprite renderer
             IBuildingDynamicTexture otherDynamicRenderer = other.GetPrimitiveObject() as IBuildingDynamicTexture;
             if (otherDynamicRenderer != null)
             {
                 // Check if ame categories and then update the building's sprite at that location.
                 if (other.GetPrimitiveObject().GetBuildingCategory() == building.GetPrimitiveObject().GetBuildingCategory())
                 {
                     // Now attempt to get that building's renderer
                     BuildingDynamicTextureRenderer otherRenderer = other.components["renderer"] as BuildingDynamicTextureRenderer;
                     if (otherRenderer != null)
                     {
                         int    amount = tile.SimilarConstructedItemsAroundTile(this.building);
                         Sprite sprite = otherRenderer.GetSpriteAt(tile.GetTileNumber(), true);
                         if (sprite != null)
                         {
                             sprite.setSubtexture(WorkOutSprite(amount, tile));
                         }
                     }
                 }
             }
         }
     }
 }
        public void SetPrimitiveBuilding(PrimitiveBuilding building)
        {
            this.primitiveData = building;

            // Check to see if the primitive building reqires Beforebuild stuff
            IBuildingBeforeBuild buildingBeforeBuild = building as IBuildingBeforeBuild;

            if (buildingBeforeBuild != null)
            {
                buildingBeforeBuild.BeforeBuild(this);

                if (!buildingBeforeBuild.ContinueBuild())
                {
                    entity.destroy();
                    return;
                }
            }

            // Check to see if the primitive building wants a repeated texture renderer
            IBuildingRepeatedTextureRenderer buildingRepeatedTextureRenderer = building as IBuildingRepeatedTextureRenderer;

            if (buildingRepeatedTextureRenderer != null)
            {
                entity.addComponent(new BuildingRepeatedTextureRenderer(this, buildingRepeatedTextureRenderer.GetTexture()));
            }

            // Check to see if the primitive building wants a dynamic texture renderer
            IBuildingDynamicTexture buildingDynamicTextureRenderer = building as IBuildingDynamicTexture;

            if (buildingDynamicTextureRenderer != null)
            {
                entity.addComponent(new BuildingDynamicTextureRenderer(this, buildingDynamicTextureRenderer));
            }

            // Check to see if the primitive building wants a standard gameplay object renderer.
            IBuildingStandardGameplayRenderer buildingStandardGameplayRenderer = building as IBuildingStandardGameplayRenderer;

            if (buildingStandardGameplayRenderer != null)
            {
                entity.addComponent(new BuildingStandardGameplayRenderer(this, buildingStandardGameplayRenderer.GetTexture()));
            }

            // Check to see if the primitive building wishes to be consturcted instead of appear
            IBuildingRequiresConstruction buildingRequiresConstruction = building as IBuildingRequiresConstruction;

            if (buildingRequiresConstruction != null)
            {
                entity.addComponent(new UnderConstruction(this, buildingRequiresConstruction.GetTimeRequiredToBuild()));
            }
            else
            {
                Finish();
            }
        }
Exemple #3
0
 public BuildingDynamicTextureRenderer(Building building, IBuildingDynamicTexture buildingDynamicTexture) : base(BuildingType.Infrastructure, building, buildingDynamicTexture.SpriteNameHorizontal())
 {
     this.buildingDynamicTexture = buildingDynamicTexture;
 }