示例#1
0
        /// <summary>
        /// Returns list of guard types a kin is eligible to hire
        /// </summary>
        /// <param name="alignment"></param>
        /// <returns></returns>
        public static List <KinFactionGuardTypes> GetEligibleGuardTypes(IOBAlignment alignment)
        {
            List <KinFactionGuardTypes> results = new List <KinFactionGuardTypes>();

            foreach (KinFactionGuardTypes guardType in Enum.GetValues(typeof(KinFactionGuardTypes)))
            {
                try
                {
                    //See if this type exists and has a KinFactionGuardTypeAttribute
                    Type t = SpawnerType.GetType(guardType.ToString().ToLower());
                    if (t != null)
                    {
                        bool addToList = true;
                        KinFactionGuardTypeAttribute[] att = (KinFactionGuardTypeAttribute[])t.GetCustomAttributes(typeof(KinFactionGuardTypeAttribute), true);

                        //Note here that if there isn't an attribute, all kins get added
                        if (att != null && att.Length > 0 && att[0].EligibleKin != null && att[0].EligibleKin.Count > 0)
                        {
                            if (att[0].EligibleKin != null && !att[0].EligibleKin.Contains(alignment))
                            {
                                addToList = false;
                            }
                        }
                        if (addToList)
                        {
                            results.Add(guardType);
                        }
                    }
                }
                catch
                {
                }
            }
            return(results);
        }
示例#2
0
        /// <summary>
        /// Returns cost type of the guard using reflection, or defaults to Medium. This is the amount of slots required for the guard.
        /// </summary>
        /// <returns></returns>
        public static int GetGuardCostType(KinFactionGuardTypes guardType)
        {
            //Default to medium cost
            int  cost = (int)KinFactionGuardCostTypes.MediumCost;
            Type t    = SpawnerType.GetType(guardType.ToString());

            if (t == null)
            {
                return(cost);
            }
            //Although foreach is used here, there will only be one of these attributes.
            foreach (KinFactionGuardTypeAttribute att in t.GetCustomAttributes(typeof(KinFactionGuardTypeAttribute), true))
            {
                //Use the custom value if it was provided
                if (att.CustomSlotCost > 0)
                {
                    cost = att.CustomSlotCost;
                }
                else
                {
                    cost = (int)att.GuardCostType;
                }
            }
            return(cost);
        }
示例#3
0
    public void addSpawner(int i, int j, SpawnerType type)
    {
        Vector3 newPosition = start + (rightRoom * j) + (bottomRoom * i);

        switch (type)
        {
        case SpawnerType.Node:
            GameObject nodeLocal = Instantiate(node, newPosition, Quaternion.Euler(0, 0, 0));
            nodeLocal.transform.parent = mapGenericRoom[i, j].gameObject.transform;

            nodeLocal.GetComponent <Node>().zombie = zombie;

            nodeLocal.transform.localPosition = new Vector3(30, 5, -20);
            break;

        case SpawnerType.Portal:
            GameObject portalLocal = Instantiate(portal, newPosition, Quaternion.Euler(0, 0, 0));
            portalLocal.transform.parent = mapGenericRoom[i, j].gameObject.transform;

            portalLocal.GetComponent <Portal>().zombie = zombie;

            portalLocal.transform.localPosition = new Vector3(25, 0, -25);
            break;

        case SpawnerType.Regular:
            GameObject regular = Instantiate(regularSpawner, newPosition, Quaternion.Euler(0, 0, 0));
            regular.transform.parent = mapGenericRoom[i, j].gameObject.transform;

            regular.GetComponent <SpawnZombie>().enemy = zombie;

            regular.transform.localPosition = new Vector3(25, 5, -25);
            break;
        }
    }
示例#4
0
        public List <string> CreateArray(RelayInfo info, Mobile from)
        {
            List <string> creaturesName = new List <string>();

            for (int i = 0; i < 13; i++)
            {
                TextRelay te = info.GetTextEntry(i);

                if (te != null)
                {
                    string str = te.Text;

                    if (str.Length > 0)
                    {
                        str = str.Trim();

                        Type type = SpawnerType.GetType(str);

                        if (type != null)
                        {
                            creaturesName.Add(str);
                        }
                        else
                        {
                            AddLabel(70, 230, 39, "Invalid Search String");
                        }
                    }
                }
            }

            return(creaturesName);
        }
示例#5
0
        /**
         * Find a random spawn group with the correct type and no more than maxCost.
         */
        public GroupInfo GetRandomSpawnGroup(SpawnerType spawnType, int maxCost)
        {
            List <GroupInfo> matchingGroups =
                m_spawnGroups.FindAll(g => (g.m_spawnType == spawnType) && (g.m_cost <= maxCost));

            return(GetRandomSpawnGroup(matchingGroups));
        }
示例#6
0
        private static void ExecuteDeathAction(Item corpse, Mobile killer, string action)
        {
            if (action == null || action.Length <= 0 || corpse == null)
            {
                return;
            }

            string status_str = null;

            XmlSpawner.SpawnObject TheSpawn = new XmlSpawner.SpawnObject(null, 0);

            TheSpawn.TypeName = action;
            string substitutedtypeName = BaseXmlSpawner.ApplySubstitution(null, corpse, killer, action);
            string typeName            = BaseXmlSpawner.ParseObjectType(substitutedtypeName);

            Point3D loc = corpse.Location;
            Map     map = corpse.Map;

            if (BaseXmlSpawner.IsTypeOrItemKeyword(typeName))
            {
                BaseXmlSpawner.SpawnTypeKeyword(corpse, TheSpawn, typeName, substitutedtypeName, true, killer, loc, map, out status_str);
            }
            else
            {
                // its a regular type descriptor so find out what it is
                Type type = SpawnerType.GetType(typeName);
                try
                {
                    string[] arglist = BaseXmlSpawner.ParseString(substitutedtypeName, 3, "/");
                    object   o       = XmlSpawner.CreateObject(type, arglist[0]);

                    if (o == null)
                    {
                        status_str = "invalid type specification: " + arglist[0];
                    }
                    else
                    if (o is Mobile)
                    {
                        Mobile m = (Mobile)o;
                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = loc;                                     // Spawners location is the home point
                        }

                        m.Location = loc;
                        m.Map      = map;

                        BaseXmlSpawner.ApplyObjectStringProperties(null, substitutedtypeName, m, killer, corpse, out status_str);
                    }
                    else
                    if (o is Item)
                    {
                        Item item = (Item)o;
                        BaseXmlSpawner.AddSpawnItem(null, corpse, TheSpawn, item, loc, map, killer, false, substitutedtypeName, out status_str);
                    }
                }
                catch { }
            }
        }
