예제 #1
0
    static void Main()
    {
        BaseCat    b1 = new BaseCat();
        DerivedCat d1 = new DerivedCat();

        b1.Name = "Mary";
        d1.Name = "John";

        b1.Color = "White";
        d1.Color = "Black";  // The BaseCat.Color property is called.

        System.Console.WriteLine("Base: {0}, {1}", b1.Name, b1.Color);
        System.Console.WriteLine("Derived: {0}, {1}", d1.Name, d1.Color);

        // Keep the console window open in debug mode.
    }
예제 #2
0
        private Sprite DeserializeModel(string objKey, ISaveState objSave)
        {
            // Add base sprite models here, (AnimatedSprite namespace, not Model namespace)
            Sprite         sp = null;
            OnGroundState  ogs;
            ShipState      ss;
            NpcState       npcs;
            StructureState sts;

            switch (objKey)
            {
            // TODO: Should I save fired ammo state?

            case "baseShip":
                ss = (ShipState)objSave;
                BaseShip bs = new BaseShip(ss.team, ss.region, ss.location, _content, _graphics);
                bs.health          = ss.health;
                bs.actionInventory = DeserializeInventory(ss.actionInventory);
                //bs.shipInterior = DeserializeInterior(ss.interiorState); we do this after models are created
                bs.playerAboard = ss.playerAboard;
                bs.SetInteriorForId(ss.shipId);
                if (bs.playerAboard)
                {
                    bs.shipSail.playerAboard = true;
                }
                return(bs);

            case "baseTribal":
                npcs = (NpcState)objSave;
                BaseTribal bt = new BaseTribal(npcs.team, npcs.region, npcs.location, _content, _graphics);
                bt.health    = npcs.health;
                bt.inventory = DeserializeInventory(npcs.inventory);
                return(bt);

            case "baseCat":
                npcs = (NpcState)objSave;
                BaseCat bct = new BaseCat(npcs.team, npcs.region, npcs.location, _content, _graphics);
                bct.health    = npcs.health;
                bct.inventory = DeserializeInventory(npcs.inventory);
                return(bct);

            case "chicken":
                npcs = (NpcState)objSave;
                Chicken chk = new Chicken(npcs.team, npcs.region, npcs.location, _content, _graphics);
                chk.health    = npcs.health;
                chk.inventory = DeserializeInventory(npcs.inventory);
                return(chk);

            case "blueBird":
                npcs = (NpcState)objSave;
                BlueBird bbr = new BlueBird(npcs.team, npcs.region, npcs.location, _content, _graphics);
                bbr.health    = npcs.health;
                bbr.inventory = DeserializeInventory(npcs.inventory);
                return(bbr);

            case "snake":
                npcs = (NpcState)objSave;
                Snake snk = new Snake(npcs.team, npcs.region, npcs.location, _content, _graphics);
                snk.health    = npcs.health;
                snk.inventory = DeserializeInventory(npcs.inventory);
                return(snk);

            case "teePee":
                sts = (StructureState)objSave;
                TeePee tp = new TeePee(sts.team, sts.region, sts.location, _content, _graphics);
                return(tp);

            case "baseBarrel":
                ogs = (OnGroundState)objSave;
                BaseBarrel bb = new BaseBarrel(ogs.team, ogs.region, ogs.location, _content, _graphics);
                bb.drops = DeserializeInventory(ogs.inventory);
                return(bb);

            case "baseChest":
                ogs = (OnGroundState)objSave;
                BaseChest bc = new BaseChest(ogs.team, ogs.region, ogs.location, _content, _graphics);
                bc.inventory = DeserializeInventory(ogs.inventory);
                return(bc);

            case "clayFurnace":
                ogs = (OnGroundState)objSave;
                ClayFurnace cf = new ClayFurnace(ogs.team, ogs.region, ogs.location, _content, _graphics);
                return(cf);

            case "campFire":
                ogs = (OnGroundState)objSave;
                CampFire caf = new CampFire(ogs.team, ogs.region, ogs.location, _content, _graphics);
                return(caf);

            case "craftingAnvil":
                ogs = (OnGroundState)objSave;
                CraftingAnvil ca = new CraftingAnvil(ogs.team, ogs.region, ogs.location, _content, _graphics);
                return(ca);
            }
            return(sp);
        }
