コード例 #1
0
        public override int Construct(Point3D location, Map map, ref MapOperationSeries mapOperationSeries)
        {
            int trunkHue = base.Construct(location, map, ref mapOperationSeries);

            GraphicAsset[] leafSet = null;

            if (LeafSets != null && LeafSets.Count > 0)
            {
                //leafSet = LeafSets[Utility.Random(LeafSets.Count)];
                leafSet = LeafSets[0];
            }

            if (leafSet != null)
            {
                foreach (GraphicAsset asset in leafSet)
                {
                    //come back and add a usestatic boolean to this class and add it into the constructor too
                    AddStatic addStatic = new AddStatic(map.MapID, asset.ItemID, location.Z, location.X + asset.XOffset, location.Y + asset.YOffset, LEAF_HUE);
                    if (mapOperationSeries == null)
                    {
                        mapOperationSeries = new MapOperationSeries(addStatic, map.MapID);
                    }
                    else
                    {
                        mapOperationSeries.Add(addStatic);
                    }
                }
            }

            return(trunkHue);
        }
コード例 #2
0
        public void Teardown(Point3D originLocation, Map map)
        {
            MapOperationSeries series = null;

            Teardown(originLocation, map, ref series);
            if (series != null)
            {
                series.DoOperation();
            }
        }
コード例 #3
0
        public void Construct(Point3D location, Map map)
        {
            MapOperationSeries series = null;

            Construct(location, map, ref series);
            if (series != null)
            {
                series.DoOperation();
            }
        }
コード例 #4
0
        /* This is the growth function for a phase. If a next growth phase is defined, this function tears down all the assets associated with the
         * phase and constructs the next growth phase. If the next phase has not been defined, this function assumes that the phase has finished
         * growing, and does nothing.
         *
         *                       Grow                     Grow                      Grow                     Grow
         *
         *    +----------------+       +----------------+       +-----------------+      +-----------------+
         *    | SaplingPhase1  +------>| SaplingPhase2  +------>| GrownTreePhase1 +----->| GrownTreePhase2 |---------->( Stop )
         *    +----------------+       +----------------+       +-----------------+      +-----------------+
         *
         */
        public virtual bool Grow(Point3D originLocation, Map map)
        {
            MapOperationSeries series = null;
            bool grew = grow(originLocation, map, ref series);

            if (series != null)
            {
                series.DoOperation();
            }

            return(grew);
        }
コード例 #5
0
        public virtual bool grow(Point3D originLocation, Map map, ref MapOperationSeries series)
        {
            bool grew = false;

            if (NextGrowthPhase != null)
            {
                Teardown(originLocation, map, ref series);
                MasterHarvestablePhaseLookupByTypeList[NextGrowthPhase].Construct(originLocation, map); //this is the transition to the next phase
                grew = true;
            }

            return(grew);
        }
コード例 #6
0
        public override bool Harvest(Mobile from, int itemId, Point3D harvestTargetLocation, Map map)
        {
            bool successfulHarvest        = false;
            MapOperationSeries mapActions = null;

            successfulHarvest = Harvest(from, itemId, harvestTargetLocation, map, ref mapActions);

            if (mapActions != null)
            {
                mapActions.DoOperation();
            }
            return(successfulHarvest);
        }