示例#7
0
        public XmlSocketable(int maxsockets, string skillname, double minskilllevel, string skillname2, double minskilllevel2, string resource, int quantity)
        {
            this.MaxSockets = maxsockets;

            try
            {
                this.RequiredResource = SpawnerType.GetType(resource);
            }
            catch
            {
            }

            try
            {
                this.RequiredSkill = (SkillName)Enum.Parse(typeof(SkillName), skillname);
            }
            catch
            {
            }

            this.MinSkillLevel = minskilllevel;

            try
            {
                this.RequiredSkill2 = (SkillName)Enum.Parse(typeof(SkillName), skillname2);
            }
            catch
            {
            }

            this.MinSkillLevel2 = minskilllevel2;

            this.ResourceQuantity = quantity;
            this.InvalidateParentProperties();
        }
示例#8
0
        public ISpawnCommand Create(SpawnerType spawnerType)
        {
            switch (spawnerType)
            {
            case SpawnerType.Explosing:
                return(_spawnRocketCommand);

                break;

            case SpawnerType.MiddlePlane:
            case SpawnerType.LowPlane:
                return(_spawnPlaneCommand);

                break;

            case SpawnerType.MiddleUFO:
            case SpawnerType.LowUFO:
                return(_spawnUfoCommand);

                break;

            case SpawnerType.Splitting:
                return(_spawnSplittingCommand);

                break;
            }
            Debug.LogError("Unknown spawner type");
            return(null);
        }
示例#9
0
 public void DoSpawn()
 {
     if (this.m_Entity != null)
     {
         this.m_Entity.MoveToWorld(this.Location, this.Map);
     }
     if (this.NestSpawnType != null && this.m_Spawn != null && this.Count() < this.m_MaxCount)
     {
         try
         {
             Type   type = SpawnerType.GetType(this.NestSpawnType);
             object o    = Activator.CreateInstance(type);
             if (o != null && o is Mobile)
             {
                 Mobile c = o as Mobile;
                 if (c is BaseCreature)
                 {
                     BaseCreature m = o as BaseCreature;
                     this.m_Spawn.Add(m);
                     m.OnBeforeSpawn(this.Location, this.Map);
                     m.MoveToWorld(this.Location, this.Map);
                     m.Home      = this.Location;
                     m.RangeHome = this.m_RangeHome;
                 }
             }
         }
         catch
         {
             this.NestSpawnType = null;
         }
     }
 }
示例#10
0
        /// <summary>
        /// Returns silver guard hire cost based on guard type using reflection
        /// </summary>
        /// <returns></returns>
        public static int GetGuardHireCost(KinFactionGuardTypes guardType)
        {
            //Default to medium cost
            int  cost = KinSystemSettings.GuardTypeMediumSilverCost;
            Type t    = SpawnerType.GetType(guardType.ToString());

            if (t == null)
            {
                return(cost);
            }
            foreach (KinFactionGuardTypeAttribute att in t.GetCustomAttributes(typeof(KinFactionGuardTypeAttribute), true))
            {                    //Although foreach is used here, there will only be one of these attributes.
                //Use the custom value if it was provided
                if (att.CustomHireCost > 0)
                {
                    cost = att.CustomHireCost;
                }
                else
                {
                    switch (att.GuardCostType)
                    {
                    case KinFactionGuardCostTypes.LowCost: cost = KinSystemSettings.GuardTypeLowSilverCost; break;

                    case KinFactionGuardCostTypes.MediumCost: cost = KinSystemSettings.GuardTypeMediumSilverCost; break;

                    case KinFactionGuardCostTypes.HighCost: cost = KinSystemSettings.GuardTypeHighSilverCost; break;
                    }
                }
            }
            return(cost);
        }
示例#11
0
 public GroupInfo()
 {
     m_cost          = 0;
     m_spawnClass    = SpawnerClass.ANY;
     m_spawnType     = SpawnerType.ANY;
     m_spawnGroupDef = null;
 }
示例#12
0
        // note that this method will be called when attached to either a mobile or a weapon
        // when attached to a weapon, only that weapon will do additional damage
        // when attached to a mobile, any weapon the mobile wields will do additional damage
        public override void OnWeaponHit(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven)
        {
            // if it is still refractory then return
            if (DateTime.UtcNow < this.m_EndTime)
            {
                return;
            }

            if (this.m_Chance <= 0 || Utility.Random(100) > this.m_Chance)
            {
                return;
            }

            if (defender != null && attacker != null)
            {
                // spawn a minion
                object o = null;
                try
                {
                    o = Activator.CreateInstance(SpawnerType.GetType(this.m_Minion));
                }
                catch
                {
                }

                if (o is BaseCreature)
                {
                    BaseCreature b = o as BaseCreature;
                    b.MoveToWorld(attacker.Location, attacker.Map);

                    if (attacker is PlayerMobile)
                    {
                        b.Controlled    = true;
                        b.ControlMaster = attacker;
                    }

                    b.Combatant = defender;

                    // add it to the list of controlled mobs
                    this.MinionList.Add(b);
                }
                else
                {
                    if (o is Item)
                    {
                        ((Item)o).Delete();
                    }
                    if (o is Mobile)
                    {
                        ((Mobile)o).Delete();
                    }
                    // bad minion specification so delete the attachment
                    this.Delete();
                }

                this.m_EndTime = DateTime.UtcNow + this.Refractory;
            }
        }
示例#13
0
 /// <summary>
 /// Sets all options to their default values. Does not throw exceptions.
 /// </summary>
 Options ()
 {
     versionNumber = latestVersion ();
     renameAsteroids = true;
     minUntrackedLifetime = 1.0f;
     maxUntrackedLifetime = 20.0f;
     spawner = SpawnerType.FixedRate;
     errorsOnScreen = true;
 }
示例#14
0
 public ShipsSpawner(Vector2 pos, SpawnerType st, Faction fact, int max, int time)
 {
     Position    = pos;
     spawnerType = st;
     maxShips    = max;
     maxTimer    = time;
     faction     = fact;
     timer       = maxTimer;
     timer       = 200;
 }
