コード例 #1
0
ファイル: Map.cs プロジェクト: eldan-dex/randio
        //Updates Tiles and all NPCs on them
        protected void UpdateNPCs(GameTime gameTime)
        {
            List <NPC> toRemove = new List <NPC>();

            foreach (NPC n in NPCs)
            {
                n.Update(gameTime);

                //Reset any entity which falls down from the map
                if (CheckOutOfMap((int)n.Position.Y) == -1 && n.Alive)
                {
                    n.Reset();
                }

                if (!n.Alive)
                {
                    toRemove.Add(n);
                }
            }

            //Removes dead NPCs
            foreach (NPC n in toRemove)
            {
                if (NPCs.Contains(n))
                {
                    NPCs.Remove(n);
                }
            }
        }
コード例 #2
0
 public void DeleteCharacter(Character _character)
 {
     if (_character.IsPlayable == true && PCs.Contains(_character) == true)
     {
         PCs.Remove(_character);
     }
     else if (_character.IsPlayable == false && NPCs.Contains(_character) == true)
     {
         NPCs.Remove(_character);
     }
 }
コード例 #3
0
 /// <summary>
 /// [EDITOR ONLY]
 /// </summary>
 /// <param name="_character"></param>
 public void AddCharacter(Character _character)
 {
     if (_character.IsPlayable == true && PCs.Contains(_character) == false)
     {
         PCs.Add(_character);
     }
     else if (_character.IsPlayable == false && NPCs.Contains(_character) == false)
     {
         NPCs.Add(_character);
     }
 }
コード例 #4
0
ファイル: Map.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Handles when a Character is added to the Map. This is an extension of EntityAdded that handles
        /// special stuff just for Characters.
        /// </summary>
        /// <param name="character">The Character that was added to the map.</param>
        /// <exception cref="TypeException">Unknown Character type - not a NPC or User...?</exception>
        void CharacterAdded(Character character)
        {
            // If the character was already on a map, so remove them from the old map
            if (character.Map != null && character.Map != this)
            {
                const string errmsg = "Character `{0}` [{1}] added to new map, but is already on a map!";
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat(errmsg, character, character.MapEntityIndex);
                }
                Debug.Fail(string.Format(errmsg, character, character.MapEntityIndex));
                character.Map.RemoveEntity(character);
            }

            // Syncronise paperdoll layers to all users on the same map
            foreach (User userOnMap in character.Map.Users)
            {
                if (userOnMap != null)
                {
                    character.SynchronizePaperdollTo(userOnMap);
                }
            }

            // Added character is a User
            var user = character as User;

            if (user != null)
            {
                EventCounterManager.Map.Increment(ID, MapEventCounterType.UserAdded);

                Debug.Assert(!Users.Contains(user), string.Format("Users list already contains `{0}`!", user));
                _users.Add(user);
                SendMapData(user);
                return;
            }

            // Added character is a NPC
            var npc = character as NPC;

            if (npc != null)
            {
                EventCounterManager.Map.Increment(ID, MapEventCounterType.NPCAdded);

                Debug.Assert(!NPCs.Contains(npc), string.Format("NPCs list already contains `{0}`!", npc));
                _npcs.Add(npc);
                return;
            }

            // Unknown added character type - not actually an error, but it is likely an oversight
            throw new TypeException("Unknown Character type - not a NPC or User...?");
        }
コード例 #5
0
            internal static bool Prefix(FarmHouse __instance)
            {
                if (__instance != null && __instance.owner != null && __instance.owner.getSpouse() != null && NPCs.Contains(__instance.owner.getSpouse().Name))
                {
                    return(false);
                }

                return(true);
            }