示例#1
0
        public void TestAddItems()
        {
            Inventory.Inventory inventory = new Inventory.Inventory(10);
            Item sword  = new Item("Sword", 3, ItemType.equipment);
            Item potion = new Item("Potion", 2, ItemType.consumable);
            Item map    = new Item("Map", 0, ItemType.key);

            inventory.Add(sword);
            inventory.Add(potion);
            inventory.Add(map);

            Assert.IsNotNull(inventory);
        }
示例#2
0
        public void TestAddItems()
        {
            Inventory.Inventory inventory = new Inventory.Inventory(10);
            Item sword  = new Item("Sword", 3, ItemType.equipment);
            Item potion = new Item("Potion", 2, ItemType.consumable);
            Item map    = new Item("Map", 0, ItemType.key);

            inventory.Add(sword);
            inventory.Add(potion);
            inventory.Add(map);
            Assert.IsTrue(inventory.GetSize() == 3);

            inventory.Remove(potion);
            Assert.IsTrue(inventory.GetSize() == 2);
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing Systems...");

            // Creates an inventory and items
            Console.WriteLine("Initializing Inventory...");
            Inventory.Inventory inventory = new Inventory.Inventory(10);
            Item sword  = new Item("Sword", 3, ItemType.equipment);
            Item potion = new Item("Potion", 2, ItemType.consumable);
            Item map    = new Item("Map", 0, ItemType.key);

            // adds items into inventory
            Console.WriteLine("Filling Inventory...");
            inventory.Add(sword);
            inventory.Add(potion);
            inventory.Add(map);

            Console.WriteLine("Initializing Character Manager");
            Character.Character player;

            // load the character
            player = PersistentData.PersistentData.Deserialize <Character.Character>("player.xml");
            if (player == null)
            {
                Console.WriteLine("No player found, creating new default character");
                player = new Character.Character(100, Races.Elf, Alignments.Neutral);
            }

            CharacterManager characterManager = CharacterManager.Instance;

            characterManager.Player = player;
            Character.Character enemyOne = new Character.Character(50, Races.Orc, Alignments.ChaoticEvil);
            Character.Character enemyTwo = new Character.Character(50, Races.Orc, Alignments.NeutralEvil);
            characterManager.AddEnemy(enemyOne);
            characterManager.AddEnemy(enemyTwo);

            // TODO: create persistent data system

            // save the player
            Console.WriteLine("Saving player");
            PersistentData.PersistentData.Serialize <Character.Character>(player, "character.xml");

            Console.WriteLine("Press return to exit...");
            Console.ReadKey();
        }
示例#4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing Systems...");
            // TODO: create inventory system
            Inventory.Inventory inventory = new Inventory.Inventory(5);

            Item item  = new Item("A", 1, ItemType.consumable);
            Item item2 = new Item("B", 2, ItemType.consumable);
            Item item3 = new Item("C", 3, ItemType.consumable);
            Item item4 = new Item("D", 4, ItemType.consumable);

            inventory.Add(item);
            inventory.Add(item2);
            inventory.Add(item3);
            inventory.Add(item4);

            Console.WriteLine("Initializing Character Manager");
            Character.Character player;

            // load the character
            player = PersistentData.PersistentData.Deserialize <Character.Character>("player.xml");
            if (player == null)
            {
                Console.WriteLine("No player found, creating new default character");
                player = new Character.Character(100, Races.Elf, Alignments.Neutral);
            }

            CharacterManager characterManager = CharacterManager.Instance;

            characterManager.Player = player;
            Character.Character enemyOne = new Character.Character(50, Races.Orc, Alignments.ChaoticEvil, "1", "masculine");
            Character.Character enemyTwo = new Character.Character(50, Races.Orc, Alignments.NeutralEvil, "2", "masculine");
            characterManager.AddEnemy(enemyOne);
            characterManager.AddEnemy(enemyTwo);

            // TODO: create persistent data system

            // save the player
            Console.WriteLine("Saving player");
            PersistentData.PersistentData.Serialize <Character.Character>(player, "character.xml");

            Console.WriteLine("Press return to exit...");
            Console.ReadKey();
        }
