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();
 }
Пример #2
0
 internal CommercialStructurePlan(
     CommercialStructureContribution _contrib,
     ULVFactory factory, Location _loc)
     : base(factory.create(Cube.createExclusive(_loc, new Distance(_contrib.size.x, _contrib.size.y, 0))))
 {
     this.contrib = _contrib;
     this.loc     = _loc;
 }
Пример #3
0
 /// <summary>
 /// Creates a new commercial structurewith its left-top corner at
 /// the specified location.
 /// </summary>
 /// <param name="_type">
 /// Type of the structure to be built.
 /// </param>
 /// <param name="initiallyOwned"></param>
 /// <param name="wloc"></param>
 public Commercial(CommercialStructureContribution _type, WorldLocator wloc, bool initiallyOwned)
     : base(_type, wloc)
 {
     this.type = _type;
     if (wloc.world == WorldDefinition.World)
     {
         this.subsidiary = new SubsidiaryCompany(this, initiallyOwned);
     }
 }
Пример #4
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);
        }