コード例 #1
0
ファイル: HVStructure.cs プロジェクト: hayate891/freetrain
 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);
             }
         }
     }
     World.world.onVoxelUpdated(baseLocation);
     return(false);
 }
コード例 #2
0
        public Structure create(Location baseLoc, Direction front, PlaceSide side)
        {
            ContributionReference reffer = new ContributionReference(this, currentColor, currentHighlight, front, side);
            HalfDividedVoxel      v      = World.world[baseLoc] as HalfDividedVoxel;

            if (v == null)
            {
                return(new HVStructure(reffer, baseLoc));
            }
            else
            {
                if (!v.owner.add(reffer))
                {
                    MainWindow.showError("Not enough space or no fit");
                }
                //! MainWindow.showError("設置スペースが無いか、一致しません");
                return(v.owner);
            }
        }
コード例 #3
0
ファイル: HVStructure.cs プロジェクト: hayate891/freetrain
        /// <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
ファイル: HVStructure.cs プロジェクト: hayate891/freetrain
 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);
 }