示例#15
0
 public GroupInfo(
     int cost,
     SpawnerClass spawnClass,
     SpawnerType spawnType,
     MySpawnGroupDefinition spawnGroup)
 {
     m_cost          = cost;
     m_spawnClass    = spawnClass;
     m_spawnType     = spawnType;
     m_spawnGroupDef = spawnGroup;
 }
示例#16
0
        /// <summary>
        /// Loads info
        /// </summary>
        /// <param name="reader"></param>
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_RitualItem   = SpawnerType.GetType(reader.ReadString());
            m_RitualAmount = reader.ReadInt();

            Serial serial = reader.ReadInt();

            PSpawner = World.FindItem(serial);
        }
示例#17
0
 bool IsTypeEquals(BaseSpawner spawner, SpawnerType type)
 {
     if (spawner is LivingEntityBasicSpawner && type == SpawnerType.Basic ||
         spawner is LivingEntityDrawMeshSpawner && type == SpawnerType.DrawMesh ||
         spawner is LivingEntityOneMeshSpawner && type == SpawnerType.OneMesh ||
         spawner is LivingEntityParticleSystemSpawner && type == SpawnerType.ParticleSystem)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#18
0
        public void Spawn(int index)
        {
            if (m_ItemsName.Count == 0 ||
                index >= m_ItemsName.Count ||
                m_Container == null)
            {
                return;
            }

            Defrag();

            //limit already at for this type of item
            // (changed from m_Items.Count so that m_Count items of each type will spawn)
            if (CountItems((string)m_ItemsName[index]) >= m_Count)
            {
                return;
            }

            Type type = SpawnerType.GetType((string)m_ItemsName[index]);

            if (type != null)
            {
                try
                {
                    object o = Activator.CreateInstance(type);

                    if (o is Item)
                    {
                        if (m_Container != null)
                        {
                            Item item = (Item)o;

                            //add it to the list
                            m_Items.Add(item);
                            InvalidateProperties();
                            //spawn it in the container
                            Container cont = m_Container;
                            cont.DropItem(item);
                        }
                    }
                }
                catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
            }
        }
示例#19
0
        public void Spawn(int index)
        {
            if (m_ItemsName.Count == 0 || index >= m_ItemsName.Count)
            {
                return;
            }

            Defrag();

            //limit already at
            if (m_Items.Count >= m_Count)
            {
                return;
            }

            Type type = SpawnerType.GetType((string)m_ItemsName[index]);

            if (type != null)
            {
                try
                {
                    object o = Activator.CreateInstance(type);

                    if (o is Item)
                    {
                        //parent must be container to spawn
                        if (this.Parent is Container)
                        {
                            Item item = (Item)o;

                            //add it to the list
                            m_Items.Add(item);
                            InvalidateProperties();
                            //spawn it in the container
                            Container cont = (Container)this.Parent;
                            cont.DropItem(item);
                        }
                    }
                }
                catch
                {
                }
            }
        }
示例#20
0
    protected BehaviorManager GetSpawner(SpawnerType spawnerType)
    {
        GameObject spawner = GameObject.FindGameObjectWithTag(spawnerType.ToString());

        if(spawner == null)
        {
            Debug.LogErrorFormat("Unable to find Spawner with tag '{0}'", spawnerType.ToString());
            return null;
        }

        BehaviorManager behavior = spawner.GetComponent<BehaviorManager>();

        if(behavior == null)
        {
            Debug.LogErrorFormat("Unable to find Behavior Manger on object '{0}'", spawner.name);
            return null;
        }

        return behavior;
    }
        protected override BulletSpawner createSpawner(SpawnerType type, Entity parent, BulletType btype)
        {
            Texture2D btex = BType2Tex(btype);

            Entity e = parent;

            switch (type)
            {
            case (SpawnerType.CardinalSouth):
                return(new CardinalBulletSpawner(e, btex, e.Position, e.Movement, e.Width, e.Height, Movement.CardinalDirection.South));

            case (SpawnerType.Targeted):
                return(new TargetedBulletSpawner(e, btex, e.Position, e.Movement, e.Width, e.Height));

            case (SpawnerType.Keyboard):
                return(new KeyboardBulletSpawner(e, btex, e.Position, e.Movement, e.Width, e.Height, Movement.CardinalDirection.North));

            default:
                throw new Exception("StandardSpawnerFactory type requested not yet implemented");
            }
        }
        public static int GetSettingsSize(DeliriumSpawnerSettings settings, SpawnerType type)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            switch (type)
            {
            case SpawnerType.Good:
                return(settings.GoodSpawner.Size.Value);

            case SpawnerType.Bad:
                return(settings.BadSpawner.Size.Value);

            case SpawnerType.Unknown:
                return(settings.UnknownSpawner.Size.Value);

            default:
                throw new ArgumentOutOfRangeException(nameof(type));
            }
        }
示例#23
0
    public void setAttributes(int spawnerInt, int index, Transform player)
    {
        playerTransform = player;
        var spawnerIntStr = spawnerInt.ToString();

        id             = index;
        width          = Int16.Parse(spawnerIntStr.Substring(0, 2));
        height         = Int16.Parse(spawnerIntStr.Substring(2, 2));
        centerOfObject = new Vector3(transform.position.x + (width / 2), transform.position.y + (height / 2), 0);
        var spawnerTypeList = SpawnerType.GetValues(typeof(SpawnerType)) as SpawnerType[];

        System.Random pseudoRandom = new System.Random((int)System.DateTime.Now.Ticks);
        type = spawnerTypeList[pseudoRandom.Next(0, spawnerTypeList.Length)];
        // type = SpawnerType.Walled;
        // Debug.Log(type);
        var numberOfWalls = Int16.Parse(spawnerIntStr.Substring(4, 1));

        for (var i = 0; i < numberOfWalls; i++)
        {
            createBoundaryWall(Int16.Parse(spawnerIntStr.Substring(5 + i, 1)));
        }
        setWallTriggers();
    }
