コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            mySquad  = new ClassSquad("TestNewSquad", "KaiLiu", CaptainSpec.Forest, true, CaptainSpec.Water, HeroSpec.Curses);
            NPCSquad = new ClassSquad();

            listBox1.Items.Add("Add a squad " + mySquad.name);
            listBox1.Items.Add("Add a squad " + NPCSquad.name);

            store = new ClassGameStore();
            listBox1.Items.Add("Add a gamestore have " + store.soldierList.Count.ToString() + " soldiers and " + store.stashList.Count.ToString() + " items.");

            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", count of roster: " + mySquad.rosterList.Count.ToString());
            mySquad.BuyRosterMember(store, 5);
            listBox1.Items.Add("Buy a member to roster");

            mySquad.BuyRosterMember(store, 5);
            listBox1.Items.Add("Buy a member to roster");

            mySquad.BuyRosterMember(store, 5);
            listBox1.Items.Add("Buy a member to roster");

            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have roster:  " + mySquad.rosterList.Count.ToString());

            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());
            mySquad.BuyStashItem(store, 5);
            listBox1.Items.Add("Buy an item to stash");
            mySquad.BuyStashItem(store, 5);
            listBox1.Items.Add("Buy an item to stash");
            mySquad.BuyStashItem(store, 5);
            listBox1.Items.Add("Buy an item to stash");
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());

            mySquad.AddItemToCaptain(1);
            listBox1.Items.Add("Add an item to Captain, now the captain have items:" + (mySquad.captain.equipList.Count + mySquad.captain.weaponList.Count).ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());

            mySquad.AddItemToCaptain(0);
            listBox1.Items.Add("Add an item to Captain, now captain have items: " + (mySquad.captain.equipList.Count + mySquad.captain.weaponList.Count).ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have stash items " + mySquad.stashList.Count.ToString());

            mySquad.AddSquadMember(0);
            listBox1.Items.Add("Add an item to squad, now have members:" + mySquad.memberList.Count.ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have roster:  " + mySquad.rosterList.Count.ToString());

            mySquad.AddSquadMember(0);
            listBox1.Items.Add("Add an item to squad, now have members:" + mySquad.memberList.Count.ToString());
            listBox1.Items.Add("Have credit " + mySquad.credit.ToString() + ", have roster:  " + mySquad.rosterList.Count.ToString());
        }
コード例 #2
0
 //To be done
 public int SendBattleCreate(ClassSquad squad)
 {
     try
     {
         if (netStats)
         {
             ;
         }
         return(1);
     }
     catch (Exception ex)
     {
         err = ex.ToString();
         return(0);
     }
 }
コード例 #3
0
        //Init this class by inputed parameters
        public ClassBattle(ClassSquad host, bool online, ClassNetwork net)
        {
            hostSide     = host;
            isOnline     = online;
            battleStats  = BattleStats.prebattle;
            hostMapList  = new List <BattleMapNode>();
            guestMapList = new List <BattleMapNode>();

            if (online)
            {
                if (net == null || !net.netStats)
                {
                    throw new Exception("Network is not ready.");
                }
                network = net;
                int result = network.SendBattleCreate(hostSide);
                if (result <= 0)
                {
                    throw new Exception("Create online battle faied.");
                }
            }
            else
            {
                foreach (ClassSoldier soldier in hostSide.memberList)
                {
                    Random        rd     = new Random();
                    int           result = rd.Next(0, 999);
                    BattleMapNode node;
                    node.posX    = 0;
                    node.posY    = result;
                    node.soldier = soldier;
                    hostMapList.Add(node);
                }
                guestSide = new ClassSquad();
                foreach (ClassSoldier gSoldier in guestSide.memberList)
                {
                    Random        rd     = new Random();
                    int           result = rd.Next(0, 999);
                    BattleMapNode node;
                    node.posX    = 999;
                    node.posY    = result;
                    node.soldier = gSoldier;
                    guestMapList.Add(node);
                }
            }
        }