예제 #3
0
        // Creates the initial game state - this will probably be a huge method at the end of it.. TODO: find way to dynamically create items/npc/etc and place them in appropriate region
        public void CreateNewGame()
        {
            //TEMPORARY NEED TO CREATE SOME SORT OF GAME SETUP / REGION SETUP that is easily scalable
            List <Sprite> giannaLandTiles = BoundingBoxLocations.RegionMap["Gianna"].RegionLandTiles;
            List <Sprite> scLandTiles     = BoundingBoxLocations.RegionMap["SnooCat"].RegionLandTiles;
            List <Sprite> usoppLandTiles  = BoundingBoxLocations.RegionMap["Usopp"].RegionLandTiles;
            var           screenCenter    = new Vector2(_graphics.Viewport.Bounds.Width / 2, _graphics.Viewport.Bounds.Height / 2);

            ShortShip shortShip = new ShortShip(TeamType.Player, "GustoMap", new Vector2(-100, -600), _content, _graphics);

            shortShip.shipInterior.interiorId = Guid.NewGuid();
            BoundingBoxLocations.interiorMap.Add(shortShip.shipInterior.interiorId, shortShip.shipInterior);

            BaseShip baseShip = new BaseShip(TeamType.Player, "GustoMap", new Vector2(-300, -600), _content, _graphics);

            baseShip.shipInterior.interiorId = Guid.NewGuid();
            BoundingBoxLocations.interiorMap.Add(baseShip.shipInterior.interiorId, baseShip.shipInterior);

            BaseShip baseShipAI = new BaseShip(TeamType.A, "Usopp", new Vector2(500, -140), _content, _graphics);

            baseShipAI.shipInterior.interiorId = Guid.NewGuid();
            BoundingBoxLocations.interiorMap.Add(baseShipAI.shipInterior.interiorId, baseShipAI.shipInterior);

            TeePee teePee = new TeePee(TeamType.A, "Gianna", new Vector2(340, -850), _content, _graphics);

            teePee.structureInterior.interiorId = Guid.NewGuid();
            BoundingBoxLocations.interiorMap.Add(teePee.structureInterior.interiorId, teePee.structureInterior);

            BaseTribal    baseTribalLand = new BaseTribal(TeamType.A, "Gianna", giannaLandTiles[RandomEvents.rand.Next(giannaLandTiles.Count)].location, _content, _graphics);
            BaseCat       baseCatLand    = new BaseCat(TeamType.B, "SnooCat", scLandTiles[RandomEvents.rand.Next(scLandTiles.Count)].location, _content, _graphics);
            Chicken       chickenLand    = new Chicken(TeamType.Animal, "Gianna", giannaLandTiles[RandomEvents.rand.Next(giannaLandTiles.Count)].location, _content, _graphics);
            Snake         snakeLand      = new Snake(TeamType.Animal, "Usopp", usoppLandTiles[RandomEvents.rand.Next(usoppLandTiles.Count)].location, _content, _graphics);
            BlueBird      blueBird       = new BlueBird(TeamType.Animal, "Usopp", usoppLandTiles[RandomEvents.rand.Next(usoppLandTiles.Count)].location, _content, _graphics);
            Tower         tower          = new BaseTower(TeamType.B, "GustoMap", new Vector2(-1600, -1500), _content, _graphics);
            ClayFurnace   furnace        = new ClayFurnace(TeamType.Player, "GustoMap", new Vector2(180, 140), _content, _graphics);
            CraftingAnvil craftingAnvil  = new CraftingAnvil(TeamType.Player, "GustoMap", new Vector2(120, 40), _content, _graphics);
            BaseBarrel    barrelLand     = new BaseBarrel(TeamType.A, "GustoMap", new Vector2(-20, -160), _content, _graphics);
            BaseBarrel    barrelOcean    = new BaseBarrel(TeamType.A, "GustoMap", new Vector2(380, -90), _content, _graphics);
            BaseChest     chestLand      = new BaseChest(TeamType.A, "GustoMap", new Vector2(100, -120), _content, _graphics);
            CampFire      campfire       = new CampFire(TeamType.A, "GustoMap", new Vector2(70, -350), _content, _graphics);

            Shovel shovel = new Shovel(TeamType.A, "GustoMap", new Vector2(200, -330), _content, _graphics);

            shovel.onGround = true;
            Pickaxe pickaxe = new Pickaxe(TeamType.Player, "GustoMap", new Vector2(130, -430), _content, _graphics);

            pickaxe.onGround = true;
            //Pistol pistol = new Pistol(TeamType.A, "GustoMap", new Vector2(250, -300), _content, _graphics);
            //pistol.amountStacked = 1;
            //pistol.onGround = true;
            BaseCannon cannon = new BaseCannon(TeamType.A, "GustoMap", new Vector2(0, -450), _content, _graphics);

            cannon.onGround = true;
            Ballista ballista = new Ballista(TeamType.A, "GustoMap", new Vector2(-120, -550), _content, _graphics);

            ballista.onGround = true;
            CrossBow crossBow = new CrossBow(TeamType.A, "GustoMap", new Vector2(220, -350), _content, _graphics);

            crossBow.amountStacked = 1;
            crossBow.onGround      = true;
            ArrowItem arrows = new ArrowItem(TeamType.A, "GustoMap", new Vector2(210, -340), _content, _graphics);

            arrows.onGround      = true;
            arrows.amountStacked = 10;
            //PistolShotItem pistolAmmo = new PistolShotItem(TeamType.A, "GustoMap", new Vector2(220, -300), _content, _graphics);
            //pistolAmmo.amountStacked = 14;
            //pistolAmmo.onGround = true;
            CannonBallItem cannonAmmo = new CannonBallItem(TeamType.A, "GustoMap", new Vector2(200, -300), _content, _graphics);

            cannonAmmo.amountStacked = 10;
            cannonAmmo.onGround      = true;
            RustyHarpoonItem harpoonAmmo = new RustyHarpoonItem(TeamType.A, "GustoMap", new Vector2(-120, -550), _content, _graphics);

            harpoonAmmo.amountStacked = 10;
            harpoonAmmo.onGround      = true;
            Lantern lantern = new Lantern(TeamType.A, "GustoMap", new Vector2(180, -300), _content, _graphics);

            lantern.onGround = true;
            BasePlank basePlank = new BasePlank(TeamType.A, "GustoMap", new Vector2(150, -300), _content, _graphics);

            basePlank.onGround      = true;
            basePlank.amountStacked = 10;

            // Item utility is global and is accessed in main update, all items that are "dropped" or placed on the world view ground exist in this list (placable, invetory, etc)
            ItemUtility.ItemsToUpdate.Add(lantern);
            ItemUtility.ItemsToUpdate.Add(furnace);
            ItemUtility.ItemsToUpdate.Add(craftingAnvil);
            ItemUtility.ItemsToUpdate.Add(barrelLand);
            ItemUtility.ItemsToUpdate.Add(barrelOcean);
            ItemUtility.ItemsToUpdate.Add(chestLand);
            ItemUtility.ItemsToUpdate.Add(shovel);
            //ItemUtility.ItemsToUpdate.Add(pistol);
            ItemUtility.ItemsToUpdate.Add(cannon);
            ItemUtility.ItemsToUpdate.Add(ballista);
            ItemUtility.ItemsToUpdate.Add(crossBow);
            ItemUtility.ItemsToUpdate.Add(arrows);
            ItemUtility.ItemsToUpdate.Add(pickaxe);
            //ItemUtility.ItemsToUpdate.Add(pistolAmmo);
            ItemUtility.ItemsToUpdate.Add(cannonAmmo);
            ItemUtility.ItemsToUpdate.Add(harpoonAmmo);
            ItemUtility.ItemsToUpdate.Add(basePlank);
            ItemUtility.ItemsToUpdate.Add(campfire);

            UpdateOrder.Add(shortShip);
            UpdateOrder.Add(baseShip);
            UpdateOrder.Add(baseShipAI);
            UpdateOrder.Add(player);
            UpdateOrder.Add(baseTribalLand);
            UpdateOrder.Add(baseCatLand);
            UpdateOrder.Add(chickenLand);
            UpdateOrder.Add(blueBird);
            UpdateOrder.Add(snakeLand);
            UpdateOrder.Add(tower);
            UpdateOrder.Add(teePee);

            // interior set
            BaseTribal baseTribalInShip = new BaseTribal(TeamType.A, "GustoMap", Vector2.Zero, _content, _graphics);

            baseTribalInShip.npcInInterior = baseShipAI.shipInterior;
            baseShipAI.shipInterior.interiorObjects.Add(baseTribalInShip);

            ready = true;
        }