コード例 #7
0
        public override bool Harvest(Mobile from, int itemId, Point3D harvestTargetLocation, Map map)
        {
            Point3D trunkLocation = LookupOriginLocation(harvestTargetLocation, itemId);

            //search for leaves
            MapOperationSeries mapActions = null;
            List <KeyValuePair <int, GraphicAsset> > leavesRemoved = RemoveAssets(map, trunkLocation, ref mapActions, LeafSets);

            if (mapActions != null)
            {
                //handle falling leaves

                int numLeaves = Utility.Random(5);
                Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(trunkLocation.X, trunkLocation.Y, trunkLocation.Z + 20), map),
                                            new Entity(Serial.Zero, new Point3D(trunkLocation.X, trunkLocation.Y, trunkLocation.Z), map),
                                            0x1B1F, 1, 0, false, false, FALLING_LEAF_HUE, 0, 0, 1, 0, EffectLayer.Waist, 0x486);

                for (int i = 0; i < numLeaves + 9; i++)
                {
                    new FadingLeaf().MoveToWorld(new Point3D(trunkLocation.X + Utility.Random(4) - 2, trunkLocation.Y + Utility.Random(4) - 2, trunkLocation.Z), map);
                    Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(trunkLocation.X + Utility.Random(4) - 2, trunkLocation.Y + Utility.Random(4) - 2, trunkLocation.Z + 20), map),
                                                new Entity(Serial.Zero, new Point3D(trunkLocation.X + Utility.Random(4) - 2, trunkLocation.Y + Utility.Random(4) - 2, trunkLocation.Z), map),
                                                0x1B1F, 1, 0, false, false, FALLING_LEAF_HUE, 0, 0, 1, 0, EffectLayer.Waist, 0x486);
                }

                //give out leaf bonus asset resources
                foreach (KeyValuePair <int, GraphicAsset> assetPair in leavesRemoved)
                {
                    foreach (Item itm in assetPair.Value.ReapBonusResources(assetPair.Key, from))
                    {
                        from.AddToBackpack(itm);
                    }
                }
            }
            else //if there are no leaves left, then remove the trunk pieces and call nextPhase.construct
            {
                base.Harvest(from, itemId, harvestTargetLocation, map, ref mapActions);
            }

            if (mapActions != null)
            {
                mapActions.DoOperation();
            }

            return(false);
        }
コード例 #8
0
        /*
         * Return value is the HUE
         */
        public virtual int Construct(Point3D location, Map map, ref MapOperationSeries mapOperationSeries)
        {
            onBeforeConstruct(location, map, ref mapOperationSeries);

            GraphicAsset[] trunkSet = null;

            if (BaseAssetSets != null && BaseAssetSets.Count > 0)
            {
                trunkSet = BaseAssetSets[Utility.Random(BaseAssetSets.Count)];
            }

            int hue = 0;

            List <int> possibleHues = new List <int>(PhaseResources.Keys);

            if (ConstructUsingHues && possibleHues.Count > 0)
            {
                hue = possibleHues[Utility.Random(possibleHues.Count)];
            }

            if (trunkSet != null)
            {
                foreach (GraphicAsset asset in trunkSet)
                {
                    //come back and add a usestatic boolean to this class and add it into the constructor too
                    AddStatic addStatic = new AddStatic(map.MapID, asset.ItemID, location.Z, location.X + asset.XOffset, location.Y + asset.YOffset, hue);
                    if (mapOperationSeries == null)
                    {
                        mapOperationSeries = new MapOperationSeries(addStatic, map.MapID);
                    }
                    else
                    {
                        mapOperationSeries.Add(addStatic);
                    }
                }
            }

            return(hue);
        }
コード例 #9
0
        public static List <KeyValuePair <int, GraphicAsset> > RemoveAssets(Map map, Point3D trunkLocation, ref MapOperationSeries deleteTreePartsOperationSeries, List <GraphicAsset[]> assetList)
        {
            List <KeyValuePair <int, GraphicAsset> > treePartsRemoved = new List <KeyValuePair <int, GraphicAsset> >();

            foreach (GraphicAsset[] assetSet in assetList)
            {
                foreach (GraphicAsset treeAsset in assetSet)
                {
                    int leafX = trunkLocation.X + treeAsset.XOffset;
                    int leafY = trunkLocation.Y + treeAsset.YOffset;

                    foreach (StaticTile tile in map.Tiles.GetStaticTiles(leafX, leafY))
                    {
                        if (tile.Z >= trunkLocation.Z - STATIC_TILE_SEARCH_Z_TOLERANCE && tile.Z <= trunkLocation.Z + STATIC_TILE_SEARCH_Z_TOLERANCE)
                        {
                            if (tile.ID == treeAsset.ItemID)
                            {
                                Point3D leafLocation = new Point3D(leafX, leafY, tile.Z);

                                if (deleteTreePartsOperationSeries == null)
                                {
                                    deleteTreePartsOperationSeries = new MapOperationSeries(new DeleteStatic(map.MapID, new StaticTarget(leafLocation, treeAsset.ItemID)), map.MapID);
                                }
                                else
                                {
                                    deleteTreePartsOperationSeries.Add(new DeleteStatic(map.MapID, new StaticTarget(leafLocation, treeAsset.ItemID)));
                                }

                                treePartsRemoved.Add(new KeyValuePair <int, GraphicAsset>(tile.Hue, treeAsset));

                                continue;
                            }
                        }
                    }
                }
            }

            return(treePartsRemoved);
        }