示例#24
0
        public override TransferMessage ProcessMessage()
        {
            ArrayList tmparray = new ArrayList();
            Type      type     = null;

            // is there a object type restriction?
            if (ObjectType != null && ObjectType.Length > 0)
            {
                //type = Type.GetType(ObjectType);
                type = SpawnerType.GetType(ObjectType);
            }

            if (type != null)
            {
                if (type == typeof(Mobile) || type.IsSubclassOf(typeof(Mobile)))
                {
                    // because this is going to run in a separate thread, need to worry about the world lists
                    // being modified while loooping, so make a copy
                    ArrayList mobilearray = null;

                    mobilearray = new ArrayList(World.Mobiles.Values);

                    if (mobilearray != null)
                    {
                        foreach (Mobile m in mobilearray)
                        {
                            if (m.Map == null || m.Map == Map.Internal)
                            {
                                continue;
                            }

                            bool passed = true;

                            // match map
                            if (m.Map.MapID != SelectedMap && SelectedMap != -1)
                            {
                                passed = false;
                            }

                            // match type
                            if (passed && type != m.GetType() && !m.GetType().IsSubclassOf(type))
                            {
                                passed = false;
                            }

                            // check filters

                            // apply playermobile filters
                            if (m is PlayerMobile)
                            {
                                PlayerMobile b = (PlayerMobile)m;

                                // AccessLevel restricted?  1=playeronly 2=staffonly 3=counseloronly 4=gmonly 5=seeronly 6=adminonly
                                if (passed && Access > 0)
                                {
                                    if (Access == 1 && b.AccessLevel != AccessLevel.Player)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Access == 2 && b.AccessLevel == AccessLevel.Player)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Access == 3 && b.AccessLevel != AccessLevel.Counselor)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Access == 4 && b.AccessLevel != AccessLevel.GameMaster)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Access == 5 && b.AccessLevel != AccessLevel.Seer)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Access == 6 && b.AccessLevel != AccessLevel.Administrator)
                                    {
                                        passed = false;
                                    }
                                }

                                // criminal restricted?  1=innocentonly 2=criminalonly 3=murdereronly
                                if (passed && Criminal > 0)
                                {
                                    int noto = NotorietyHandlers.MobileNotoriety(b, b);

                                    if (Criminal == 1 && noto != Notoriety.Innocent)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Criminal == 2 && noto != Notoriety.Criminal && noto != Notoriety.Murderer)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Criminal == 3 && noto != Notoriety.Murderer)
                                    {
                                        passed = false;
                                    }
                                }
                            }

                            // apply basecreature filters
                            if (m is BaseCreature)
                            {
                                BaseCreature b = (BaseCreature)m;

                                // controlled restricted?  1=controlledonly 2=notcontrolled
                                if (passed && Controlled > 0)
                                {
                                    if (Controlled == 1 && !b.Controled)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Controlled == 2 && b.Controled)
                                    {
                                        passed = false;
                                    }
                                }

                                // innocent restricted?  1=innocentonly 2=invulnerable 3=attackable
                                if (passed && Innocent > 0)
                                {
                                    int noto = NotorietyHandlers.MobileNotoriety(b, b);

                                    if (Innocent == 1 && noto != Notoriety.Innocent)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Innocent == 2 && noto != Notoriety.Invulnerable)
                                    {
                                        passed = false;
                                    }
                                    else
                                    if (Innocent == 3 && noto != Notoriety.CanBeAttacked)
                                    {
                                        passed = false;
                                    }
                                }
                            }

                            // add it to the array if it passed all the tests
                            if (passed)
                            {
                                tmparray.Add(m);
                            }
                        }
                    }
                }
                else
                if (type == typeof(Item) || type.IsSubclassOf(typeof(Item)))
                {
                    ArrayList itemarray = null;

                    itemarray = new ArrayList(World.Items.Values);

                    if (itemarray != null)
                    {
                        foreach (Item m in itemarray)
                        {
                            if (m.Map == null || m.Map == Map.Internal)
                            {
                                continue;
                            }

                            bool passed = true;

                            if (m.Map.MapID != SelectedMap && SelectedMap != -1)
                            {
                                passed = false;
                            }

                            if (passed && type != m.GetType() && !m.GetType().IsSubclassOf(type))
                            {
                                passed = false;
                            }

                            // movable restricted?  1=movableonly 2=not movable only
                            if (passed && Movable > 0)
                            {
                                if (Movable == 1 && !m.Movable)
                                {
                                    passed = false;
                                }
                                else
                                if (Movable == 2 && m.Movable)
                                {
                                    passed = false;
                                }
                            }

                            // visible restricted?  1=visibleonly 2=not visible only
                            if (passed && Visible > 0)
                            {
                                if (Visible == 1 && !m.Visible)
                                {
                                    passed = false;
                                }
                                else
                                if (Visible == 2 && m.Visible)
                                {
                                    passed = false;
                                }
                            }

                            // blessed restricted?  1=blessedonly 2=notblessed
                            if (passed && Blessed > 0)
                            {
                                if (Blessed == 1 && m.LootType != LootType.Blessed)
                                {
                                    passed = false;
                                }
                                else
                                if (Blessed == 2 && m.LootType == LootType.Blessed)
                                {
                                    passed = false;
                                }
                            }

                            // static restricted?  1=staticsonly 2=no statics
                            if (passed && Statics > 0)
                            {
                                if (Statics == 1 && !(m is Static))
                                {
                                    passed = false;
                                }
                                else
                                if (Statics == 2 && m is Static)
                                {
                                    passed = false;
                                }
                            }

                            // container restricted?  1=incontaineronly 2=not in containers
                            if (passed && InContainers > 0)
                            {
                                if (InContainers == 1 && !(m.Parent is Container))
                                {
                                    passed = false;
                                }
                                else
                                if (InContainers == 2 && m.Parent is Container)
                                {
                                    passed = false;
                                }
                            }

                            // carried by mobiles restricted?  1=carriedonly 2=not carried
                            if (passed && Carried > 0)
                            {
                                if (Carried == 1 && !(m.RootParent is Mobile))
                                {
                                    passed = false;
                                }
                                else
                                if (Carried == 2 && m.RootParent is Mobile)
                                {
                                    passed = false;
                                }
                            }

                            // itemid restricted?
                            if (passed && ItemID >= 0 && ItemID != m.ItemID)
                            {
                                passed = false;
                            }

                            if (passed)
                            {
                                tmparray.Add(m);
                            }
                        }
                    }
                }
            }

            ObjectData [] objectlist = new ObjectData[tmparray.Count];

            for (int i = 0; i < tmparray.Count; i++)
            {
                if (tmparray[i] is Mobile)
                {
                    Mobile m = tmparray[i] as Mobile;

                    string name = m.Name;
                    if (name == null)
                    {
                        name = m.GetType().Name;
                    }

                    // append a title if they have one
                    if (m.Title != null)
                    {
                        name += " " + m.Title;
                    }

                    // fill the return data array
                    objectlist[i] = new ObjectData((short)m.Location.X, (short)m.Location.Y, (byte)m.Map.MapID, name);
                }
                else
                if (tmparray[i] is Item)
                {
                    Item m = tmparray[i] as Item;

                    // fill the return data array
                    string name = m.Name;
                    if (name == null)
                    {
                        name = m.GetType().Name;
                    }

                    short x = (short)m.Location.X;
                    short y = (short)m.Location.Y;
                    if (m.RootParent is Mobile)
                    {
                        x = (short)((Mobile)m.RootParent).Location.X;
                        y = (short)((Mobile)m.RootParent).Location.Y;
                    }
                    else
                    if (m.RootParent is Container)
                    {
                        x = (short)((Container)m.RootParent).Location.X;
                        y = (short)((Container)m.RootParent).Location.Y;
                    }


                    objectlist[i] = new ObjectData(x, y, (byte)m.Map.MapID, name);
                }
            }

            return(new ReturnObjectData(objectlist));
        }
