Exemplo n.º 1
0
        public static Player DefaultPlayer()
        {
            Player defPlayer = new Player(100, 100, "PlayerName", Swords.WoodenSword()); //Replace playername with string to set Playername

            defPlayer.ListOfInventory.Add(Swords.WoodenSword());
            return(defPlayer);
        }
Exemplo n.º 2
0
    void Start()
    {
        inventory = Swords.instance;
        inventory.onItemChanhgedCallback += UpdateUI;

        slots = itemsParent.GetComponentsInChildren <ShopSlot>();
    }
Exemplo n.º 3
0
 public void Awake()
 {
     if (instance != null)
     {
         Debug.LogWarning("More than one instance of Inventory found!");
         return;
     }
     instance = this;
 }
Exemplo n.º 4
0
        public void CountDuplicatesTest_GiveDuplicatesAndSingleItems_WillPrintThemGrouped()
        {
            Swords testSword = new Swords();

            testSword.Name  = "testSword";
            testSword.Price = 5;
            Shields testShield = new Shields();

            testShield.Name  = "testShield";
            testShield.Price = 10;
            Consumables testConsumable = new Consumables();

            testConsumable.Name  = "testConsumable";
            testConsumable.Price = 15;
            Potions testPotion = new Potions();

            testPotion.Name  = "testPotion";
            testPotion.Price = 20;
            Masks testMask = new Masks();

            testMask.Name  = "testMask";
            testMask.Price = 25;

            List <Product> testCart = new List <Product>();

            for (int i = 0; i < 5; i++)
            {
                testCart.Add(testSword);
            }

            for (int i = 0; i < 132; i++)
            {
                testCart.Add(testShield);
            }

            testCart.Add(testConsumable);

            for (int i = 0; i < 45; i++)
            {
                testCart.Add(testPotion);
            }

            for (int i = 0; i < 98; i++)
            {
                testCart.Add(testMask);
            }

            string expected = "testSword x 5 - - - 25 Rupees\n\ntestShield x 132 - - - 1320 Rupees\n\ntestConsumable" +
                              " x 1 - - - 15 Rupees\n\ntestPotion x 45 - - - 900 Rupees\n\ntestMask x 98 - - - 2450 Rupees\n\n";

            string itemizerTest = Itemizer.CountDuplicates(testCart);

            Assert.AreEqual(expected, itemizerTest);
        }
Exemplo n.º 5
0
        public void GetTotalTest_GiveRandomPricedProducts_WillPrintTheTotalPrice()
        {
            Swords testSword = new Swords();

            testSword.Name  = "testSword";
            testSword.Price = 5;
            Shields testShield = new Shields();

            testShield.Name  = "testShield";
            testShield.Price = 10;
            Consumables testConsumable = new Consumables();

            testConsumable.Name  = "testConsumable";
            testConsumable.Price = 15;
            Potions testPotion = new Potions();

            testPotion.Name  = "testPotion";
            testPotion.Price = 20;
            Masks testMask = new Masks();

            testMask.Name  = "testMask";
            testMask.Price = 25;

            List <Product> testCart = new List <Product>();

            for (int i = 0; i < 5; i++)
            {
                testCart.Add(testSword);
            }

            for (int i = 0; i < 132; i++)
            {
                testCart.Add(testShield);
            }

            testCart.Add(testConsumable);

            for (int i = 0; i < 45; i++)
            {
                testCart.Add(testPotion);
            }

            for (int i = 0; i < 98; i++)
            {
                testCart.Add(testMask);
            }

            int actual = Itemizer.GetTotal(testCart);

            Assert.AreEqual(4710, actual);
        }
Exemplo n.º 6
0
        protected override void RealTestOutPut()
        {
            Array swords = new Sword[5];

            for (int i = 0; i < 5; i++)
            {
                swords.SetValue(new Sword(i, "tac"), i);
            }

            Swords s = new Swords(swords);

            foreach (var item in s)
            {
                println(item.ToString());
            }
        }
        private void btnAgregarEspada_Click(object sender, RoutedEventArgs e)
        {
            Swords swo = new Swords();

            swo.NombreArma           = txtNomEsp.Text;
            swo.CantidadArma         = int.Parse(txtCantEsp.Text);
            swo.FechaCreacion        = (DateTime)DPCreEsp.SelectedDate;
            swo.Precio               = int.Parse(txtPreExp.Text);
            swo.TipoEspada           = (Espadas)CBXTipoEsp.SelectedItem;
            swo.FechaCheckeoArmas    = (DateTime)DPFecRepEsp.SelectedDate;
            swo.CantidadReparaciones = int.Parse(txtRepEsp.Text);
            swo.CalcularEfectividadReparacion();

            col.Add(swo);

            DGEsp.ItemsSource = col.ListaEsp();
        }
