Ejemplo n.º 1
0
        /// <summary>
        /// Implemented by the derived class to provide a sprite set used
        /// to draw a preview of this structure on MapView.
        /// </summary>
        protected AlphaBlendSpriteSet createAlphaSprites()
        {
            IEntityBuilder contrib = current.current;

            if (contrib is LandBuilderContribution)
            {
                return(null);
            }
            Sprite[,,] temp;
            if (contrib is VarHeightBuildingContribution)
            {
                VarHeightBuildingContribution vhcontrib = (VarHeightBuildingContribution)contrib;
                Size sz      = vhcontrib.size;
                int  pHeight = 3;
                temp = new Sprite[sz.Width, sz.Height, pHeight];
                for (int z = 0; z < pHeight; z++)
                {
                    for (int y = 0; y < sz.Height; y++)
                    {
                        for (int x = 0; x < sz.Width; x++)
                        {
                            temp[x, y, z] = vhcontrib.getSprites(x, y, z, pHeight)[0];
                        }
                    }
                }
            }
            else
            {
                temp = ((CommercialStructureContribution)contrib).sprites;
            }
            return(new AlphaBlendSpriteSet(temp));
        }
Ejemplo n.º 2
0
 public override void onClick(MapViewWindow view, Location loc, Point ab)
 {
     if (!canBeBuilt(loc))
     {
         MainWindow.showError("Can not build");
     }
     //! MainWindow.showError("設置できません");
     else
     {
         if (current.current is VarHeightBuildingContribution)
         {
             VarHeightBuildingContribution vhContrib = (VarHeightBuildingContribution)current.current;
             CompletionHandler             handler   = new CompletionHandler(vhContrib, loc, (int)numHeight.Value, true);
             new ConstructionSite(loc, new EventHandler(handler.handle),
                                  new Distance(vhContrib.size, (int)numHeight.Value));
         }
         else
         {
             CommercialStructureContribution csContrib = (CommercialStructureContribution)current.current;
             if (csContrib.size.volume > 0)                    // eliminate dummy contribution
             {
                 CompletionHandler handler = new CompletionHandler(csContrib, loc, current.maxHeight, true);
                 new ConstructionSite(loc, new EventHandler(handler.handle), csContrib.size);
             }
         }
     }
     randomize();
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_type"></param>
        /// <param name="wloc"></param>
        /// <param name="_height"></param>
        /// <param name="initiallyOwned"></param>
        public VarHeightBuilding(VarHeightBuildingContribution _type, WorldLocator wloc,
                                 int _height, bool initiallyOwned)
        {
            this.type   = _type;
            this.height = _height;

            int Y = type.Size.Height;
            int X = type.Size.Width;
            int Z = height;

            this.baseLocation = wloc.location;

            voxels = new VoxelImpl[X, Y, Z];
            for (int z = 0; z < Z; z++)
            {
                for (int y = 0; y < Y; y++)
                {
                    for (int x = 0; x < X; x++)
                    {
                        WorldLocator wl = new WorldLocator(wloc.world, baseLocation + new Distance(x, y, z));
                        voxels[x, y, z] = new VoxelImpl(this, (byte)x, (byte)y, (byte)z, wl);
                    }
                }
            }
            if (wloc.world == WorldDefinition.World)
            {
                this.subsidiary = new SubsidiaryCompany(this, initiallyOwned);
            }

            if (type.Population != null)
            {
                stationListener = new StationListenerImpl(
                    new MultiplierPopulation(height, type.Population), baseLocation);
            }
        }
 internal CompletionHandler(VarHeightBuildingContribution contribution,
                            Location loc, int height, bool initiallyOwned)
 {
     this.contribution = contribution;
     this.loc          = loc;
     this.height       = height;
     this.owned        = initiallyOwned;
 }
Ejemplo n.º 5
0
 internal VarHeightBuildingPlan(
     VarHeightBuildingContribution contrib,
     ULVFactory factory, Location _loc, int h)
     : base(factory.create(new Cube(_loc, contrib.size, 0)))
 {
     this.contrib = contrib;
     this.loc     = _loc;
     this.h       = h;
 }
Ejemplo n.º 6
0
        protected void updatePrice()
        {
            int p = 0;

            if (current.current is VarHeightBuildingContribution)
            {
                VarHeightBuildingContribution vhb = (VarHeightBuildingContribution)current.current;
                p = vhb.price * (int)numHeight.Value;
            }
            else
            {
                p = current.unitPrice;
            }
            costBox.cost = p;
        }
Ejemplo n.º 7
0
        protected Plan GetPlan(IEntityBuilder entity)
        {
            Plan p = null;

            finalPrice = 0;
            if (entity is LandBuilderContribution)
            {
                LandBuilderContribution lbc = entity as LandBuilderContribution;
                SIZE size = new SIZE(Rand(F_LandAveSize, F_LandFlexSize), Rand(F_LandAveSize, F_LandFlexSize));
                p          = new LandPlan(lbc, dev, scaning, size);
                finalPrice = lbc.price * size.x * size.y;
            }
            else if (entity is CommercialStructureContribution)
            {
                CommercialStructureContribution csb = entity as CommercialStructureContribution;
                p          = new CommercialStructurePlan(csb, dev, scaning);
                finalPrice = entity.price;
            }
            else if (entity is VarHeightBuildingContribution)
            {
                VarHeightBuildingContribution vhbc = entity as VarHeightBuildingContribution;
                int  h     = vhbc.minHeight;
                int  h2    = vhbc.maxHeight;
                int  price = vhbc.price * h;
                Cube tmp   = new Cube(scaning, vhbc.size, h);
                int  cost  = 0;
                foreach (Entity e in tmp.getEntities())
                {
                    cost += e.entityValue;
                }
                while (price < cost && h < h2)
                {
                    if (price < cost)
                    {
                        price += vhbc.price;
                    }
                    h++;
                }
                p          = new VarHeightBuildingPlan(vhbc, dev, scaning, h);
                finalPrice = price;
            }
            return(p);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sprite"></param>
        /// <param name="color"></param>
        /// <param name="contrib"></param>
        /// <returns></returns>
        protected virtual Contribution CreatePrimitiveContrib(XmlElement sprite, XmlNode color, XmlElement contrib)
        {
            bool         opposite = (sprite.Attributes["opposite"] != null && sprite.Attributes["opposite"].Value.Equals("true"));
            Contribution newContrib;

            if (stType == SpriteTableType.VarHeight)
            {
                foreach (XmlNode child in sprite.ChildNodes)
                {
                    child.AppendChild(color.Clone());
                }
                newContrib = new VarHeightBuildingContribution(this, sprite, contrib, opposite);
            }
            else
            {
                sprite.AppendChild(color.Clone());
                newContrib = new CommercialStructureContribution(this, sprite, contrib, opposite);
            }
            return(newContrib);
        }