コード例 #10
0
 public virtual void Teardown(Point3D originLocation, Map map, ref MapOperationSeries mapActions)
 {
     List <KeyValuePair <int, GraphicAsset> > basePiecesRemoved = RemoveAssets(map, originLocation, ref mapActions, BaseAssetSets);
 }
コード例 #11
0
 public virtual void onBeforeConstruct(Point3D location, Map map, ref MapOperationSeries mapOperationSeries)
 {
 }
コード例 #12
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            if (!Directory.Exists(UltimaLiveSettings.LumberHarvestFallenTreeSaveLocation))
            {
                Directory.CreateDirectory(UltimaLiveSettings.LumberHarvestFallenTreeSaveLocation);
            }

            bool updateRegrowthTime = false;

            //foreach map in the lookup table
            foreach (Map m in Map.AllMaps)
            {
                if (RegrowthMasterLookupTable.ContainsKey(m.MapID))
                {
                    #region Regrowth
                    if (DateTime.Now > LastGrowth + TimeBetweenRegrowth)
                    {
                        updateRegrowthTime = true;
                        Dictionary <Point3D, int> mapLookupTable = RegrowthMasterLookupTable[m.MapID];
                        MapOperationSeries        mapOperations  = null;

                        List <Point3D> locationsToRemove = new List <Point3D>();

                        //for each tree location in the lookup table
                        foreach (KeyValuePair <Point3D, int> treeLocationKvp in mapLookupTable)
                        {
                            if (BaseHarvestablePhase.MasterHarvestablePhaseLookupByItemIdList.ContainsKey(treeLocationKvp.Value))
                            {
                                //look up the current phase
                                bool existingTileFound = false;
                                foreach (StaticTile tile in m.Tiles.GetStaticTiles(treeLocationKvp.Key.X, treeLocationKvp.Key.Y))
                                {
                                    if (tile.Z == treeLocationKvp.Key.Z)                                                        // if the z altitude matches
                                    {
                                        if (BaseHarvestablePhase.MasterHarvestablePhaseLookupByItemIdList.ContainsKey(tile.ID)) //if the item id is linked to a phase
                                        {
                                            BaseHarvestablePhase currentPhase = BaseHarvestablePhase.MasterHarvestablePhaseLookupByItemIdList[tile.ID];

                                            foreach (GraphicAsset[] assetSet in currentPhase.BaseAssetSets)
                                            {
                                                if (assetSet.Length > 0 && assetSet[0].ItemID == tile.ID)
                                                {
                                                    existingTileFound = true;
                                                }
                                            }

                                            if (existingTileFound && !currentPhase.grow(treeLocationKvp.Key, m, ref mapOperations))
                                            {
                                                locationsToRemove.Add(treeLocationKvp.Key);
                                            }

                                            break;
                                        }
                                    }
                                }

                                //nothing to grow at this location, so construct the starting phase
                                if (!existingTileFound)
                                {
                                    //lookup original phase that was saved
                                    BaseHarvestablePhase grownPhase = BaseHarvestablePhase.MasterHarvestablePhaseLookupByItemIdList[treeLocationKvp.Value];

                                    //cleanup final harvest graphics
                                    if (grownPhase.FinalHarvestPhase != null && BaseHarvestablePhase.MasterHarvestablePhaseLookupByTypeList.ContainsKey(grownPhase.FinalHarvestPhase))
                                    {
                                        BaseHarvestablePhase.MasterHarvestablePhaseLookupByTypeList[grownPhase.FinalHarvestPhase].Teardown(treeLocationKvp.Key, m, ref mapOperations);
                                    }

                                    if (grownPhase.StartingGrowthPhase != null && BaseHarvestablePhase.MasterHarvestablePhaseLookupByTypeList.ContainsKey(grownPhase.StartingGrowthPhase))
                                    {
                                        //remove stump
                                        BaseTreeHarvestPhase maturePhase = grownPhase as BaseTreeHarvestPhase;
                                        if (maturePhase != null)
                                        {
                                            if (mapOperations != null)
                                            {
                                                mapOperations.Add(new DeleteStatic(m.MapID, new StaticTarget(treeLocationKvp.Key, maturePhase.StumpGraphic)));
                                            }
                                            else
                                            {
                                                mapOperations = new MapOperationSeries(new DeleteStatic(m.MapID, new StaticTarget(treeLocationKvp.Key, maturePhase.StumpGraphic)), m.MapID);
                                            }
                                        }

                                        BaseHarvestablePhase.MasterHarvestablePhaseLookupByTypeList[grownPhase.StartingGrowthPhase].Construct(treeLocationKvp.Key, m, ref mapOperations);
                                    }
                                }
                            }
                        }

                        if (mapOperations != null)
                        {
                            mapOperations.DoOperation();
                        }

                        foreach (Point3D p in locationsToRemove)
                        {
                            RegrowthMasterLookupTable[m.MapID].Remove(p);
                        }
                    }
                    #endregion

                    GenericWriter writer = new BinaryFileWriter(Path.Combine(UltimaLiveSettings.LumberHarvestFallenTreeSaveLocation, "TreeLocations." + m.MapID), true);

                    foreach (KeyValuePair <Point3D, int> kvp in RegrowthMasterLookupTable[m.MapID])
                    {
                        writer.Write(kvp.Key);
                        writer.Write(kvp.Value);
                    }
                    writer.Close();
                }
            }

            if (updateRegrowthTime)
            {
                LastGrowth = DateTime.Now;
            }
        }
