예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public bool add(ContributionReference type)
 {
     if (type.PlaceSide == PlaceSide.Back)
     {
         if (back != null)
         {
             return(false);              // already occupied!
         }
         if (type.Frontface.isParallelToX)
         {
             if (fore.Frontface.isParallelToX)
             {
                 back = type;
                 return(true);
             }
         }
         else // parallel to Y
         {
             if (fore.Frontface.isParallelToY)
             {
                 back = type;
                 return(true);
             }
         }
     }
     else // PlaceSide.Fore
     {
         if (fore != null)
         {
             return(false);              // already occupied!
         }
         if (type.Frontface.isParallelToX)
         {
             if (back.Frontface.isParallelToX)
             {
                 fore = type;
                 return(true);
             }
         }
         else // parallel to Y
         {
             if (back.Frontface.isParallelToY)
             {
                 fore = type;
                 return(true);
             }
         }
     }
     WorldDefinition.World.OnVoxelUpdated(baseLocation);
     return(false);
 }
예제 #2
0
        /// <summary>
        ///
        ///
        /// </summary>
        /// <param name="baseLoc"></param>
        /// <param name="front"></param>
        /// <param name="side"></param>
        /// <returns></returns>
        public Structure Create(Location baseLoc, Direction front, PlaceSide side)
        {
            ContributionReference reffer = new ContributionReference(this, currentColor, currentHighlight, front, side);
            HalfDividedVoxel      v      = WorldDefinition.World[baseLoc] as HalfDividedVoxel;

            if (v == null)
            {
                return(new HVStructure(reffer, baseLoc));
            }
            else
            {
                if (!v.owner.add(reffer))
                {
                    MessageBox.Show("Not enough space or no fit");
                }

                return(v.owner);
            }
        }
예제 #3
0
        /// <summary>
        /// The sprite to draw.
        /// </summary>
        public HVStructure(ContributionReference type, Location loc)
        {
            this.baseLocation = loc;
            if (type.PlaceSide == PlaceSide.Back)
            {
                this.back = type;
            }
            else
            {
                this.fore = type;
            }

            // build voxels
            new HalfDividedVoxel(this, loc);
            subsidiary = new SubsidiaryCompany(this, false);
            if (type.Population != null)
            {
                stationListener = new StationListenerImpl(type.Population, loc);
            }
        }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public ContributionReference[] getReferences()
 {
     ContributionReference[] arr;
     if (hasSpace)
     {
         arr = new ContributionReference[1];
         if (owner.backside == null)
         {
             arr[0] = owner.foreside;
         }
         else
         {
             arr[0] = owner.backside;
         }
     }
     else
     {
         arr    = new ContributionReference[2];
         arr[0] = owner.backside;
         arr[1] = owner.foreside;
     }
     return(arr);
 }