예제 #1
0
 public override string Update(Buster buster)
 {
     // BUST id
     return("BUST " + buster.GhostInRange.EntityId.ToString());
 }
예제 #2
0
 public override void Enter(Buster buster)
 {
 }
 public void Attack(Buster b)
 {
     Attackers.Add(b);
     Stamina = Math.Max(0, Stamina - 1);
 }
예제 #4
0
 public void Initialize()
 {
     buster = new Buster(1, new Point(0, 0), 1, State.Idle, -1);
 }
예제 #5
0
        /// <summary>
        /// Enumerate all devices and optionally uninstall ghosted ones.
        /// </summary>
        ///
        /// <param name="RemoveGhosts">   true if ghosted devices should be uninstalled. </param>
        /// <param name="HideUnfiltered"> true to hide, false to show the unfiltered. </param>
        private void Enumerate(Boolean RemoveGhosts, Boolean HideUnfiltered = false)
        {
            using (new WaitCursor())
            {
                toolStripStatusLabel1.Text = String.Empty;
                toolStripStatusLabel2.Text = String.Empty;
                toolStripStatusLabel3.Text = String.Empty;
                toolStripStatusLabel4.Text = String.Empty;

                //! Add a Overlay here?
                Buster.Enumerate();

                Enabled = false;

                StringBuilder sb = new StringBuilder();

                toolStripProgressBar1.Value = 0;

                ReColorDevices(true);

                Int32 fndx = -1;

                try
                {
                    listView1.BeginUpdate();

                    listView1.Items.Clear();
                    listView1.Groups.Clear();

                    using (IniFile ini = new IniFile(Buster.IniFileName))
                    {
                        foreach (HwEntry he in Buster.HwEntries)
                        {
                            //Use Insert instead of Add...
                            ListViewItem lvi = listView1.Items.Add(he.Description);
                            for (int j = 1; j < listView1.Columns.Count; j++)
                            {
                                lvi.SubItems.Add("");
                            }

                            if (he.Properties.ContainsKey(SPDRP.MFG.ToString()))
                            {
                                lvi.SubItems[(int)LVC.ManuCol].Text = he.Properties[SPDRP.MFG.ToString()];
                            }



                            foreach (ListViewGroup lvg in listView1.Groups)
                            {
                                if (lvg.Name == he.DeviceClass)
                                {
                                    lvg.Items.Add(lvi);
                                    break;
                                }
                            }

                            if (lvi.Group == null)
                            {
                                //Use Insert instead of Add...
                                foreach (ListViewGroup lvg in listView1.Groups)
                                {
                                    if (String.Compare(lvg.Name, he.DeviceClass, true) >= 0)
                                    {
                                        Int32 ndx = listView1.Groups.IndexOf(lvg);
                                        listView1.Groups.Insert(ndx, new ListViewGroup(he.DeviceClass, String.IsNullOrEmpty(he.DeviceClass) ? "<No device class specified>" : he.DeviceClass));
                                        listView1.Groups[ndx].Items.Add(lvi);

                                        break;
                                    }
                                }
                            }

                            if (lvi.Group == null)
                            {
                                Int32 ndx = listView1.Groups.Add(new ListViewGroup(he.DeviceClass, he.DeviceClass));
                                listView1.Groups[ndx].Items.Add(lvi);
                            }

                            lvi.SubItems[(int)LVC.StatusCol].Text      = he.DeviceStatus;
                            lvi.SubItems[(int)LVC.DescriptionCol].Text = he.FriendlyName;

                            lvi.Tag = he;

                            if (RemoveGhosts && he.RemoveDevice_IF_Ghosted_AND_Marked())
                            {
                                lvi.SubItems[(int)LVC.StatusCol].Text = "REMOVED";

                                fndx = lvi.Index;

                                if (toolStripProgressBar1.Value < toolStripProgressBar1.Maximum)
                                {
                                    toolStripProgressBar1.Increment(1);
                                }

                                statusStrip1.Invalidate();
                                Application.DoEvents();
                            }

                            Application.DoEvents();
                        }
                    }
                }
                finally
                {
                    Enabled = true;
                }

                listView1.Columns[(int)LVC.DeviceCol].Width      = -1;
                listView1.Columns[(int)LVC.StatusCol].Width      = -1;
                listView1.Columns[(int)LVC.DescriptionCol].Width = -1;

                listView1.EndUpdate();

                if (fndx != -1)
                {
                    listView1.EnsureVisible(fndx);
                }

                ReColorDevices(false);

                //Remove all devices with just Ok/Service and No Match
                if (HideUnfiltered)
                {
                    for (Int32 i = listView1.Items.Count - 1; i >= 0; i--)
                    {
                        if ((listView1.Items[i].SubItems[(int)LVC.StatusCol].Text.Equals("Ok") ||
                             listView1.Items[i].SubItems[(int)LVC.StatusCol].Text.Equals("Service")) &&
                            String.IsNullOrEmpty(listView1.Items[i].SubItems[(int)LVC.MatchTypeCol].Text))
                        {
                            listView1.Items.RemoveAt(i);
                        }
                    }
                }

                ReColorDevices(false);

                if (RemoveGhosts && toolStripProgressBar1.Value != 0)
                {
                    toolStripProgressBar1.Value = toolStripProgressBar1.Maximum;
                }

                //foreach (ListViewGroup lvg in listView1.Groups)
                //{
                //    if (String.IsNullOrEmpty(lvg.Header))
                //    {
                //        lvg.Header = "<No Class Specified>";
                //    }
                //}
            }
        }
