Esempio n. 1
0
        static void Main(string[] args)
        {
            Creator creator = new UnitCreator();

            List <IUnit> characters = new List <IUnit>();

            characters.Add(creator.CreateUnit(UnitType.Fighter, 2));
            characters.Add(creator.CreateUnit(UnitType.Archer, 5));
            characters.Add(creator.CreateUnit(UnitType.Mage, 8));
            characters.Add(creator.CreateUnit(UnitType.Archer, 4));
            characters.Add(creator.CreateUnit(UnitType.Fighter, 6));


            foreach (var c in characters)
            {
                Console.WriteLine(c.SaySomething());
            }

            foreach (var c in characters)
            {
                Console.WriteLine(c.ShowDetails());
            }

            Console.ReadKey();
        }
Esempio n. 2
0
    void ProcessMarbles()
    {
        SetMatrix();
        InputMatrix();
        CompareMatrixes();
        Debug.Log("type " + type);
        int n = 0;

        for (int i = 0; i < 5; i++)
        {
            if (hits[i] != null)
            {
                n++;
                hits[i].GetComponent <SpriteRenderer>().enabled = false;
                //hits[i] = null;
            }
        }
        if (n == 4)
        {
            if (type < 4)
            {
                int m = 0;
                for (int i = 0; i < 5; i++)
                {
                    if (hits[i] != null)
                    {
                        Collider2D[] marbleBuffer = new Collider2D[2];
                        marbleBuffer = Physics2D.OverlapBoxAll(hits[i].position, new Vector2(0.8f, 0.8f), 0, marbleLayerMask);
                        if (marbleBuffer[0] != null)
                        {
                            while (marbles[m] != null)
                            {
                                m++;
                            }
                            marbles[m] = marbleBuffer[0];
                        }
                    }
                }
                if (marbles[0] != null && marbles[1] != null && marbles[2] != null && marbles[3] != null)
                {
                    ConsumeMarbles();
                    unitCreator.CreateUnit(type, colors);
                }
            }
        }
        Sparkle();
        Initialize();
        SetMatrix();
    }
        public void Simple()
        {
            var producing = UnitCreator.CreateUnit("simple producing unit");

            State.AddUnit(producing, new Vector2(0, 0));

            Engine.ProduceUnit(producing, "simple combat unit");
            FullUpdate();

            var expected = State.Units.FirstOrDefault(u => u.GetType() == typeof(SimpleCombatUnit));

            Assert.NotNull(expected);
            Assert.AreEqual(expected.Id, 1); // но это необязательно
            Assert.AreEqual(expected.Position, new Vector2(1, 1));
        }