示例#25
0
        public static void ProcessSpawnSet(
            string spawnSet,
            int x,
            int y,
            int z,
            int hRange,
            int sRange,
            int n,
            string mapName
            )
        {
            Point3D location = new Point3D(x, y, z);

            Map mapInstance = null;

            Map[] maps = Map.Maps;

            foreach (Map map in maps)
            {
                if (map.Name == mapName)
                {
                    mapInstance = map;
                    break;
                }
            }

            if (mapInstance == null)
            {
                Console.WriteLine("#### RE: no map for map nammed \"{0}\".", mapName);
            }

            Dictionary <string, List <ImportRecord> > regionEncounters;

            if (facetEncounters.ContainsKey(mapName))
            {
                regionEncounters = facetEncounters[mapName];
            }
            else
            {
                regionEncounters = new Dictionary <string, List <ImportRecord> >();

                facetEncounters.Add(mapName, regionEncounters);
            }

            Region region = Region.Find(location, mapInstance);

            if (
                region != null
                &&
                region.Name != null
                &&
                region.Name != "")
            {
                string[] spawns = spawnSet.Split(':');

                List <ImportRecord> encounterSet;

                if (regionEncounters.ContainsKey(region.Name))
                {
                    encounterSet = regionEncounters[region.Name];
                }
                else
                {
                    /*
                     *  public class ProbabilityComparer : IComparer
                     *  {
                     *      public int Compare( object o1, object o2 )
                     *      {
                     *          ImportRecord r1 = (ImportRecord) o1;
                     *          ImportRecord r2 = (ImportRecord) o2;
                     *
                     *          if ( r1.P > r2.P ) return -1;
                     *          if ( r1.P < r2.P ) return 1;
                     *
                     *          else return 0;
                     *      }
                     *  }
                     */
                    encounterSet = new List <ImportRecord>( );

                    regionEncounters.Add(region.Name, encounterSet);
                }

                foreach (string spawn in spawns)
                {
                    Type   typeObject = SpawnerType.GetType(spawn);
                    object created    = null;
                    double level      = 0.0;
                    double p          = 0.0;

                    if (typeObject == null)
                    {
                        continue;
                    }
                    try
                    {
                        created = Activator.CreateInstance(typeObject);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        continue;
                    }

                    if (created is TownCrier)
                    {
                        continue;
                    }
                    if (created is BaseVendor)
                    {
                        continue;
                    }
                    if (created is Mobile)
                    {
                        Mobile m = (Mobile)created;

                        bool hostile = (m is BaseEscortable) ? false : true;

                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;

                            switch (c.AI)
                            {
                            case AIType.AI_Healer: { hostile = false; break; }

                            case AIType.AI_Vendor: { hostile = false; break; }

                            case AIType.AI_Animal: { if (c.Fame < 400)
                                                     {
                                                         hostile = false;
                                                     }
                                                     break; }
                            }
                        }

                        level = Helpers.CalculateLevelForMobile(m, LevelType.Overall);

                        p = 1.0 / Math.Pow(1 + level, 1.4);

                        ImportRecord ir = new ImportRecord(
                            (Mobile)created,
                            spawn,
                            x,
                            y,
                            z,
                            hRange,
                            sRange,
                            n,
                            mapName,
                            region.Name,
                            level,
                            hostile,
                            p
                            );

                        //Console.WriteLine("        "+ir);

                        encounterSet.Add(ir);
                    }
                }
            }
        }
示例#26
0
        void OnGUI()
        {
            const float spawnerBoxWidth = 550f;

            if (_spawnerComboBox == null)
            {
                var width  = spawnerBoxWidth * UICoeff;
                var height = UIMediumMargin + UISmallMargin * 2;
                var x      = Screen.width - width - UIMediumMargin;
                var y      = Screen.height - height - UIMediumMargin;

                var rect = new Rect(x, y, width, height);

                var comboBoxList = new GUIContent[]
                {
                    new GUIContent("GameObject"), // Basic
                    new GUIContent("Draw Mesh"),
                    new GUIContent("One Mesh"),
                    new GUIContent("Particle System")
                };

                var buttonStyle = new GUIStyle("button");
                buttonStyle.fontSize = (int)(60f * UICoeff);

                var boxStyle = new GUIStyle("box");

                var listStyle = new GUIStyle();
                listStyle.fontSize           = (int)(60f * UICoeff);
                listStyle.normal.textColor   = Color.white;
                listStyle.onHover.background = listStyle.hover.background = new Texture2D(2, 2);
                listStyle.padding.left       = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4;

                _spawnerComboBox = new ComboBox(
                    rect,
                    comboBoxList,
                    buttonStyle,
                    boxStyle,
                    listStyle
                    );
                _spawnerComboBox.OnItemSelected += (i, userHasPressed) => {
                    if (!userHasPressed)
                    {
                        return;
                    }

                    _SelectedType = (SpawnerType)i;

                    UpdateType();
                };
                _spawnerComboBox.Direction         = ComboBox.PopupDirection.FromBottomToTop;
                _spawnerComboBox.SelectedItemIndex = _type.HasValue? (int)_type.Value : 0;
            }
            else
            {
                var width  = spawnerBoxWidth * UICoeff;
                var height = UIMediumMargin + UISmallMargin * 2;
                var x      = Screen.width - width - UIMediumMargin;
                var y      = Screen.height - height - UIMediumMargin;

                var rect = new Rect(x, y, width, height);

                _spawnerComboBox.rect = rect;
            }

            if (_configComboBox == null)
            {
                var width  = 550 * UICoeff;
                var height = UIMediumMargin + UISmallMargin * 2;
                var x      = Screen.width - UIMediumMargin - spawnerBoxWidth * UICoeff - UISmallMargin - width;
                var y      = Screen.height - height - UIMediumMargin;

                var rect = new Rect(x, y, width, height);

                var comboBoxList = new GUIContent[_LivingEntityDatas.Length];

                for (int i = 0; i < comboBoxList.Length; i++)
                {
                    comboBoxList[i] = new GUIContent(_LivingEntityDatas[i].Name);
                }

                var buttonStyle = new GUIStyle("button");
                buttonStyle.fontSize = (int)(60f * UICoeff);

                var boxStyle = new GUIStyle("box");

                var listStyle = new GUIStyle();

                listStyle.fontSize           = (int)(60f * UICoeff);
                listStyle.normal.textColor   = Color.white;
                listStyle.onHover.background = listStyle.hover.background = new Texture2D(2, 2);
                listStyle.padding.left       = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4;

                _configComboBox = new ComboBox(
                    rect,
                    comboBoxList,
                    buttonStyle,
                    boxStyle,
                    listStyle
                    );
                _configComboBox.OnItemSelected += (i, userHasPressed) => {
                    if (!userHasPressed)
                    {
                        return;
                    }

                    _LivingEntityData = _LivingEntityDatas[i];

                    UpdateLivingEntityData();
                };

                _configComboBox.Direction         = ComboBox.PopupDirection.FromBottomToTop;
                _configComboBox.SelectedItemIndex = System.Array.FindIndex(_LivingEntityDatas, (d) => d.Equals(_LivingEntityData));
            }
            else
            {
                var width  = 550 * UICoeff;
                var height = UIMediumMargin + UISmallMargin * 2;
                var x      = Screen.width - UIMediumMargin - spawnerBoxWidth * UICoeff - UISmallMargin - width;
                var y      = Screen.height - height - UIMediumMargin;

                var rect = new Rect(x, y, width, height);

                _configComboBox.rect = rect;
            }

            if (GUIVisibility)
            {
                _spawnerComboBox.Show();
                _configComboBox.Show();
            }
        }
