Exemplo n.º 1
0
        public override Card spawnCard()
        {
            string methodName = name, callMethodName = "";

            for (int i = 0; i < methodName.Length; ++i)
            {
                if (alphabet.IndexOf(methodName[i]) >= 0)
                {
                    callMethodName += methodName[i];
                }
            }
            SpawnSpecial spun = new SpawnSpecial();
            PropertyInfo m    = spun.GetType().GetProperty(callMethodName);

            return(m.GetMethod.Invoke(spun, null) as Special);
        }
Exemplo n.º 2
0
        public static List <Card> invokeAllCards()
        {
            SpawnUnit    su = new SpawnUnit();
            SpawnSpecial ss = new SpawnSpecial();
            SpawnLeader  sl = new SpawnLeader();

            List <Type> tps = new List <Type>()
            {
                su.GetType(), ss.GetType(), sl.GetType()
            };
            List <Card> allCardsInGame = new List <Card>();
            int         tIndex         = 0;

            foreach (Type t in tps)
            {
                ++tIndex;
                foreach (var m in t.GetMethods())
                {
                    try
                    {
                        Card c = null;
                        if (tIndex == 1)
                        {
                            c = m.Invoke(su, null) as Card;
                        }
                        if (tIndex == 2)
                        {
                            c = m.Invoke(ss, null) as Card;
                        }
                        if (tIndex == 3)
                        {
                            c = m.Invoke(sl, null) as Card;
                        }
                        if (c != null)
                        {
                            allCardsInGame.Add(c);
                        }
                    }
                    catch (Exception e) { }
                }
            }
            return(allCardsInGame);
        }