예제 #1
0
        public Attack(string token)
        {
            // Set the form location so that there wont be any overlap with the building form
            Left = 310;
            Top  = 25;
            InitializeComponent();

            // Set the synchronizing object to get trigger events within the main thread.
            // Important if you're using Windows Forms
            _taskScheduler = new TaskScheduler {
                SynchronizingObject = this
            };

            // Restore data from storage
            RestoreData();

            // Army list will display according to the added items name property
            ArmyList.DisplayMember = "Name";

            // Create an instance for farm actions
            _command = new FarmActions(token);

            _isOn = false; // set the sate as off

            // set the tray icon
            var trayIcon = new NotifyIcon
            {
                Text = "My application",
                Icon = new Icon("Attack.ico")
            };

            // Add menu to tray icon and show it.
            var cm = new ContextMenu();

            cm.MenuItems.Add("Show", OnShow);
            cm.MenuItems.Add("Exit", OnExit);

            trayIcon.ContextMenu = cm;

            trayIcon.Visible = true;
        }
예제 #2
0
        private static void Attack(string token, string[] args)
        {
            var armyInfo = new int[10];

            var command = new FarmActions(token);

            var coordinates = new int[2];

            coordinates[X] = int.Parse(args[1]);
            coordinates[Y] = int.Parse(args[2]);

            for (var i = 3; i < args.Length; i++)
            {
                armyInfo[i - 3] = int.Parse(args[i]);
            }

            var army = new ArmyBuilder(armyInfo);

            command.Attack(coordinates[X], coordinates[Y], army);

            Console.WriteLine("Attack is made to " + coordinates[X] + "," + coordinates[Y]);
            Console.ReadKey();
        }
 void Start()
 {
     _farmAction = this.gameObject.GetComponentInParent <FarmActions> ();
     b           = this.gameObject.GetComponentInChildren <Button> ();
 }