Ejemplo n.º 1
0
        private void btnGetTarget_Click(object sender, System.EventArgs e)
        {
            if (cbxPatrolAreas.SelectedIndex == -1)
            {
                MessageBox.Show("Please select the Patrol Area first.", "Add Target Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (_ak.TargetObject == null)
            {
                MessageBox.Show("Target something in the game first.", "Add Target Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string targetName = _ak.TargetObject.Name;

            PatrolArea patrolarea = _patrolareas.GetPatrolArea(cbxPatrolAreas.SelectedItem.ToString());

            lbxTargets.Items.Add(targetName);
            patrolarea.AddTarget(targetName);
        }
Ejemplo n.º 2
0
        private void btnTargetDelete_Click(object sender, System.EventArgs e)
        {
            if (cbxPatrolAreas.SelectedIndex == -1)
            {
                MessageBox.Show("Please select the Patrol Area first.", "Add Target Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            PatrolArea patrolarea = _patrolareas.GetPatrolArea(cbxPatrolAreas.SelectedItem.ToString());

            //remove the highlighted items
            while (lbxTargets.SelectedIndices.Count > 0)
            {
                lbxTargets.Items.RemoveAt(lbxTargets.SelectedIndices[0]);
            }

            //rebuild our patrolarea targets array
            patrolarea.ClearTargets();
            foreach (string target in lbxTargets.Items)
            {
                patrolarea.AddTarget(target);
            }
        }