コード例 #13
0
        public bool Harvest(Mobile from, int itemId, Point3D harvestTargetLocation, Map map, ref MapOperationSeries operationSeries)
        {
            Point3D trunkLocation = LookupOriginLocation(harvestTargetLocation, itemId);

            List <KeyValuePair <int, GraphicAsset> > phasePiecesRemoved = null;

            //If the next phase is not null, tear it all down and construct the next phase
            if (NextHarvestPhase != null)
            {
                phasePiecesRemoved = RemoveAssets(map, trunkLocation, ref operationSeries, BaseAssetSets);
                int constructedTreeHue = 0;

                if (MasterHarvestablePhaseLookupByTypeList.ContainsKey(NextHarvestPhase))
                {
                    constructedTreeHue = MasterHarvestablePhaseLookupByTypeList[NextHarvestPhase].Construct(trunkLocation, map, ref operationSeries);
                }

                if (operationSeries != null)
                {
                    RecordTreeLocationAndGraphic(map.MapID, BaseAssetSets[0][0].ItemID, trunkLocation);

                    if (AddStump)
                    {
                        operationSeries.Add(new AddStatic(map.MapID, StumpGraphic, trunkLocation.Z, trunkLocation.X, trunkLocation.Y, constructedTreeHue));
                    }
                }
            }
            else //the next phase is not null, so destroy one asset at a time
            {
                GraphicAsset          asset          = LookupAsset(itemId);
                List <GraphicAsset[]> assetsToRemove = new List <GraphicAsset[]>();
                assetsToRemove.Add(new GraphicAsset[] { asset });
                phasePiecesRemoved = RemoveAssets(map, trunkLocation, ref operationSeries, assetsToRemove);
            }

            int hue = 0;

            //give out phase resource for each graphic asset removed
            foreach (KeyValuePair <int, GraphicAsset> assetPair in phasePiecesRemoved)
            {
                hue = assetPair.Key;

                Item itm = this.ReapResource(assetPair.Key, from, assetPair.Value.HarvestResourceBaseAmount);

                if (itm != null)
                {
                    from.AddToBackpack(itm);
                }
            }

            //give out asset bonus resources
            foreach (Item itm in this.ReapBonusResources(hue, from))
            {
                from.AddToBackpack(itm);
            }

            bool returnValue = false;

            if (operationSeries != null)
            {
                returnValue = true;
            }

            return(returnValue);
        }
コード例 #14
0
 public override void Teardown(Point3D originLocation, Map map, ref MapOperationSeries mapActions)
 {
     base.Teardown(originLocation, map, ref mapActions);
     List <KeyValuePair <int, GraphicAsset> > leavesRemoved = RemoveAssets(map, originLocation, ref mapActions, LeafSets);
 }