示例#1
0
        // removes GameObject from all lists depending on type
        public void Remove(GameObject go)
        {
            GameObjects.Remove(go);

            var item = go as ICollidable;

            if (item != null)
            {
                Collidables.Remove(item);
            }

            var moveable = go as IMoveable;

            if (moveable != null)
            {
                Moveables.Remove(moveable);
            }

            var renderable = go as IRenderable;

            if (renderable != null)
            {
                Renderables.Remove(renderable);
            }
        }
示例#2
0
文件: Level.cs 项目: LifeOfTony/Tony
        /// <summary>
        /// RemoveObject is called to remove a GameObject from the Objects list.
        /// </summary>
        public void RemoveObject(GameObject oldObject)
        {
            Objects.Remove(oldObject);

            // Adds to Drawables if drawable.
            if (oldObject is Drawable drawable)
            {
                Drawables.Remove(drawable);
            }

            // Adds to Collidables if collidable.
            if (oldObject is Collider)
            {
                Collidables.Remove(oldObject);
            }

            if (oldObject is Player)
            {
                Player = null;;
            }

            if (oldObject is Npc)
            {
                Npcs.Remove((Npc)oldObject);
            }
        }