示例#5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing Systems...");
            // TODO: create inventory system
            Inventory.Inventory mInv = new Inventory.Inventory(10);
            mInv.Add(new Item("Dai-Ryumyaku Jufuku of Fending", 1, ItemType.equipment));
            mInv.Add(new Item("Max Potion", 1, ItemType.consumable));
            mInv.Add(new Item("Max Ether", 1, ItemType.consumable));
            mInv.Add(new Item("Diamond Sword", 1, ItemType.equipment));
            mInv.Add(new Item("Diamond Shield", 1, ItemType.equipment));
            mInv.Add(new Item("Silvergrace Earrings of Fending", 1, ItemType.equipment));
            mInv.Add(new Item("Aether Compass", 1, ItemType.key));
            mInv.Add(new Item("Empty Dalmascan Wine Bottle", 1, ItemType.key));
            mInv.Add(new Item("Pazuzu Feather", 1, ItemType.key));

            mInv.PrintInventory();

            Console.WriteLine("Initializing Character Manager");
            Character.Character player;

            // load the character
            player = PersistentData.PersistentData.Deserialize <Character.Character>("player.xml");
            if (player == null)
            {
                Console.WriteLine("No player found, creating new default character");
                player = new Character.Character(100, Race.Elf, Alignment.Neutral);
            }


            CharacterManager characterManager = CharacterManager.Instance;

            characterManager.Player = player;
            Character.Character enemyOne = new Character.Character(50, Race.Orc, Alignment.ChaoticEvil);
            Character.Character enemyTwo = new Character.Character(50, Race.Orc, Alignment.NeutralEvil);
            characterManager.AddEnemy(enemyOne);
            characterManager.AddEnemy(enemyTwo);


            // TODO: create persistent data system

            // save the player
            Console.WriteLine("Saving players and Enemys");
            PersistentData.PersistentData.Serialize <CharacterManager>(characterManager, "character.xml");


            Console.WriteLine("Press return to exit...");
            Console.ReadKey();
        }
示例#6
0
        IEnumerator TraceTarget()
        {
            RaycastHit2D[] hits      = new RaycastHit2D[10];
            int            count     = 0;
            Inventory      inventory = null;

            do
            {
                count     = Physics2D.CircleCastNonAlloc(transform.position, TraceRadius, Vector2.zero, hits, 0, 1 << 11);
                inventory = hits.Take(count)
                            .Select(hit => hit.rigidbody?.GetComponent <GameEntity>()?.GetEntityComponent <Inventory>())
                            .Where(t => t && t.AutoPickup)
                            .FirstOrDefault();
                yield return(null);
            }while (!inventory);

            /*var movement = GetComponent<SimpleMovement>();
             * movement.Velocity = PickupVelocity;
             * movement.StartMovement();*/
            GetComponent <Rigidbody2D>().velocity = PickupVelocity;
            while (true)
            {
                var bodyCenter = inventory.Entity.transform.localToWorldMatrix.MultiplyPoint(inventory.Entity.GetComponent <Rigidbody2D>().centerOfMass);
                Debug.DrawLine(bodyCenter, transform.position);
                GetComponent <Rigidbody2D>().AddForce((inventory.Entity.transform.position - transform.position).normalized * Acceleration, ForceMode2D.Force);
                //movement.Acceleration = (inventory.Entity.transform.position - transform.position).normalized * Acceleration;
                if ((bodyCenter.ToVector2() - transform.position.ToVector2()).magnitude <= inventory.PickupDistance)
                {
                    inventory.Add(Item);
                    inventory.Entity.GetComponent <AudioController>().PlayEffect(Item.PickupSoundEffect);
                    inventory.Entity.EventBus.Dispatch(EventPickup, Item);
                    break;
                }
                yield return(null);
            }

            Destroy(gameObject);
        }