Example #1
0
    public FarmhouseSave(GameObject go) : base(go)
    {
        Farmhouse f = go.GetComponent <Farmhouse>();

        CurrentlyStoring = f.CurrentlyStoring;
        Yield            = f.Yield;
    }
        private void ActionBuildFarmhouse()
        {
            Clear();
            if (ObjectManager.Instance.GetFarmer() != null)
            {
                ObjectManager.Instance.GetFarmer().Select();
            }
            if (ObjectManager.Instance.GetFarmhouse() != null)
            {
                return;
            }
            if (mWorldPosition.X < 3 || mWorldPosition.X > Game1.sTileMap.Width - 4 || mWorldPosition.Y < 3 ||
                mWorldPosition.Y > Game1.sTileMap.Height - 4)
            {
                SoundManager.PlaySound("test_sound2");
                NotificationManager.AddNotification("Du kannst dein Farmhaus nicht an den Rand bauen.", 2.0f);
                return;
            }

            var farmhouse = new Farmhouse((int)mWorldPosition.X, (int)mWorldPosition.Y);

            for (var i = (int)mWorldPosition.X - 1; i < (int)mWorldPosition.X + (int)farmhouse.CollisionBoxSize.X; i++)
            {
                for (var j = (int)mWorldPosition.Y; j < (int)mWorldPosition.Y + (int)farmhouse.CollisionBoxSize.Y + 1; j++)
                {
                    if (Game1.sTileMap.GetTileType(i, j) == Tile.Water)
                    {
                        SoundManager.PlaySound("test_sound2");
                        NotificationManager.AddNotification("Du kannst dein Farmhaus nicht so nah am Wasser bauen.", 2.0f);
                        return;
                    }
                }
            }

            if (ObjectManager.Instance.GetQuadTree().GetGameObjects(
                    farmhouse.CollisionBoxCenter - farmhouse.CollisionBoxSize / 2 - Vector2.UnitX,
                    farmhouse.CollisionBoxCenter + farmhouse.CollisionBoxSize / 2 + Vector2.UnitY,
                    false,
                    typeof(IPathCollidable)).Any())
            {
                SoundManager.PlaySound("test_sound2");
                NotificationManager.AddNotification("Du kannst dein Farmhaus nicht so nah an Bäumen/Steinen bauen.", 2.0f);
                return;
            }
            if (!FarmerQueueManager.Instance.Queue("ActionBuildFarmhouse", mWorldPosition))
            {
                return;
            }
            if (!EconomyManager.Instance.GoldDecrease("ActionBuildFarmhouse"))
            {
                return;
            }
            ObjectManager.Instance.Add(farmhouse);
            SoundManager.PlaySound("building_short");
        }
Example #3
0
        public static UIElement Shape(this ObjectCategory self)
        {
            Canvas shape;
            switch (self)
            {
                case ObjectCategory.ThunderstruckTree: shape = new Thunderstruck(); break;

                case ObjectCategory.HarvestableTree: shape = new Tree(false); break;
                case ObjectCategory.FruitedTree: shape = new Tree(true); break;

                //case ObjectCategory.Uprootable: shape = new Up(); break;

                case ObjectCategory.ScarecrowGarden: shape = new Garden(); break;

                case ObjectCategory.SmallHousing: shape = new SmallHouse(); break;

                case ObjectCategory.Farmhouse: shape = new Farmhouse(); break;
                case ObjectCategory.LargeHousing: shape = new LargeHouse(); break;

                case ObjectCategory.HarvestablePlant: shape = new Leaf(); break;
                case ObjectCategory.ScarecrowFarm: shape = new Farm(); break;
                case ObjectCategory.HousingWorkbench: shape = new HousingWorkbench(); break;
                
                case ObjectCategory.FriendlyPlayer: shape = new PlayerShape(true); break;
                case ObjectCategory.EnemyPlayer: shape = new PlayerShape(false); break;

                case ObjectCategory.FriendlyClipper: shape = new Clipper(true); break;
                case ObjectCategory.EnemyClipper: shape = new Clipper(false); break;

                case ObjectCategory.FriendlyMerchantShip: shape = new MerchantShip(true); break;
                case ObjectCategory.EnemyMerchantShip: shape = new MerchantShip(false); break;

                case ObjectCategory.FriendlyFishingBoat: shape = new FishingShip(true); break;
                case ObjectCategory.EnemyFishingBoat: shape = new FishingShip(false); break;

                case ObjectCategory.FriendlyGalleon: shape = new Galleon(true); break;
                case ObjectCategory.EnemyGalleon: shape = new Galleon(false); break;
                case ObjectCategory.FriendlyNPC: shape = new NpcShape(true); break;
                
                case ObjectCategory.TradePack: shape = new TradePack(); break;
                case ObjectCategory.Treasure: shape = new Treasure(); break;
                case ObjectCategory.FishSchool: shape = new Fish(); break;

                case ObjectCategory.EnemyNPC: shape = new NpcShape(false); break;
                    
                default:
                    Ellipse dot = DrawSimpleDot();
                    dot.Fill = self.Color();
                    return dot;       
            }

            //need to flip the shape because our canvas is inverted (due to game coordinate system)
            return Flip(shape);
        }
Example #4
0
        public void Add(BGameObject obj)
        {
            if (EndScreen)
            {
                AddMoonwalkZombie(obj);
                return;
            }

            mQuadTree.InsertGameObject(obj);

            if (obj is Farmer farmer)
            {
                if (mFarmer == null)
                {
                    mFarmer = farmer;
                }
                else
                {
                    mQuadTree.RemoveGameObject(obj);
                }
            }
            else if (obj is Farmhouse house)
            {
                if (mFarmhouse == null)
                {
                    mFarmhouse = house;
                }
                else
                {
                    mQuadTree.RemoveGameObject(obj);
                }
            }
            else if (obj is Tower tower)
            {
                mTowers.Add(tower);
            }
            else if (obj is Fence fence)
            {
                mFences.Add(fence);
            }
            else if (obj is PreviewFence previewFence)
            {
                mPreviewFences.Add(previewFence);
            }
            else if (obj is Zombie zombie && !(obj is TreasureZombie))
            {
                mZombies.Add(zombie);
            }