Exemplo n.º 1
0
        private static void HandleChopTree(Creature c)
        {
            int   currentFloor = c.CurrentFloor;
            Point worldIndex   = c.WorldIndex;

            Block[] blocks = currentFloor >= 0 ? Program.WorldMap[worldIndex.X, worldIndex.Y].Dungeon.Floors[currentFloor].Blocks : Program.WorldMap[worldIndex.X, worldIndex.Y].Blocks;
            int     width = Program.WorldMap.TileWidth, height = Program.WorldMap.TileHeight;

            Point closestTree = blocks.GetClosestOfBlockTypeToPos(c.Position, new Point(width, height), BlockType.Tree);
            bool  nextToTree  = c.Position.NextToPoint(closestTree);

            if (!nextToTree)
            {
                PathToPoint(c, closestTree);
            }
            else
            {
                if (c.Body.MainHand != null && c.Body.MainHand is Axe == false)
                {
                    for (int i = 0; i < c.Inventory.Count; i++)
                    {
                        Item I = c.Inventory[i];
                        if (I is Axe || I is Sword)
                        {
                            c.Wield(i, true);
                        }
                    }
                }
                c.ChopTree(closestTree);
            }
        }
Exemplo n.º 2
0
        // FUNCTIONS //

        public override void Activate(Creature user)
        {
            if (user.Body.MainHand != null && (user.Body.MainHand is Axe || user.Body.MainHand is Sword))
            {
                user.ChopTree(this);
            }
        }