Exemplo n.º 8
0
    private void LoadFromJson()
    {
        for (int i = 0; i < swordsInt.Length; i++)
        {
            var jsonPath   = Application.dataPath + "/StreamingAssets/S" + (i + 1).ToString() + ".dt";
            var jsonString = Coder.EncodeDecrypt(File.ReadAllText(jsonPath));
            Swords.Add(JsonUtility.FromJson <WeaponItem>(jsonString));
            Swords[i].sprite = Resources.LoadAll <Sprite>("Swords")[swordsInt[i]];
        }

        for (int i = 0; i < 6; i++)
        {
            var jsonPath   = Application.dataPath + "/StreamingAssets/A" + (i + 1).ToString() + ".dt";
            var jsonString = Coder.EncodeDecrypt(File.ReadAllText(jsonPath));
            Armors.Add(JsonUtility.FromJson <ArmorItem>(jsonString));
            Armors[i].sprite = Resources.Load <Sprite>($"Armor/{(i + 1).ToString()}");
        }
    }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            try
            {
                CollecionArmas col = new CollecionArmas();
                Axes           axe = new Axes();
                axe.NombreArma           = "Deicide";
                axe.CantidadArma         = 2;
                axe.FechaCreacion        = new DateTime(2016, 8, 21);
                axe.Precio               = 8000;
                axe.TipoHacha            = Hachas.GreatHammer;
                axe.FechaCheckeoArmas    = new DateTime(2018, 9, 6);
                axe.CantidadReparaciones = 2;
                axe.CalcularEfectividadReparacion();

                Swords swordie = new Swords();
                swordie.NombreArma           = "Fenrir";
                swordie.CantidadArma         = 1;
                swordie.FechaCreacion        = new DateTime(2015, 12, 5);
                swordie.Precio               = 5000;
                swordie.TipoEspada           = Espadas.KeyBlade;
                swordie.FechaCheckeoArmas    = new DateTime(2017, 6, 25);
                swordie.CantidadReparaciones = 5;
                swordie.CalcularEfectividadReparacion();

                col.Add(swordie);
                col.Add(axe);
                Console.WriteLine(col.Imprimir());


                Console.ReadKey();
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine("Error :", ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error", ex);
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            Logger.Instance().Info("Program started");

            CharacterFactory CharFactory = new CharacterFactory();
            Spell            blind       = new Spell("Blind", 15, 3, "Blinds only near objects, with big amount of damage", new Blind());
            Spell            knockout    = new Spell("knockout", 2, 8, "Knockout created", new Knockout());

            EnemyRobotAdapter ERobot = new EnemyRobotAdapter(new EnemyRobot(25, 25, 50, 7, new Tuple <int, int>(13, 1)));
            ICommand          ERobot_command_fire    = new CommandFireAtEnemy((IEnemy)ERobot);
            ICommand          ERobot_command_forward = new CommandForwardToEnemy((IEnemy)ERobot);
            ICommand          ERobot_command_retreat = new CommandRetreat((IEnemy)ERobot);

            ERobot_command_forward.execute();
            ERobot_command_fire.execute();
            ERobot_command_retreat.execute();
            ERobot_command_retreat.undo();


            myCharacter = CharFactory.CreateCharacter(2, "Elfas112");

            IObserver achObserver = new AchievementObserver();
            IObserver queObserver = new QuestObserver();

            myCharacter.Subscribe(achObserver);
            myCharacter.Subscribe(queObserver);

            if (myCharacter != null)
            {
                myCharacter.Notify("EVENT_CHARACTER_CREATION"); switch (myCharacter.GetType().ToString())
                {
                case "Zaidimukas.Character.HumanCharacter": myCharacter.Notify("QUEST_BECOME_HUMAN"); break;

                case "Zaidimukas.Character.ElfCharacter": myCharacter.Notify("QUEST_BECOME_ELF"); break;

                case "Zaidimukas.Character.DwarfCharacter": myCharacter.Notify("QUEST_BECOME_DWARF");
                    break;
                }
                myCharacter.Walk(1);
                myCharacter.CastSpell(blind);
                myCharacter.Walk(1);
                myCharacter.Walk(2);
                myCharacter.Walk(3);
                myCharacter.Walk(1);
                myCharacter.CastSpell(knockout);
                myCharacter.Walk(4);
                ArmorUnit arm  = new ArmorUnit("Shirts", 4);
                Armor     arm1 = new Gloves(new BasicArmor(arm));
                myCharacter.SetArmor(arm1);
                Console.WriteLine(myCharacter.ArmorDecorator.getArmors().ToString());
                arm1 = new Gloves(arm1);



                //myCharacter.SetArmor(arm1);
                //Console.WriteLine(myCharacter.ArmorDecorator.getArmors().ToString());

                //arm1 = new Helmet(arm1);



                //myCharacter.SetArmor(arm1);
                //Console.WriteLine(myCharacter.ArmorDecorator.getArmors().ToString());
            }
            // state

            myCharacter.AttackInState();
            myCharacter.changeState(myCharacter.blindedState, 3000);
            myCharacter.AttackInState();
            myCharacter.CastSpellInState(blind);
            myCharacter.WalkInState(3);
            myCharacter.changeState(myCharacter.normalState, 3000);
            myCharacter.WalkInState(4);

            // composite
            MyCharacter elf = CharFactory.CreateCharacter(2, "Elf");

            myCharacter.printGoldAndName();
            MyCharacter humanChar  = CharFactory.CreateCharacter(3, "Human");
            MyCharacter humanChar2 = CharFactory.CreateCharacter(3, "Human2");
            MyCharacter humanChar3 = CharFactory.CreateCharacter(2, "Human3");

            int goldForKill = 3000;

            Console.WriteLine($"You have gained {goldForKill} coins!");
            IComponent elfComp         = elf;
            IComponent humanCharComp   = humanChar;
            IComponent myCharacterComp = myCharacter;
            IComponent humanChar2Comp  = humanChar2;
            IComponent humanChar3Comp  = humanChar3;

            IComponent party = new Team
            {
                name    = "Best party ever",
                players =
                {
                    elfComp,
                    humanCharComp,
                    humanChar2Comp,
                    humanChar3Comp
                }
            };
            IComponent teams = new Team
            {
                players = { party, myCharacter }
            };

            Logger.Instance().Info("Team");
            teams.addGold(goldForKill);
            teams.printGoldAndName();
            // chain of responsibility
            myCharacter.GetRank();
            myCharacter.LevelUp();
            myCharacter.GetRank();
            myCharacter.LevelUp();

            myCharacter.GetRank();
            myCharacter.LevelDown();
            myCharacter.GetRank();
            //null object

            ICommandFactory commandFactory = new ICommandFactory();
            EnemyHuman      EHuman         = new EnemyHuman(50, 100, 1000, 1, new Tuple <int, int>(15, 5));
            IEnemy          enemyHuman     = new EnemyHumanAdapter(EHuman);
            ICommand        retreatCommand = commandFactory.CreateCommand(enemyHuman, 3);
            ICommand        nullCommand    = commandFactory.CreateCommand(enemyHuman, 1123464);

            //visitor

            EnemyHuman tank = new EnemyHuman(2, 2, 2, 2, new Tuple <int, int>(2, 1));
            ExperienceWorthCalculator normalGain  = new NormalExperienceGain();
            ExperienceWorthCalculator boostedGain = new BoostedExperienceGain();

            Console.WriteLine($"Without exp boost enemy is worth: {tank.GetExp(normalGain)} exp");
            Console.WriteLine($"With exp boost enemy is worth: {tank.GetExp(boostedGain)} exp");

            //mediator

            Tracker m = new Tracker();

            Notification c1 = new Notification(m);
            Achievement  c2 = new Achievement(m);

            m.not = c1;
            m.ach = c2;

            c1.Send("10 seconds Have passed");
            c2.Send("Achievement Uncloked: Time flies");

            //template

            Sword sword = new Sword(1, 5, "long Sword");

            sword.SelectWeapon();

            Knife knife = new Knife(1, 4, "Fast Knife");

            knife.SelectWeapon();

            //iterator

            KnifeList kl = new KnifeList();

            kl.AddKnife(knife);
            kl.AddKnife(1, 9, "Dagger");
            var a1 = kl.GetEnumerator();

            a1.MoveNext();
            var g = a1.Current;

            Swords sws = new Swords();

            sws.Add(sword);
            sws.Add(new Sword(1, 9, "test"));
            var test = sws.GetEnumerator();

            test.MoveNext();

            //MEMENTO
            org = new Originator(myCharacter, null);


            var list = new IEnemy[] {
                (IEnemy)ERobot
            };

            saveState(list);
            Console.Write("");

            Console.Write("charaacter before update");
            myCharacter.CharacterToString();

            myCharacter.Walk(1);
            myCharacter.Walk(1);
            myCharacter.healthPoints = 4;
            Console.Write("charaacter After update");
            myCharacter.CharacterToString();

            Console.Write("charaacter Restored");
            restoreState();
            myCharacter.CharacterToString();

            Logger.Instance().Info("Program ended");
            myCharacter.Unsubscribe(achObserver);
            myCharacter.Unsubscribe(queObserver);
        }
Exemplo n.º 11
0
 public void SetEquipedSword(int e)
 {
     equiped = swords[e];
 }
Exemplo n.º 12
0
 private void Start()
 {
     equiped = swords[equipedSword];
 }
Exemplo n.º 13
0
 public void StartWep()
 {
     CurrentWeapon = Swords.WoodenSword();
 }