示例#27
0
 void AssignSpawnerType(SpawnerType type)
 {
     if (ContainsType(type) == 1)
         Debug.Log(type.ToString() + " already exists in " + name);
     else if (Spawner1 == SpawnerType.Unknown) {
         Spawner1 = type;
         Spawners1 = new List<PickupSpawner>();
         setupTypeProps(type, Spawner1Pos);
     } else if (Spawner2 == SpawnerType.Unknown) {
         Spawner2 = type;
         Spawners2 = new List<PickupSpawner>();
         setupTypeProps(type, Spawner2Pos);
     } else if (Spawner3 == SpawnerType.Unknown) {
         Spawner3 = type;
         Spawners3 = new List<PickupSpawner>();
         setupTypeProps(type, Spawner3Pos);
     } else {
         Debug.Log("Cannot add " + type.ToString() + "; no more room in " + name);
     }
 }
示例#28
0
 int ContainsType(SpawnerType type)
 {
     if (type == Spawner1) {
         return Spawn1(type);
     } else if (type == Spawner2) {
         return Spawn2(type);
     } else if (type == Spawner3) {
         return Spawn3(type);
     }
     return 0;
 }
示例#29
0
 int Spawn2(SpawnerType type)
 {
     if (type == Spawner2) {
         if (Spawners2.Count < Capacity)
             return 1;
         return 2;
     }
     return 0;
 }
        // adds components from a multi.txt file to an existing addon
        public static int LoadAddonFromMulti(XmlSpawnerAddon newaddon, string filename, out string status_str)
        {
            status_str = null;

            if (filename == null)
            {
                status_str = "Invalid filename";
                return(0);
            }

            if (newaddon == null)
            {
                status_str = "Invalid addon";
                return(0);
            }

            bool badformat   = false;
            int  ncomponents = 0;

            if (System.IO.File.Exists(filename))
            {
                using (StreamReader sr = new StreamReader(filename))
                {
                    string line;
                    int    linenumber = 0;

                    // Read and process lines from the file until the end of the file is reached.
                    // Individual lines have the format of
                    // itemid x y z visible [hue] ; attachment[,args]
                    // where visible is a 0/1 and hue can be optionally specified for individual itemid entries.
                    while ((line = sr.ReadLine()) != null)
                    {
                        linenumber++;

                        // process the line
                        if (line.Length == 0)
                        {
                            continue;
                        }

                        // first parse out the component specification from any optional attachment specifications

                        string[] specs = line.Split(';');

                        // the component spec will always be first

                        if (specs == null || specs.Length < 1)
                        {
                            continue;
                        }

                        string[] args = specs[0].Trim().Split(' ');

                        AddonComponent newcomponent = null;

                        if (args != null && args.Length >= 5)
                        {
                            int itemid  = -1;
                            int x       = 0;
                            int y       = 0;
                            int z       = 0;
                            int visible = 0;
                            int hue     = -1;

                            try
                            {
                                itemid  = int.Parse(args[0]);
                                x       = int.Parse(args[1]);
                                y       = int.Parse(args[2]);
                                z       = int.Parse(args[3]);
                                visible = int.Parse(args[4]);

                                // handle the optional fields that are not part of the original multi.txt specification
                                if (args.Length > 5)
                                {
                                    hue = int.Parse(args[5]);
                                }
                            }
                            catch { badformat = true; }

                            if (itemid < 0 || badformat)
                            {
                                status_str = String.Format("Error line {0}", linenumber);
                                break;
                            }

                            // create the new component
                            newcomponent = new AddonComponent(itemid);

                            // set the properties according to the specification
                            newcomponent.Visible = (visible == 1);

                            if (hue >= 0)
                            {
                                newcomponent.Hue = hue;
                            }

                            // add it to the addon
                            newaddon.AddComponent(newcomponent, x, y, z);

                            ncomponents++;
                        }

                        // if a valid component was added, then check to see if any additional attachment specifications need to be processed
                        if (newcomponent != null && specs.Length > 1)
                        {
                            for (int j = 1; j < specs.Length; j++)
                            {
                                if (specs[j] == null)
                                {
                                    continue;
                                }

                                string attachstring = specs[j].Trim();

                                Type type = null;
                                try
                                {
                                    type = SpawnerType.GetType(BaseXmlSpawner.ParseObjectType(attachstring));
                                }
                                catch { }

                                // if so then create it
                                if (type != null && type.IsSubclassOf(typeof(XmlAttachment)))
                                {
                                    object newo = XmlSpawner.CreateObject(type, attachstring, false, true);
                                    if (newo is XmlAttachment)
                                    {
                                        // add the attachment to the target
                                        XmlAttach.AttachTo(newcomponent, (XmlAttachment)newo);
                                    }
                                }
                            }
                        }
                    }

                    sr.Close();
                }
            }
            else
            {
                status_str = "No such file : " + filename;
            }

            if (badformat)
            {
                return(0);
            }
            else
            {
                return(ncomponents);
            }
        }
