Ejemplo n.º 1
0
        public static void receiveBuildingChange(byte whatChange, short tileX, short tileY, string name, long who, long id)
        {
            if (Game1.IsClient)
            {
                MultiplayerUtility.recentMultiplayerEntityID = id;
            }
            else
            {
                MultiplayerUtility.recentMultiplayerEntityID = MultiplayerUtility.getNewID();
            }
            if (Game1.currentLocation is Farm || Game1.IsServer)
            {
                Farm farm = (Farm)Game1.currentLocation;
                if (!(Game1.currentLocation is Farm))
                {
                    farm = (Farm)Game1.otherFarmers[id].currentLocation;
                }
                Farmer farmer = Game1.getFarmer(who);
                switch (whatChange)
                {
                case 0:
                {
                    BluePrint bluePrint = new BluePrint(name);
                    if (bluePrint.blueprintType.Equals("Animals") && farm.placeAnimal(bluePrint, new Vector2((float)tileX, (float)tileY), true, who) && farmer.IsMainPlayer)
                    {
                        bluePrint.consumeResources();
                    }
                    else if (!bluePrint.blueprintType.Equals("Animals") && farm.buildStructure(bluePrint, new Vector2((float)tileX, (float)tileY), true, farmer, false) && farmer.IsMainPlayer)
                    {
                        bluePrint.consumeResources();
                    }
                    else if (farmer.IsMainPlayer)
                    {
                        Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10016", new object[0]), Color.Red, 3500f));
                        return;
                    }
                    if (!bluePrint.blueprintType.Equals("Animals"))
                    {
                        Game1.playSound("axe");
                        return;
                    }
                    break;
                }

                case 1:
                {
                    Building buildingAt = farm.getBuildingAt(new Vector2((float)tileX, (float)tileY));
                    if (farm.destroyStructure(new Vector2((float)tileX, (float)tileY)))
                    {
                        int groundLevelTile = buildingAt.tileY + buildingAt.tilesHigh;
                        for (int i = 0; i < buildingAt.texture.Bounds.Height / Game1.tileSize; i++)
                        {
                            Game1.createRadialDebris(farm, buildingAt.texture, new Microsoft.Xna.Framework.Rectangle(buildingAt.texture.Bounds.Center.X, buildingAt.texture.Bounds.Center.Y, Game1.tileSize / 16, Game1.tileSize / 16), buildingAt.tileX + Game1.random.Next(buildingAt.tilesWide), buildingAt.tileY + buildingAt.tilesHigh - i, Game1.random.Next(20, 45), groundLevelTile);
                        }
                        Game1.playSound("explosion");
                        Utility.spreadAnimalsAround(buildingAt, farm);
                        return;
                    }
                    break;
                }

                case 2:
                {
                    BluePrint bluePrint   = new BluePrint(name);
                    Building  buildingAt2 = farm.getBuildingAt(new Vector2((float)tileX, (float)tileY));
                    farm.tryToUpgrade(buildingAt2, bluePrint);
                    break;
                }

                default:
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        public void addNewHatchedAnimal(string name)
        {
            if (this.getBuilding() is Coop)
            {
                foreach (Object @object in this.objects.Values)
                {
                    if (@object.bigCraftable && @object.Name.Contains("Incubator") && (@object.heldObject != null && @object.minutesUntilReady <= 0) && !this.isFull())
                    {
                        string type = "??";
                        if (@object.heldObject == null)
                        {
                            type = "White Chicken";
                        }
                        else
                        {
                            switch (@object.heldObject.ParentSheetIndex)
                            {
                            case 305:
                                type = "Void Chicken";
                                break;

                            case 442:
                                type = "Duck";
                                break;

                            case 180:
                            case 182:
                                type = "Brown Chicken";
                                break;

                            case 107:
                                type = "Dinosaur";
                                break;

                            case 174:
                            case 176:
                                type = "White Chicken";
                                break;
                            }
                        }
                        FarmAnimal farmAnimal = new FarmAnimal(type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                        farmAnimal.name        = name;
                        farmAnimal.displayName = name;
                        Building building = this.getBuilding();
                        farmAnimal.home         = building;
                        farmAnimal.homeLocation = new Vector2((float)building.tileX, (float)building.tileY);
                        farmAnimal.setRandomPosition(farmAnimal.home.indoors);
                        (building.indoors as AnimalHouse).animals.Add(farmAnimal.myID, farmAnimal);
                        (building.indoors as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID);
                        @object.heldObject       = (Object)null;
                        @object.ParentSheetIndex = 101;
                        break;
                    }
                }
            }
            else if (Game1.farmEvent != null && Game1.farmEvent is QuestionEvent)
            {
                FarmAnimal farmAnimal = new FarmAnimal((Game1.farmEvent as QuestionEvent).animal.type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                farmAnimal.name        = name;
                farmAnimal.displayName = name;
                farmAnimal.parentId    = (Game1.farmEvent as QuestionEvent).animal.myID;
                Building building = this.getBuilding();
                farmAnimal.home         = building;
                farmAnimal.homeLocation = new Vector2((float)building.tileX, (float)building.tileY);
                (Game1.farmEvent as QuestionEvent).forceProceed = true;
                farmAnimal.setRandomPosition(farmAnimal.home.indoors);
                (building.indoors as AnimalHouse).animals.Add(farmAnimal.myID, farmAnimal);
                (building.indoors as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID);
            }
            if (Game1.currentLocation.currentEvent != null)
            {
                ++Game1.currentLocation.currentEvent.CurrentCommand;
            }
            Game1.exitActiveMenu();
        }
Ejemplo n.º 3
0
        // Token: 0x06000152 RID: 338 RVA: 0x0000E63C File Offset: 0x0000C83C
        public static void receiveBuildingChange(byte whatChange, short tileX, short tileY, string name, long who, long id)
        {
            if (Game1.IsClient)
            {
                MultiplayerUtility.recentMultiplayerEntityID = id;
            }
            else
            {
                MultiplayerUtility.recentMultiplayerEntityID = MultiplayerUtility.getNewID();
            }
            if (Game1.currentLocation is Farm || Game1.IsServer)
            {
                Farm farm = (Farm)Game1.currentLocation;
                if (!(Game1.currentLocation is Farm))
                {
                    farm = (Farm)Game1.otherFarmers[id].currentLocation;
                }
                Farmer f = Game1.getFarmer(who);
                switch (whatChange)
                {
                case 0:
                {
                    BluePrint b = new BluePrint(name);
                    if (b.blueprintType.Equals("Animals") && farm.placeAnimal(b, new Vector2((float)tileX, (float)tileY), true, who) && f.IsMainPlayer)
                    {
                        b.consumeResources();
                    }
                    else if (!b.blueprintType.Equals("Animals") && farm.buildStructure(b, new Vector2((float)tileX, (float)tileY), true, f, false) && f.IsMainPlayer)
                    {
                        b.consumeResources();
                    }
                    else if (f.IsMainPlayer)
                    {
                        Game1.addHUDMessage(new HUDMessage("Can't Build There", Color.Red, 3500f));
                        return;
                    }
                    if (!b.blueprintType.Equals("Animals"))
                    {
                        Game1.playSound("axe");
                        return;
                    }
                    break;
                }

                case 1:
                {
                    Building destroyed = farm.getBuildingAt(new Vector2((float)tileX, (float)tileY));
                    if (farm.destroyStructure(new Vector2((float)tileX, (float)tileY)))
                    {
                        int groundYTile = destroyed.tileY + destroyed.tilesHigh;
                        for (int i = 0; i < destroyed.texture.Bounds.Height / Game1.tileSize; i++)
                        {
                            Game1.createRadialDebris(farm, destroyed.texture, new Microsoft.Xna.Framework.Rectangle(destroyed.texture.Bounds.Center.X, destroyed.texture.Bounds.Center.Y, Game1.tileSize / 16, Game1.tileSize / 16), destroyed.tileX + Game1.random.Next(destroyed.tilesWide), destroyed.tileY + destroyed.tilesHigh - i, Game1.random.Next(20, 45), groundYTile);
                        }
                        Game1.playSound("explosion");
                        Utility.spreadAnimalsAround(destroyed, farm);
                        return;
                    }
                    break;
                }

                case 2:
                {
                    BluePrint b         = new BluePrint(name);
                    Building  toUpgrade = farm.getBuildingAt(new Vector2((float)tileX, (float)tileY));
                    farm.tryToUpgrade(toUpgrade, b);
                    break;
                }

                default:
                    return;
                }
            }
        }
Ejemplo n.º 4
0
        public void addNewHatchedAnimal(string name)
        {
            if (this.getBuilding() is Coop)
            {
                using (Dictionary <Vector2, Object> .ValueCollection.Enumerator enumerator = this.objects.Values.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Object current = enumerator.Current;
                        if (current.bigCraftable && current.Name.Contains("Incubator") && current.heldObject != null && current.minutesUntilReady <= 0 && !this.isFull())
                        {
                            string type = "??";
                            if (current.heldObject == null)
                            {
                                type = "White Chicken";
                            }
                            else
                            {
                                int num = current.heldObject.ParentSheetIndex;
                                if (num <= 176)
                                {
                                    if (num != 107)
                                    {
                                        if (num == 174 || num == 176)
                                        {
                                            type = "White Chicken";
                                        }
                                    }
                                    else
                                    {
                                        type = "Dinosaur";
                                    }
                                }
                                else if (num <= 182)
                                {
                                    if (num == 180 || num == 182)
                                    {
                                        type = "Brown Chicken";
                                    }
                                }
                                else if (num != 305)
                                {
                                    if (num == 442)
                                    {
                                        type = "Duck";
                                    }
                                }
                                else
                                {
                                    type = "Void Chicken";
                                }
                            }
                            FarmAnimal farmAnimal = new FarmAnimal(type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                            farmAnimal.name        = name;
                            farmAnimal.displayName = name;
                            Building building = this.getBuilding();
                            farmAnimal.home         = building;
                            farmAnimal.homeLocation = new Vector2((float)building.tileX, (float)building.tileY);
                            farmAnimal.setRandomPosition(farmAnimal.home.indoors);
                            (building.indoors as AnimalHouse).animals.Add(farmAnimal.myID, farmAnimal);
                            (building.indoors as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID);
                            current.heldObject       = null;
                            current.ParentSheetIndex = 101;
                            break;
                        }
                    }
                    goto IL_2D6;
                }
            }
            if (Game1.farmEvent != null && Game1.farmEvent is QuestionEvent)
            {
                FarmAnimal farmAnimal2 = new FarmAnimal((Game1.farmEvent as QuestionEvent).animal.type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                farmAnimal2.name        = name;
                farmAnimal2.displayName = name;
                farmAnimal2.parentId    = (Game1.farmEvent as QuestionEvent).animal.myID;
                Building building2 = this.getBuilding();
                farmAnimal2.home         = building2;
                farmAnimal2.homeLocation = new Vector2((float)building2.tileX, (float)building2.tileY);
                (Game1.farmEvent as QuestionEvent).forceProceed = true;
                farmAnimal2.setRandomPosition(farmAnimal2.home.indoors);
                (building2.indoors as AnimalHouse).animals.Add(farmAnimal2.myID, farmAnimal2);
                (building2.indoors as AnimalHouse).animalsThatLiveHere.Add(farmAnimal2.myID);
            }
IL_2D6:
            if (Game1.currentLocation.currentEvent != null)
            {
                Event expr_2EC = Game1.currentLocation.currentEvent;
                int   num      = expr_2EC.CurrentCommand;
                expr_2EC.CurrentCommand = num + 1;
            }
            Game1.exitActiveMenu();
        }
Ejemplo n.º 5
0
        public static void receiveBuildingChange(byte whatChange, short tileX, short tileY, string name, long who, long id)
        {
            MultiplayerUtility.recentMultiplayerEntityID = !Game1.IsClient ? MultiplayerUtility.getNewID() : id;
            if (!(Game1.currentLocation is Farm) && !Game1.IsServer)
            {
                return;
            }
            Farm currentLocation = (Farm)Game1.currentLocation;

            if (!(Game1.currentLocation is Farm))
            {
                currentLocation = (Farm)Game1.otherFarmers[id].currentLocation;
            }
            Farmer farmer = Game1.getFarmer(who);

            switch (whatChange)
            {
            case 0:
                BluePrint bluePrint = new BluePrint(name);
                if (bluePrint.blueprintType.Equals("Animals") && currentLocation.placeAnimal(bluePrint, new Vector2((float)tileX, (float)tileY), true, who) && farmer.IsMainPlayer)
                {
                    bluePrint.consumeResources();
                }
                else if (!bluePrint.blueprintType.Equals("Animals") && currentLocation.buildStructure(bluePrint, new Vector2((float)tileX, (float)tileY), true, farmer, false) && farmer.IsMainPlayer)
                {
                    bluePrint.consumeResources();
                }
                else if (farmer.IsMainPlayer)
                {
                    Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10016"), Color.Red, 3500f));
                    break;
                }
                if (bluePrint.blueprintType.Equals("Animals"))
                {
                    break;
                }
                Game1.playSound("axe");
                break;

            case 1:
                Building buildingAt1 = currentLocation.getBuildingAt(new Vector2((float)tileX, (float)tileY));
                if (!currentLocation.destroyStructure(new Vector2((float)tileX, (float)tileY)))
                {
                    break;
                }
                int num = buildingAt1.tileY + buildingAt1.tilesHigh;
                for (int index = 0; index < buildingAt1.texture.Bounds.Height / Game1.tileSize; ++index)
                {
                    Farm      farm    = currentLocation;
                    Texture2D texture = buildingAt1.texture;
                    Microsoft.Xna.Framework.Rectangle bounds = buildingAt1.texture.Bounds;
                    int x = bounds.Center.X;
                    bounds = buildingAt1.texture.Bounds;
                    int y      = bounds.Center.Y;
                    int width  = Game1.tileSize / 16;
                    int height = Game1.tileSize / 16;
                    Microsoft.Xna.Framework.Rectangle sourcerectangle = new Microsoft.Xna.Framework.Rectangle(x, y, width, height);
                    int xTile           = buildingAt1.tileX + Game1.random.Next(buildingAt1.tilesWide);
                    int yTile           = buildingAt1.tileY + buildingAt1.tilesHigh - index;
                    int numberOfChunks  = Game1.random.Next(20, 45);
                    int groundLevelTile = num;
                    Game1.createRadialDebris((GameLocation)farm, texture, sourcerectangle, xTile, yTile, numberOfChunks, groundLevelTile);
                }
                Game1.playSound("explosion");
                Utility.spreadAnimalsAround(buildingAt1, currentLocation);
                break;

            case 2:
                BluePrint blueprint   = new BluePrint(name);
                Building  buildingAt2 = currentLocation.getBuildingAt(new Vector2((float)tileX, (float)tileY));
                currentLocation.tryToUpgrade(buildingAt2, blueprint);
                break;
            }
        }