예제 #1
0
파일: Game.cs 프로젝트: I3lue12/Projects
        void link_Died(Mob deadGuy)
        {
            Pause();
            List <Locateable> oldMap = new List <Locateable>();

            foreach (Locateable loc in link.Map)
            {
                oldMap.Add(loc);
            }
            int          r      = rand.Next(0, oldMap.Count);
            Vector       newPos = new Vector(oldMap[r].Position.X, oldMap[r].Position.Y);
            DialogResult dr     = MessageBox.Show(deadGuy.Name + " has just died!");

            if (dr == DialogResult.OK)
            {
                link = new Mob("link", newPos, animations["linkNone"],
                               animations["linkMove"], animations["linkMelee"], null,
                               MobType.Human, newPos, 500, 10, 5, 5, 300);
                link.Sense(oldMap);
                Sword sw = new Sword("long sword", new Vector(0, 0), null, 10);
                link.Inventory.Add(sw);
                link.EquippedWeapon    = sw;
                link.MeleeCombatEnded += m_MeleeCombatEnded;
                link.Died             += link_Died;
                Play();
            }
        }
예제 #2
0
파일: Game.cs 프로젝트: I3lue12/Projects
        void tmr_Tick(object sender, EventArgs e)
        {
            CheckProjectileCollisions();
            RemoveDeadGuys();// remove dead mobs before they sense/react to anything...
            RemoveDeadProjectiles();
            CheckForLoot();
            foreach (Mob m in monsters)
            {
                List <Locateable> thingsICanSee = FindAllLocateablesInRadius(m);
                m.Sense(thingsICanSee);
                List <Mob> mobsICanSee = FindAllMobsInRadius(m);
                m.Sense(mobsICanSee);
                MobAction act = m.React(1.0);
            }
            List <Locateable> thingsLinkCanSee = FindAllLocateablesInRadius(link);

            link.Sense(thingsLinkCanSee);
            List <Mob> mobsLinkCanSee = FindAllMobsInRadius(link);

            link.Sense(mobsLinkCanSee);
            MobAction actLink = link.React(1.0);

            foreach (Projectile proj in projectiles)
            {
                proj.Move(1.0);
            }

            GameInfo gi = new GameInfo();

            gi.Link        = link;
            gi.Monsters    = link.Contacts;
            gi.Map         = link.Map;
            gi.Projectiles = projectiles;
            gi.Msg         = obituary;

            if (Update != null)
            {   // Notify the Form that the Game status has changed...
                Update(gi);
            }
            obituary = "";// clear out the obituary for the next round of deaths to come
        }