示例#31
0
 int CountSpawners(SpawnerType type)
 {
     if (ContainsType(type) == 0)
         Debug.Log("No instances of " + type.ToString() + " found in " + name);
     else if (Spawner1 == type) {
         if (Spawners1.Count > 1) Spawners1.RemoveAll(x => x == null);
         return Spawners1.Count;
     } else if (Spawner2 == type) {
         if (Spawners2.Count > 1) Spawners2.RemoveAll(x => x == null);
         return Spawners2.Count;
     } else if (Spawner3 == type) {
         if (Spawners3.Count > 1) Spawners3.RemoveAll(x => x == null);
         return Spawners3.Count;
     }
     return 0;
 }
示例#32
0
        public override void OnDoubleClick(Mobile from)
        {
            Type type = SpawnerType.GetType(m_ItemType);

            if (type != null && typeof(Item).IsAssignableFrom(type))
            {
                object o = null;

                try
                {
                    ConstructorInfo[] ctors = type.GetConstructors();

                    for (int i = 0; i < ctors.Length; ++i)
                    {
                        ConstructorInfo ctor = ctors[i];

                        if (Add.IsConstructable(ctor, AccessLevel.GameMaster))
                        {
                            ParameterInfo[] paramList = ctor.GetParameters();

                            if (m_ParamList.Length == paramList.Length)
                            {
                                object[] paramValues = Add.ParseValues(paramList, m_ParamList);

                                if (paramValues != null)
                                {
                                    o = ctor.Invoke(paramValues);
                                    break;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("VendStone: Invalid constructor or parameters for {0}: {1} {2}", Serial, m_ItemType, m_Parameters);
                }

                Item item = o as Item;

                if (m_Value < 0)
                {
                    m_Value = 0;
                }

                int amt = from.AccessLevel >= AccessLevel.GameMaster ? 0 : Currency.Consume(from, m_Value, true, CurrencyType.Both);

                if (amt > 0)
                {
                    from.SendMessage(1153, "You lack {0}gp for this", amt);
                    item.Delete();
                }
                else if (from.AddToBackpack(item))
                {
                    from.SendMessage("You place the {0} into your backpack.", FullName);
                    from.PlaySound(from.Backpack.GetDroppedSound(item));
                }
                else
                {
                    from.SendMessage("You do not have room for this item in your backpack and it has been dropped to the ground.");
                    int sound = item.GetDropSound();
                    from.PlaySound(sound == -1 ? 0x42 : sound);
                }
            }
            else
            {
                from.SendMessage("There is nothing being sold on this stone.");
            }
        }
示例#33
0
 public SpawnTag(string tagString, SpawnerClass spawnClass, SpawnerType spawnType)
 {
     m_tagString  = tagString;
     m_spawnClass = spawnClass;
     m_spawnType  = spawnType;
 }
示例#34
0
    void AddSpawner(SpawnerType type, GameObject spawner)
    {
        if (ContainsType(type) == 0)
            Debug.Log("There are no " + type.ToString() + " here in " + name);

        else if (ContainsType(type) == 1) {
            Vector3 randomVector = Random.insideUnitSphere * 5;
            randomVector.y = 5f;
            if (type == Spawner1) {
                Spawners1.Add(AreaPlacement(5, Spawner1Pos + randomVector, spawner, Spawner1Location));
            } else if (type == Spawner2) {
                Spawners2.Add(AreaPlacement(5, Spawner2Pos + randomVector, spawner, Spawner2Location));
            } else if (type == Spawner3) {
                Spawners3.Add(AreaPlacement(5, Spawner3Pos + randomVector, spawner, Spawner3Location));
            }
        }
    }
示例#35
0
 int SpawnIteration(SpawnerType type, int area)
 {
     switch (area) {
         case (1):
             return Spawn1(type);
         case (2):
             return Spawn2(type);
         case (3):
             return Spawn3(type);
         default:
             return ContainsType(type);
     }
 }
示例#36
0
 int Spawn3(SpawnerType type)
 {
     if (type == Spawner3) {
         if (Spawners3.Count < Capacity)
             return 1;
         return 2;
     }
     return 0;
 }
示例#37
0
        public void Spawn()
        {
            Map map = Map;

            if (map == null || map == Map.Internal || m_Location == Point3D.Zero || m_Creature == null || m_Creature == "-invalid-")
            {
                return;
            }

            Type type = SpawnerType.GetType((string)m_Creature);

            if (type != null)
            {
                m_NextSpawn = DateTime.Now + m_Delay;

                try
                {
                    object o = Activator.CreateInstance(type);

                    if (o is Mobile)
                    {
                        Mobile m = (Mobile)o;

                        m_Creatures.Add(m);
                        InvalidateProperties();

                        m.Map      = map;
                        m.Location = m_Location;

                        if (m_Message != null)
                        {
                            m.PublicOverheadMessage(MessageType.Regular, 0x76C, false, m_Message);
                        }

                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;

                            c.RangeHome = m_HomeRange;

                            if (m_Team > 0)
                            {
                                c.Team = m_Team;
                            }

                            c.Home = m_Location;
                        }
                    }
                    else if (o is Item)
                    {
                        Item item = (Item)o;

                        m_Creatures.Add(item);
                        InvalidateProperties();

                        item.MoveToWorld(m_Location, map);

                        if (m_Message != null)
                        {
                            item.PublicOverheadMessage(MessageType.Regular, 0x76C, false, m_Message);
                        }
                    }
                }
                catch
                {
                    PublicOverheadMessage(MessageType.Regular, 0x3BD, false, string.Format("Exception Caught"));                         // debugging
                }
            }
        }
示例#38
0
 void RemoveSpawner(SpawnerType type)
 {
     if (ContainsType(type) == 0)
         Debug.Log("There are no " + type.ToString() + " here in " + name);
     else if (type == Spawner3) {
         if (Spawners3.Count > 0) {
             Destroy(Spawners3[Spawners3.Count - 1].gameObject);
             Spawners3.RemoveAt(Spawners3.Count - 1);
         }
         if (Spawners3.Count == 0) {
             Spawner3 = SpawnerType.Unknown;
             Spawners3 = null;
             // Remove all children (clean slate)
             var children = new List<GameObject>();
             foreach (Transform child in Spawner3Location) children.Add(child.gameObject);
             children.ForEach(child => Destroy(child));
         }
     } else if (type == Spawner2) {
         if (Spawners2.Count > 0) {
             Destroy(Spawners2[Spawners2.Count - 1].gameObject);
             Spawners2.RemoveAt(Spawners2.Count - 1);
         }
         if (Spawners2.Count == 0) {
             Spawner2 = SpawnerType.Unknown;
             Spawners2 = null;
             // Remove all children (clean slate)
             var children = new List<GameObject>();
             foreach (Transform child in Spawner2Location) children.Add(child.gameObject);
             children.ForEach(child => Destroy(child));
         }
     } else if (type == Spawner1) {
         if (Spawners1.Count > 0) {
             Destroy(Spawners1[Spawners1.Count - 1].gameObject);
             Spawners1.RemoveAt(Spawners1.Count - 1);
         }
         if (Spawners1.Count == 0) {
             Spawner1 = SpawnerType.Unknown;
             Spawners1 = null;
             // Remove all children (clean slate)
             var children = new List<GameObject>();
             foreach (Transform child in Spawner1Location) children.Add(child.gameObject);
             children.ForEach(child => Destroy(child));
         }
     }
 }
示例#39
0
 int Spawn1(SpawnerType type)
 {
     if (type == Spawner1) {
         if (Spawners1.Count < Capacity)
             return 1;
         return 2;
     }
     return 0;
 }
示例#40
0
        private void ExecuteAction(Mobile mob, object target, string action)
        {
            if (action == null || action.Length <= 0)
            {
                return;
            }

            string status_str = null;

            Server.Mobiles.XmlSpawner.SpawnObject TheSpawn = new Server.Mobiles.XmlSpawner.SpawnObject(null, 0);

            TheSpawn.TypeName = action;
            string substitutedtypeName = BaseXmlSpawner.ApplySubstitution(null, target, mob, action);
            string typeName            = BaseXmlSpawner.ParseObjectType(substitutedtypeName);

            Point3D loc = new Point3D(0, 0, 0);
            Map     map = null;


            if (target is Item)
            {
                Item ti = target as Item;
                if (ti.Parent == null)
                {
                    loc = ti.Location;
                    map = ti.Map;
                }
                else if (ti.RootParent is Item)
                {
                    loc = ((Item)ti.RootParent).Location;
                    map = ((Item)ti.RootParent).Map;
                }
                else if (ti.RootParent is Mobile)
                {
                    loc = ((Mobile)ti.RootParent).Location;
                    map = ((Mobile)ti.RootParent).Map;
                }
            }
            else if (target is Mobile)
            {
                Mobile ti = target as Mobile;

                loc = ti.Location;
                map = ti.Map;
            }

            if (BaseXmlSpawner.IsTypeOrItemKeyword(typeName))
            {
                BaseXmlSpawner.SpawnTypeKeyword(target, TheSpawn, typeName, substitutedtypeName, true, mob, loc, map, out status_str);
            }
            else
            {
                // its a regular type descriptor so find out what it is
                Type type = SpawnerType.GetType(typeName);
                try
                {
                    string[] arglist = BaseXmlSpawner.ParseString(substitutedtypeName, 3, "/");
                    object   o       = Server.Mobiles.XmlSpawner.CreateObject(type, arglist[0]);

                    if (o == null)
                    {
                        status_str = "invalid type specification: " + arglist[0];
                    }
                    else
                    if (o is Mobile)
                    {
                        Mobile m = (Mobile)o;
                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = loc;     // Spawners location is the home point
                        }

                        m.Location = loc;
                        m.Map      = map;

                        BaseXmlSpawner.ApplyObjectStringProperties(null, substitutedtypeName, m, mob, target, out status_str);
                    }
                    else
                    if (o is Item)
                    {
                        Item item = (Item)o;
                        BaseXmlSpawner.AddSpawnItem(null, target, TheSpawn, item, loc, map, mob, false, substitutedtypeName, out status_str);
                    }
                }
                catch { }
            }

            ReportError(mob, status_str);
        }
示例#41
0
 /// <summary>
 /// Setup <fern, bush, bananaTree, etc.>
 /// </summary>
 /// <param name="type"></param>
 void setupTypeProps(SpawnerType type, Vector3 position)
 {
     GameObject[] stuff = new GameObject[1];
     switch(type) {
         case (SpawnerType.Banana):
             stuff = new GameObject[4];
             stuff[0] = BananaSignifier[Random.Range(0, 5)]; // Tree
             stuff[1] = BananaSignifier[5]; // Rock
             stuff[2] = BananaSignifier[5]; // Rock
             stuff[3] = BananaSignifier[5]; // Rock
             break;
         case (SpawnerType.Stick):
             stuff = new GameObject[3];
             stuff[0] = StickSignifier[0]; // Rock
             stuff[1] = StickSignifier[1]; // Roots
             stuff[2] = StickSignifier[1]; // Roots
             break;
         case (SpawnerType.Sap):
             stuff = new GameObject[1];
             stuff[0] = SapSignifier[Random.Range(0, 2)]; // Tree-hollow
             break;
         case (SpawnerType.Leaf):
             stuff = new GameObject[2];
             stuff[0] = LeafSignifier[0]; // Fern
             stuff[1] = LeafSignifier[0]; // Fern
             break;
         case (SpawnerType.Berry):
             stuff = new GameObject[5];
             stuff[0] = BerrySignifier[Random.Range(0, 2)]; // Bush
             stuff[1] = BerrySignifier[Random.Range(0, 2)]; // Bush
             stuff[2] = BerrySignifier[Random.Range(0, 2)]; // Bush
             stuff[3] = BerrySignifier[2]; // Rock
             stuff[4] = BerrySignifier[2]; // Rock
             break;
         default:
             break;
     }
     foreach (GameObject go in stuff) {
         Vector3 randomVector = Random.insideUnitSphere * 5;
         randomVector.y = 5f;
         AreaPlacement(5, position + randomVector, go, transform);
     }
 }