예제 #6
0
 public EmptyState(Buster buster) : base(buster)
 {
 }
 public override string Update(Buster buster)
 {
     return("RELEASE");
 }
예제 #8
0
 public virtual void ComputeInformations(Buster buster)
 {
 }
예제 #9
0
 private void Start()
 {
     this.GetAnimalSettings();
     this.animator       = GetComponent <Animator>();
     this.AutoPoopBuster = this.Animal.Busters.Find(x => x.Name == "Auto Poop");
 }
예제 #10
0
 public void UpgradeBuster(Buster buster)
 {
     // TODO: upgrade buster
 }
예제 #11
0
    static void Main(string[] args)
    {
        int bustersPerPlayer = int.Parse(Console.ReadLine()); // the amount of busters you control
        int ghostCount       = int.Parse(Console.ReadLine()); // the amount of ghosts on the map
        int myTeamId         = int.Parse(Console.ReadLine()); // if this is 0, your base is on the top left of the map, if it is one, on the bottom right

        List <Buster> friends = new List <Buster>();
        //List<Buster> enemies = new List<Buster>();

        List <Ghost> ghosts = new List <Ghost>();
        List <Point> bases  = new List <Point>();

        bases.Add(new Point(0, 0));
        bases.Add(new Point(16000, 9000));

        Buster.Generator = new Random();

        //game loop
        while (true)
        {
            int entities = int.Parse(Console.ReadLine()); // the number of busters and ghosts visible to you
            Console.Error.WriteLine(entities);
            for (int i = 0; i < entities; i++)
            {
                string[] inputs = Console.ReadLine().Split(' ');

                int   entityId   = int.Parse(inputs[0]); // buster id or ghost id
                int   x          = int.Parse(inputs[1]);
                int   y          = int.Parse(inputs[2]); // position of this buster / ghost
                int   entityType = int.Parse(inputs[3]); // the team id if it is a buster, -1 if it is a ghost.
                int   state      = int.Parse(inputs[4]); // For busters: 0=idle, 1=carrying a ghost.
                int   value      = int.Parse(inputs[5]); // For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost.
                Point position   = new Point(x, y);
                Console.Error.WriteLine(i + ": entityId " + entityId + " Point: " + position + " entityType: " + entityType + " state: " + state + " value: " + value);
                if (entityType == myTeamId)
                {
                    if (friends.Count < bustersPerPlayer)
                    {
                        friends.Add(new Buster(position, entityId, "Friend"));
                        continue;
                    }

                    Buster buster = friends[entityId % bustersPerPlayer];
                    buster.Position = position;

                    bool isCarrying = (state == 0 ? false : true);
                    buster.IsCarrying = isCarrying;
                    if (isCarrying)
                    {
                        foreach (var ghost in ghosts)
                        {
                            if (ghost.Id == value)
                            {
                                buster.GhostCarryied = ghost;
                                ghosts.Remove(ghost);
                                break;
                            }
                        }
                    }
                }
                else if (entityType == -1)
                {
                    Ghost ghost    = new Ghost(position, entityId, value);
                    bool  isInList = false;
                    foreach (var g in ghosts)
                    {
                        if (g.Equals(ghost))
                        {
                            isInList = true;
                            ghost    = g;
                            break;
                        }
                    }
                    if (!isInList)
                    {
                        ghosts.Add(ghost);
                    }

                    ghost.Position        = position;
                    ghost.NumberOfBusters = value;
                }
            }

            try
            {
                foreach (var ghost in ghosts)
                {
                    if (ghost.Timer == 0)
                    {
                        ghosts.Remove(ghost); //removing old ghosts
                    }
                    ghost.Timer--;
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
            }

            foreach (var buster in friends)
            {
                // Write an action using Console.WriteLine()
                // To debug: Console.Error.WriteLine("Debug messages...");

                // MOVE x y | BUST id | RELEASE

                if (!buster.IsCarrying) //if buster if not carrying a ghost
                {
                    if (ghosts.Count == 0)
                    {
                        buster.Explore();
                    }
                    else
                    {
                        bool ghostNear = false;
                        foreach (var ghost in ghosts)
                        {
                            if (Point.Distance(buster.Position, ghost.Position) <= 2200)
                            {
                                ghostNear = true;
                                buster.Bust(ghost);
                                break;
                            }
                        }

                        if (!ghostNear)
                        {
                            buster.Explore();
                        }
                    }
                }
                else if (Point.Distance(buster.Position, bases[myTeamId]) <= 1600) //if on release distance
                {
                    buster.Release();
                }
                else //going to base
                {
                    buster.MoveTo(bases[myTeamId]);
                }
            }
        }
    }
예제 #12
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //! Add Support for CommandLine Options:
            //!
            //! /Remove
            //! /Register (Task)
            //! /Unregister (Task)
            //! IniFile
            //!

            //! Start logging to TaskManager Log, EventLog and Debug Console.

            switch (Environment.GetCommandLineArgs().Length)
            {
            case 3:
                if (Buster.IsAdmin())
                {
                    if (Environment.GetCommandLineArgs()[1].ToUpper().Equals("/NOGUI"))
                    {
                        String fn = Environment.ExpandEnvironmentVariables(Environment.GetCommandLineArgs()[2]);

                        if (File.Exists(fn) && fn.ToUpper().EndsWith(".INI"))
                        {
                            using (Buster buster = new Buster(fn))
                            {
                                Buster.Enumerate();

                                Buster.WriteToEventLog(String.Format("Found {0} Device(s)", Buster.HwEntries.Count), EventLogEntryType.Information);

                                Buster.WriteToEventLog(String.Format("Loaded {0} Device Filter(s)", Buster.Devices.Count), EventLogEntryType.Information);
                                Buster.WriteToEventLog(String.Format("Loaded {0} Class Filter(s)", Buster.Classes.Count), EventLogEntryType.Information);
                                Buster.WriteToEventLog(String.Format("Loaded {0} Wildcard Filter(s)", Buster.Wildcards.Count), EventLogEntryType.Information);

                                //! Count Filtered Devices (separate match from deletion in RemoveDevice_IF_Ghosted_AND_Marked).

                                Int32 ghosted = 0;
                                Int32 cnt     = 0;
                                foreach (HwEntry he in Buster.HwEntries)
                                {
                                    //Debug.WriteLine(he.Description);

                                    if (he.Ghosted)
                                    {
                                        ghosted++;
                                    }

                                    if (he.RemoveDevice_IF_Ghosted_AND_Marked())
                                    {
                                        cnt++;
                                    }
                                }

                                Buster.WriteToEventLog(String.Format("Removed {0} of {1} Ghosted Device(s).", cnt, ghosted), EventLogEntryType.Information);

                                Application.Exit();

                                return;
                            }
                        }
                        else
                        {
                            MessageBox.Show(String.Format("Configuration File not found at \r\n'{0}'.", fn), Buster.S_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else if (Environment.GetCommandLineArgs()[1].ToUpper().Equals("/REGISTER"))
                    {
                        // Get the service on the local machine
                        using (TaskService ts = new TaskService())
                        {
                            String user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                            String conf = Environment.ExpandEnvironmentVariables(Environment.GetCommandLineArgs()[2]);
                            String appl = Application.ExecutablePath;

                            Debug.WriteLine(appl);
                            Debug.WriteLine(conf);

                            Version ver    = ts.HighestSupportedVersion;
                            Boolean newVer = (ver >= new Version(1, 2));

                            TaskDefinition td = ts.NewTask();

                            td.Data                         = "GhostBuster";
                            td.Principal.UserId             = user;
                            td.Principal.LogonType          = TaskLogonType.InteractiveToken;
                            td.RegistrationInfo.Author      = "Wim van der Vegt";
                            td.RegistrationInfo.Description = String.Format(
                                "{0} removes selected Ghosted Devices. \r\n" +
                                "\r\n" +
                                "Default Settings for this scheduled task are:\r\n" +
                                " - Running with the required Administrative Privileges,\r\n" +
                                " - Running 1 minute after a user logs on,\r\n" +
                                " - Can be started manually with 'schtasks /run /ts {0}'. \r\n" +
                                "\r\n" +
                                "See http://ghosutbuster.codeplex.com", Buster.S_TITLE);
                            td.RegistrationInfo.Documentation      = "See http://ghostbuster.codeplex.com";
                            td.Settings.DisallowStartIfOnBatteries = true;
                            td.Settings.Hidden = false;

                            if (newVer)
                            {
                                td.Principal.RunLevel          = TaskRunLevel.Highest;
                                td.RegistrationInfo.Source     = Buster.S_TITLE;
                                td.RegistrationInfo.URI        = new Uri("http://ghostbuster.codeplex.com");
                                td.RegistrationInfo.Version    = new Version(0, 9);
                                td.Settings.AllowDemandStart   = true;
                                td.Settings.AllowHardTerminate = true;
                                td.Settings.Compatibility      = TaskCompatibility.V2;
                                td.Settings.MultipleInstances  = TaskInstancesPolicy.Queue;
                            }

                            LogonTrigger lTrigger = (LogonTrigger)td.Triggers.Add(new LogonTrigger());
                            if (newVer)
                            {
                                lTrigger.Delay  = TimeSpan.FromMinutes(1);
                                lTrigger.UserId = user;
                            }

                            td.Actions.Add(new ExecAction(
                                               appl,
                                               String.Format("/NOGUI {0}", conf),
                                               Path.GetDirectoryName(appl)));

                            //if (ts.FindTask(Buster.S_TITLE) != null)
                            //{
                            //    ts.RootFolder.DeleteTask(Buster.S_TITLE);
                            //}

                            // Register the task in the root folder
                            Task task = ts.RootFolder.RegisterTaskDefinition(
                                Buster.S_TITLE, td,
                                TaskCreation.CreateOrUpdate, null, null,
                                TaskLogonType.InteractiveToken,
                                null);

                            task.ShowEditor();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(S_CONSOLE, Buster.S_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case 2:
            {
                if (Buster.IsAdmin())
                {
                    if (Environment.GetCommandLineArgs()[1].ToUpper().Equals("/UNREGISTER"))
                    {
                        using (TaskService ts = new TaskService())
                        {
                            if (ts.FindTask(Buster.S_TITLE) != null)
                            {
                                ts.RootFolder.DeleteTask(Buster.S_TITLE);
                            }
                        }
                    }
                    else if (Environment.GetCommandLineArgs()[1].ToUpper().Equals("/EVENTLOG"))
                    {
                        if (!EventLog.SourceExists(Buster.S_TITLE))
                        {
                            EventLog.CreateEventSource(Buster.S_TITLE, Buster.S_TITLE);
                        }
                    }
                    else
                    {
                        MessageBox.Show(S_SYNTAX, Buster.S_TITLE,
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    Application.Exit();

                    return;
                }
                else
                {
                    if (Environment.GetCommandLineArgs()[1].ToUpper().Equals("/REGISTER") ||
                        Environment.GetCommandLineArgs()[1].ToUpper().Equals("/UNREGISTER"))
                    {
                        MessageBox.Show(S_SCHEDULE, Buster.S_TITLE,
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (Environment.GetCommandLineArgs()[1].ToUpper().Equals("/NOGUI"))
                    {
                        MessageBox.Show(S_CONSOLE, Buster.S_TITLE,
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (Environment.GetCommandLineArgs()[1].ToUpper().Equals("/EVENTLOG"))
                    {
                        MessageBox.Show(S_EVENTLOG, Buster.S_TITLE,
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(S_SYNTAX, Buster.S_TITLE,
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            break;

            default:
                Application.Run(new Mainform());
                break;
            }
        }
 public void See(Buster b)
 {
     Viewers.Add(b);
 }
예제 #14
0
 private Buster FindEnemyStunTarget(Buster buster)
 {
     return(_enemyBusters.FirstOrDefault(
                enemy => enemy.IsCarryingGhost && ComputeDistanceFromBuster(buster, enemy.X, enemy.Y) < 1760));
 }
예제 #15
0
 public override void Enter(Buster buster)
 {
     buster.TargetPosition = buster.Position;
 }
예제 #16
0
 public virtual string Update(Buster buster)
 {
     return("");
 }
예제 #17
0
 public FullState(Buster buster) : base(buster)
 {
 }
예제 #18
0
 public virtual void Enter(Buster buster)
 {
 }
예제 #19
0
 public Stun(Buster target)
 {
     Target = target;
 }
예제 #20
0
 public State(Buster buster)
 {
     Buster = buster;
 }
예제 #21
0
 public SupportState(Buster buster) : base(buster)
 {
 }
예제 #22
0
 public StunState(Buster buster) : base(buster)
 {
 }
        public void ApplyAction(List <Ghost> ghosts, List <Buster> busters, string action, bool apply)
        {
            string[] parts = action.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            ViewRange = BUSTER_VIEW;
            if (cooldownTime > 0)
            {
                cooldownTime--;
            }
            if (stunnedTime > 0)
            {
                stunnedTime--;
            }
            if (apply)              // buster is not stunned
            {
                switch (parts [0].ToUpper())
                {
                case "MOVE":
                    this.Move(new Point(int.Parse(parts [1]), int.Parse(parts [2])));
                    break;

                case "BUST":
                    DropGhost(ghosts);
                    Ghost ghost = ghosts.FirstOrDefault(g => g.ID == int.Parse(parts [1]));
                    if (ghost != null && this.Dist(ghost) >= BUSTER_MIN_BUST && this.Dist(ghost) <= BUSTER_MAX_BUST)
                    {
                        ghost.Attack(this);
                    }
                    break;

                case "RELEASE":
                    Release(ghosts);
                    break;

                case "STUN":
                    DropGhost(ghosts);
                    Buster target = busters.FirstOrDefault(b => b.ID == int.Parse(parts [1]));
                    if (cooldownTime == 0 && this.Dist(target) <= BUSTER_MAX_STUN_RANGE)
                    {
                        target.stunnedTime = BUSTER_STUN_HIT;
                        if (target.ID > this.ID)
                        {
                            target.stunnedTime++;                             //will be reduced during target.ApplyAction
                        }
                        this.cooldownTime = BUSTER_STUN_COOLDOWN;
                    }
                    break;

                case "RADAR":
                    if (canRadar)
                    {
                        canRadar  = false;
                        ViewRange = BUSTER_RADAR;
                    }
                    break;

                case "EJECT":
                    DropGhost(ghosts)?.MoveTo(new Point(int.Parse(parts [1]), int.Parse(parts [2])), BUSTER_MAX_EJECT);
                    break;
                }
            }
            foreach (GameObject g in ghosts.Union <GameObject>(busters))
            {
                if (this.Dist(g) <= ViewRange)
                {
                    g.See(this);
                }
            }
        }