Example #1
0
		public NPC()
		{
			npcId = -1;
			activeNpc = false;
			npcName = String.Empty;
			npcPosition = new PointSingle(0, 0);
			isNpcHomeless = false;
			npcHomeTile = new Point(0, 0);
			npcType = NPCType.Unknown;
		}
Example #2
0
		public NPC(Int32 id, Boolean active, String name, PointSingle pos, Boolean homeless, Point home)
		{
			npcId = id;
			activeNpc = active;
			npcName = name;
			isNpcHomeless = homeless;
			npcHomeTile = home;
			npcPosition = pos;
			npcType = NPCType.Unknown;
		}
Example #3
0
 public NPC(NPCType type, Vector2 pos, Vector2 facing, Texture2D spr)
 {
     Position = pos;
     Sprite = spr;
     tag = type;
     switch (type) {
         case NPCType.Police:
             vision = new Vision(Rectangle, 50.0f, 1, facing, Color.Red);
             speed = 10;
             break;
     }
 }
Example #4
0
        public NPCData()
        {
            switch (stringType)
            {
                case "talk":
                    type = NPCType.Talk;
                    break;

                case "shop":
                    type = NPCType.Shop;
                    break;
            }
        }
Example #5
0
    public virtual void Initialize()
    {
        List_NPC        = new List <GameObject>();
        GS_StateMachine = new StateMachine <BaseNPC>(this);
        type            = NPCType.wanderer;


        GS_StateMachine.ChangeState(Idle.Instance);

        Debug.Log("Potato 1 LoadOrder: BaseNPC name:" + this.name + " || Initialize() || Current State: " + GS_StateMachine.CurrentState.GetType().ToString());
        if (this.GetComponent <NavMeshAgent>() != null)
        {
            Nav_Agent = this.GetComponent <NavMeshAgent>();
        }
        else
        {
            Nav_Agent = this.gameObject.AddComponent(typeof(NavMeshAgent)) as NavMeshAgent;
        }

        npc_details = new NPCReport();
    }
Example #6
0
        /// <summary>
        /// 返回四张图片 形成动画
        /// </summary>
        /// <param name="mtype"></param>
        /// <returns></returns>
        public static String[] GetImagePaths(NPCType type)
        {
            switch (type)
            {
            case NPCType.老人:
                return(new string[] { "/res/icons/characters/NPC01-01.png", "/res/icons/characters/NPC01-02.png", "/res/icons/characters/NPC01-03.png", "/res/icons/characters/NPC01-04.png" });

            case NPCType.商人:
                return(new string[] { "/res/icons/characters/NPC02-01.png", "/res/icons/characters/NPC02-02.png", "/res/icons/characters/NPC02-03.png", "/res/icons/characters/NPC02-04.png" });

            case NPCType.小偷:
                return(new string[] { "/res/icons/characters/NPC03-01.png", "/res/icons/characters/NPC03-02.png", "/res/icons/characters/NPC03-03.png", "/res/icons/characters/NPC03-04.png" });

            case NPCType.仙子:
                return(new string[] { "/res/icons/characters/NPC04-01.png", "/res/icons/characters/NPC04-02.png", "/res/icons/characters/NPC04-03.png", "/res/icons/characters/NPC04-04.png" });

            case NPCType.奇怪的老人:
                return(new string[] { "/res/icons/characters/NPC05-01.png", "/res/icons/characters/NPC05-02.png", "/res/icons/characters/NPC05-03.png", "/res/icons/characters/NPC05-04.png" });
            }
            return(null);
        }
        public void AfterItemTypesDefined()
        {
            var defaults = new NPCTypeStandardSettings();

            foreach (var jobExtender in LoadedAssembalies)
            {
                if (Activator.CreateInstance(jobExtender) is INPCTypeStandardSettings settings &&
                    !string.IsNullOrEmpty(settings.keyName))
                {
                    NPCType.AddSettings(new NPCTypeStandardSettings
                    {
                        keyName           = settings.keyName,
                        maskColor1        = settings.maskColor1,
                        maskColor0        = settings.maskColor0,
                        Type              = NPCTypeID.GetID(settings.keyName),
                        inventoryCapacity = settings.inventoryCapacity == 0 ? defaults.inventoryCapacity : settings.inventoryCapacity,
                        movementSpeed     = settings.movementSpeed == 0 ? defaults.movementSpeed : settings.movementSpeed,
                    });
                }
            }
        }
        static void Fetch()
        {
            GetZombieACalculator.MonsterAA = NPCType.GetByKeyNameOrDefault("pipliz.monsteraa");
            GetZombieACalculator.MonsterAB = NPCType.GetByKeyNameOrDefault("pipliz.monsterab");
            GetZombieACalculator.MonsterAC = NPCType.GetByKeyNameOrDefault("pipliz.monsterac");

            GetZombieBCalculator.MonsterBA = NPCType.GetByKeyNameOrDefault("pipliz.monsterba");
            GetZombieBCalculator.MonsterBB = NPCType.GetByKeyNameOrDefault("pipliz.monsterbb");
            GetZombieBCalculator.MonsterBC = NPCType.GetByKeyNameOrDefault("pipliz.monsterbc");

            GetZombieCCalculator.MonsterCA = NPCType.GetByKeyNameOrDefault("pipliz.monsterca");
            GetZombieCCalculator.MonsterCB = NPCType.GetByKeyNameOrDefault("pipliz.monstercb");
            GetZombieCCalculator.MonsterCC = NPCType.GetByKeyNameOrDefault("pipliz.monstercc");

            DistributionCalculators[nameof(ZombieADistribution)] = new ZombieADistribution();
            DistributionCalculators[nameof(ZombieBDistribution)] = new ZombieBDistribution();
            DistributionCalculators[nameof(ZombieCDistribution)] = new ZombieCDistribution();

            SpawnCalcuators.Add(new GetZombieACalculator());
            SpawnCalcuators.Add(new GetZombieBCalculator());
            SpawnCalcuators.Add(new GetZombieCCalculator());
        }
Example #9
0
        public Dialogue ReadDialogOrders(NPCType type)
        {
            string        dialogOrderFilename = type.ToString() + "DialogOrder.Text";
            List <Choice> choices             = new List <Choice>();

            using (StreamReader sr = new StreamReader(dialogOrderFilename))
            {
                while (sr.Peek() >= 0)
                {
                    string   line    = sr.ReadLine();   // read in 1 line at a time
                    string[] quartet = line.Split(','); // split 3 ints by the ,
                    int      from    = Convert.ToInt32(quartet[0]);
                    int      act     = Convert.ToInt32(quartet[1]);
                    int      react   = Convert.ToInt32(quartet[2]);
                    int      att     = Convert.ToInt32(quartet[2]);
                    Choice   ch      = new Choice(from, act, react, att);
                    choices.Add(ch);// add this current choice to the List<>
                }
            }
            // now we have all info for this vendor's dialog/plot, so create his Dialog Object...
            return(new Dialogue(lexicon, choices));
        }
    public NPC GetNPC(NPCType type)
    {
        switch (type)
        {
        case NPCType.Beggar:
            NPC beggar = new Beggar();
            return(beggar);

        case NPCType.Farmer:
            NPC farmer = new Farmer();
            return(farmer);

        case NPCType.Shopowener:
            NPC shopOwner = new Shopowener();
            return(shopOwner);

        case NPCType.Villager:
            NPC villager = new Villager();
            return(villager);
        }
        return(null);
    }
Example #11
0
    public INPC getNPC(NPCType type)
    {
        switch (type)
        {
        case NPCType.Beggar:
            INPC beggar = new Beggar();
            return(beggar);

        case NPCType.Farmer:
            INPC farmer = new Farmer();
            return(farmer);

        case NPCType.Shopowner:
            INPC shopowner = new ShopOwner();
            return(shopowner);

        case NPCType.QuestGiver:
            INPC questgiver = new QuestGiver();
            return(questgiver);
        }
        return(null);
    }
Example #12
0
 public GeneratorJobSettings(string blockType, string npcTypeKey, InventoryItem energyItem, float craftingCooldown = 5f, int maxCraftsPerHaul = 5, string onCraftedAudio = null)
 {
     if (blockType != null)
     {
         ItemTypes.ItemType baseType = ItemTypes.GetType(blockType);
         bool baseHasRotated         = baseType.RotatedXPlus != null;
         BlockTypes = new ItemTypes.ItemType[5]
         {
             baseType,
             baseHasRotated ? ItemTypes.GetType(baseType.RotatedXPlus) : ItemTypes.GetType(blockType + "x+"),
             baseHasRotated ? ItemTypes.GetType(baseType.RotatedXMinus) : ItemTypes.GetType(blockType + "x-"),
             baseHasRotated ? ItemTypes.GetType(baseType.RotatedZPlus) : ItemTypes.GetType(blockType + "z+"),
             baseHasRotated ? ItemTypes.GetType(baseType.RotatedZMinus) : ItemTypes.GetType(blockType + "z-")
         };
     }
     NPCTypeKey       = npcTypeKey;
     NPCType          = NPCType.GetByKeyNameOrDefault(npcTypeKey);
     CraftingCooldown = craftingCooldown;
     MaxCraftsPerHaul = maxCraftsPerHaul;
     OnCraftedAudio   = onCraftedAudio;
     EnergyItem       = energyItem;
 }
    public INPC GetNPC(NPCType type)
    {
        switch (type)
        {
        case NPCType.Beggar:
            INPC beggar = new Beggar();
            return(beggar);

        case NPCType.Farmer:
            INPC farmer = new Farmer();
            return(farmer);

        case NPCType.Shopowner:
            INPC shopowner = new Shopowner();
            return(shopowner);

        case NPCType.Guard:
            INPC guard = new Guard();
            return(guard);
        }
        return(null);
    }
        public static bool CaclulateZombie(Banner banner, Colony colony, NPCType typeToSpawn, int RecycleFrequency = 1, float maxSpawnWalkDistance = 500f, IPandaBoss boss = null)
        {
            Path path;

            if (RecycleFrequency > 1 && MonsterSpawner.PathCache.TryGetPath(RecycleFrequency, banner.KeyLocation, maxSpawnWalkDistance, out path))
            {
                SpawnPandaZombie(typeToSpawn, path, colony, boss);
                return(true);
            }
            Vector3Int positionFinal;

            switch (MonsterSpawner.TryGetSpawnLocation(banner, maxSpawnWalkDistance, out positionFinal))
            {
            case MonsterSpawner.ESpawnResult.Success:
                if (AIManager.ZombiePathFinder.TryFindPath(positionFinal, banner.KeyLocation, out path, 2000000000) == EPathFindingResult.Success)
                {
                    if (RecycleFrequency > 1)
                    {
                        MonsterSpawner.PathCache.AddCopy(path);
                    }
                    SpawnPandaZombie(typeToSpawn, path, colony, boss);
                    return(true);
                }
                colony.OnZombieSpawn(false);
                return(false);

            case MonsterSpawner.ESpawnResult.NotLoaded:
            case MonsterSpawner.ESpawnResult.Impossible:
                colony.OnZombieSpawn(true);
                return(true);

            case MonsterSpawner.ESpawnResult.Fail:
                colony.OnZombieSpawn(false);
                return(true);

            default:
                return(false);
            }
        }
Example #15
0
        public static void SpawnZombie(Colony colony, Banner bannerGoal, NPCType typeToSpawn)
        {
            float maxSpawnWalkDistance = 500f;

            if (TimeCycle.ShouldSpawnMonsters && typeToSpawn.TryGetSettings(out NPCTypeMonsterSettings nPCTypeMonsterSettings))
            {
                maxSpawnWalkDistance = TimeCycle.NightLengthLeftInRealSeconds * (nPCTypeMonsterSettings.movementSpeed * 0.85f) + (float)bannerGoal.SafeRadius;
            }

            switch (TryGetSpawnLocation(bannerGoal, maxSpawnWalkDistance, out Vector3Int start))
            {
            case MonsterSpawner.ESpawnResult.Success:
            {
                Path path;
                if (AIManager.ZombiePathFinder.TryFindPath(start, bannerGoal.KeyLocation, out path, 2000000000) == EPathFindingResult.Success)
                {
                    IMonster monster = new Zombie(typeToSpawn, path, bannerGoal.Owner);
                    ModLoader.TriggerCallbacks <IMonster>(ModLoader.EModCallbackType.OnMonsterSpawned, monster);
                    MonsterTracker.Add(monster);
                    colony.OnZombieSpawn(true);
                }
                else
                {
                    colony.OnZombieSpawn(false);
                }

                break;
            }

            case MonsterSpawner.ESpawnResult.NotLoaded:
                colony.OnZombieSpawn(true);
                break;

            case MonsterSpawner.ESpawnResult.Fail:
                colony.OnZombieSpawn(false);
                break;
            }
        }
Example #16
0
    public void Combine(NPCType type, bool p_appendDataMarker)
    {
        m_questPercentage = type.m_questPercentage;
        m_priorityType    = type.m_priorityType;

        if (type.m_incompatibleTypes.Count > 0)
        {
            m_incompatibleTypes.AddRange(type.m_incompatibleTypes);
        }

        if (type.m_minimumStats.Count > 0)
        {
            m_minimumStats.Clear();
            m_minimumStats.AddRange(type.m_minimumStats);
        }

        if (type.m_maximumStats.Count > 0)
        {
            m_maximumStats.Clear();
            m_maximumStats.AddRange(type.m_maximumStats);
        }

        if (type.m_maleNames.Count > 0)
        {
            m_maleNames.AddRange(type.m_maleNames);
        }

        if (type.m_femaleNames.Count > 0)
        {
            m_femaleNames.AddRange(type.m_femaleNames);
        }

        if (type.m_maleSprites.Count > 0)
        {
            foreach (SerializableSprite sprite in type.m_maleSprites)
            {
                if (p_appendDataMarker)
                {
                    sprite.m_internal = false;
                }

                m_maleSprites.Add(sprite);
            }
        }

        if (type.m_femaleSprites.Count > 0)
        {
            foreach (SerializableSprite sprite in type.m_femaleSprites)
            {
                if (p_appendDataMarker)
                {
                    sprite.m_internal = false;
                }

                m_maleSprites.Add(sprite);
            }
        }

        if (type.m_defaultStates.Count > 0)
        {
            m_defaultStates.Clear();
            m_defaultStates.AddRange(type.m_defaultStates);
        }

        if (type.m_looks.Count > 0)
        {
            m_looks.Clear();
            m_looks.AddRange(type.m_looks);
        }

        if (type.m_greetings.Count > 0)
        {
            foreach (string greeting in type.m_greetings)
            {
                m_greetings.Add(greeting + (p_appendDataMarker ? "-External" : ""));
            }
        }

        if (type.m_quests.Count > 0)
        {
            foreach (string quest in type.m_quests)
            {
                m_quests.Add(quest + (p_appendDataMarker ? "-External" : ""));
            }
        }
    }
Example #17
0
        private void CreateNPCBaseInformationGUI()
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("npc的id:", labelLayouts);

            npc.npcId = EditorGUILayout.IntField(npc.npcId, normalInputLayouts);

            GUILayout.EndHorizontal();

            // name 编辑行
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("npc名称:", labelLayouts);

            npc.npcName = EditorGUILayout.TextField(npc.npcName, normalInputLayouts);

            EditorGUILayout.EndHorizontal();

            // npc图片名称编辑行
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("npc图片名称:", labelLayouts);

            npc.spriteName = EditorGUILayout.TextField(npc.spriteName, normalInputLayouts);

            EditorGUILayout.EndHorizontal();

            // npc类型编辑行
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("npc的类型:", labelLayouts);

            npcType = (NPCType)EditorGUILayout.EnumPopup(npcType, toggleLayouts);



            EditorGUILayout.EndHorizontal();

            switch (npcType)
            {
            case NPCType.Normal:
                break;

            case NPCType.Trader:

                EditorGUILayout.BeginHorizontal();

                bool addNewGoodsGroup = GUILayout.Button("新增商品组:", new GUILayoutOption[] {
                    GUILayout.Height(20),
                    GUILayout.Width(100)
                });

                bool removeLastGoodsGroup = GUILayout.Button("删除尾部商品组", new GUILayoutOption[] {
                    GUILayout.Height(20),
                    GUILayout.Width(100)
                });

                EditorGUILayout.EndHorizontal();

                if (addNewGoodsGroup)
                {
                    GoodsGroup goodsGroup = new GoodsGroup();

                    npc.goodsGroupList.Add(goodsGroup);

                    bool goodsGroupFoldout = false;

                    goodsGroupFoldoutList.Add(goodsGroupFoldout);
                }

                if (removeLastGoodsGroup && npc.goodsGroupList.Count > 0)
                {
                    npc.goodsGroupList.RemoveAt(npc.goodsGroupList.Count - 1);
                    goodsGroupFoldoutList.RemoveAt(goodsGroupFoldoutList.Count - 1);
                }

                for (int i = 0; i < npc.goodsGroupList.Count; i++)
                {
                    GoodsGroup goodsGroup = npc.goodsGroupList [i];


                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.LabelField(string.Format("商品组{0}对应的关卡", i), labelLayouts);

                    goodsGroup.accordLevel = EditorGUILayout.IntField(goodsGroup.accordLevel, normalInputLayouts);

                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();

                    bool addNewGoods = GUILayout.Button("新增商品组", new GUILayoutOption[] {
                        GUILayout.Height(20),
                        GUILayout.Width(100)
                    });

                    bool removeLastGoods = GUILayout.Button("删除尾部商品组", new GUILayoutOption[] {
                        GUILayout.Height(20),
                        GUILayout.Width(100)
                    });



                    if (addNewGoods)
                    {
                        Goods goods = new Goods();
                        goodsGroup.goodsList.Add(goods);
                    }

                    if (removeLastGoods && goodsGroup.goodsList.Count > 0)
                    {
                        goodsGroup.goodsList.RemoveAt(goodsGroup.goodsList.Count - 1);
                    }

                    for (int j = 0; j < goodsGroup.goodsList.Count; j++)
                    {
                        Goods goods = goodsGroup.goodsList [j];

                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.LabelField("物品id组:", new GUILayoutOption[] {
                            GUILayout.Height(20),
                            GUILayout.Width(50)
                        });

                        string possibleGoodsIdsInString = goodsIdsInString[i][j];
                        possibleGoodsIdsInString = EditorGUILayout.TextField(possibleGoodsIdsInString, normalInputLayouts);

                        goods.possibleItemIdsAsGoods = IdsStringToIntArray(possibleGoodsIdsInString);

                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.EndHorizontal();
                }

                break;
            }

            // npc打招呼文字编辑行
            EditorGUILayout.LabelField("npc打招呼文字:", labelLayouts);

            npc.greetingDialog = EditorGUILayout.TextArea(npc.greetingDialog, textInputLayouts);

            // npc附加功能编辑组

            EditorGUILayout.LabelField("npc附加功能编辑区:", labelLayouts);


            skillPromotionFunction = EditorGUILayout.Toggle("技能提升", skillPromotionFunction, toggleLayouts);

            propertyPromotionFunction = EditorGUILayout.Toggle("属性提升", propertyPromotionFunction, toggleLayouts);

            taskFunction = EditorGUILayout.Toggle("任务", taskFunction, toggleLayouts);

            characterTradeFunction = EditorGUILayout.Toggle("交易", characterTradeFunction, toggleLayouts);
        }
Example #18
0
 public static void Init()
 {
     NPCType.AddSettings(_knightNPCSettings);
     KnightNPCType = NPCType.GetByKeyNameOrDefault(_knightNPCSettings.keyName);
 }
 public static void Register <T> (string blockName) where T : ITrackableBlock, IBlockJobBase, INPCTypeDefiner, new()
 {
     NPCType.AddSettings(new T().GetNPCTypeDefinition());
     InstanceList.Add(new BlockJobManager <T>(blockName));
 }
Example #20
0
        public void CreateNPC(NPCType tag, Vector2 position)
        {
            NPC npc = new NPC();
            npc.tag = tag;
            npc.position = position;
            npc.stateTime = 0;
            switch (tag)
            {
                case NPCType.PoliceA:
                    //lack of break here is intentional!  We want both police managed the same way here
                case NPCType.PoliceB:
                    npc.sprite = policeTexture;
                    npc.rectangleBounds = new Point(SPRITE_SIZE, SPRITE_SIZE);

                    for (int i = 0; i < numVisions; i++)
                    {
                        float angle = (i - numVisions/2) * viewWidth;
                        npc.visions.Add(new Vision(npc.worldRectangle, viewDistance, viewWidth / 2, new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)), Color.Red));
                    }
                    npc.vision = new Vision(npc.worldRectangle, viewDistance, maxWidth / 2, new Vector2(1, 0), Color.Red);
                    npc.rotateSpeed = .001;
                    npc.moveSpeed = 0.1f;
                    npc.state = NPCState.PatrolLeft;
                    break;
            }
            this.AddNPC(npc);
        }
Example #21
0
        override public List <ZoneEntryStruct> GetSpawns()
        {
            List <ZoneEntryStruct> ZoneSpawns = new List <ZoneEntryStruct>();

            List <byte[]> SpawnPackets = GetPacketsOfType("OP_ZoneEntry", PacketDirection.ServerToClient);

            foreach (byte[] SpawnPacket in SpawnPackets)
            {
                ZoneEntryStruct newSpawn = new ZoneEntryStruct();

                ByteStream buffer = new ByteStream(SpawnPacket);

                newSpawn.SpawnName = buffer.ReadString(true);

                newSpawn.SpawnName = Utils.MakeCleanName(newSpawn.SpawnName);

                newSpawn.SpawnID = buffer.ReadUInt32();

                newSpawn.Level = buffer.ReadByte();

                float UnkSize = buffer.ReadSingle();

                newSpawn.IsNPC = buffer.ReadByte();

                UInt32 Bitfield = buffer.ReadUInt32();

                newSpawn.Gender = (Bitfield & 3);

                Byte OtherData = buffer.ReadByte();

                buffer.SkipBytes(8);    // Skip 8 unknown bytes

                newSpawn.DestructableString1 = "";
                newSpawn.DestructableString2 = "";
                newSpawn.DestructableString3 = "";

                if ((newSpawn.IsNPC > 0) && ((OtherData & 1) > 0))
                {
                    // Destructable Objects
                    newSpawn.DestructableString1 = buffer.ReadString(false);
                    newSpawn.DestructableString2 = buffer.ReadString(false);
                    newSpawn.DestructableString3 = buffer.ReadString(false);
                    buffer.SkipBytes(53);
                }

                if ((OtherData & 4) > 0)
                {
                    // Auras
                    buffer.ReadString(false);
                    buffer.ReadString(false);
                    buffer.SkipBytes(54);
                }

                newSpawn.PropCount = buffer.ReadByte();

                if (newSpawn.PropCount > 0)
                {
                    newSpawn.BodyType = buffer.ReadUInt32();
                }
                else
                {
                    newSpawn.BodyType = 0;
                }


                for (int j = 1; j < newSpawn.PropCount; ++j)
                {
                    buffer.SkipBytes(4);
                }

                buffer.SkipBytes(1);   // Skip HP %
                newSpawn.HairColor  = buffer.ReadByte();
                newSpawn.BeardColor = buffer.ReadByte();
                newSpawn.EyeColor1  = buffer.ReadByte();
                newSpawn.EyeColor2  = buffer.ReadByte();
                newSpawn.HairStyle  = buffer.ReadByte();
                newSpawn.Beard      = buffer.ReadByte();

                newSpawn.DrakkinHeritage = buffer.ReadUInt32();
                newSpawn.DrakkinTattoo   = buffer.ReadUInt32();
                newSpawn.DrakkinDetails  = buffer.ReadUInt32();

                newSpawn.EquipChest2 = buffer.ReadByte();

                bool UseWorn = (newSpawn.EquipChest2 == 255);

                buffer.SkipBytes(2);    // 2 Unknown bytes;

                newSpawn.Helm = buffer.ReadByte();

                newSpawn.Size = buffer.ReadSingle();

                newSpawn.Face = buffer.ReadByte();

                newSpawn.WalkSpeed = buffer.ReadSingle();

                newSpawn.RunSpeed = buffer.ReadSingle();

                newSpawn.Race = buffer.ReadUInt32();

                buffer.SkipBytes(1);   // Skip Holding

                newSpawn.Deity = buffer.ReadUInt32();

                buffer.SkipBytes(8);    // Skip GuildID and GuildRank

                newSpawn.Class = buffer.ReadByte();

                buffer.SkipBytes(4);     // Skip PVP, Standstate, Light, Flymode

                newSpawn.LastName = buffer.ReadString(true);

                buffer.SkipBytes(6);

                newSpawn.PetOwnerID = buffer.ReadUInt32();

                buffer.SkipBytes(25);

                newSpawn.MeleeTexture1 = 0;
                newSpawn.MeleeTexture2 = 0;

                if ((newSpawn.IsNPC == 0) || NPCType.IsPlayableRace(newSpawn.Race))
                {
                    for (int ColourSlot = 0; ColourSlot < 9; ++ColourSlot)
                    {
                        newSpawn.SlotColour[ColourSlot] = buffer.ReadUInt32();
                    }

                    for (int i = 0; i < 9; ++i)
                    {
                        newSpawn.Equipment[i] = buffer.ReadUInt32();

                        UInt32 Equip3 = buffer.ReadUInt32();

                        UInt32 Equip2 = buffer.ReadUInt32();

                        UInt32 Equip1 = buffer.ReadUInt32();

                        UInt32 Equip0 = buffer.ReadUInt32();
                    }

                    if (newSpawn.Equipment[Constants.MATERIAL_CHEST] > 0)
                    {
                        newSpawn.EquipChest2 = (byte)newSpawn.Equipment[Constants.MATERIAL_CHEST];
                    }

                    newSpawn.ArmorTintRed = (byte)((newSpawn.SlotColour[Constants.MATERIAL_CHEST] >> 16) & 0xff);

                    newSpawn.ArmorTintGreen = (byte)((newSpawn.SlotColour[Constants.MATERIAL_CHEST] >> 8) & 0xff);

                    newSpawn.ArmorTintBlue = (byte)(newSpawn.SlotColour[Constants.MATERIAL_CHEST] & 0xff);

                    if (newSpawn.Equipment[Constants.MATERIAL_PRIMARY] > 0)
                    {
                        newSpawn.MeleeTexture1 = newSpawn.Equipment[Constants.MATERIAL_PRIMARY];
                    }

                    if (newSpawn.Equipment[Constants.MATERIAL_SECONDARY] > 0)
                    {
                        newSpawn.MeleeTexture2 = newSpawn.Equipment[Constants.MATERIAL_SECONDARY];
                    }

                    if (UseWorn)
                    {
                        newSpawn.Helm = (byte)newSpawn.Equipment[Constants.MATERIAL_HEAD];
                    }
                    else
                    {
                        newSpawn.Helm = 0;
                    }
                }
                else
                {
                    // Non playable race

                    buffer.SkipBytes(20);

                    newSpawn.MeleeTexture1 = buffer.ReadUInt32();
                    buffer.SkipBytes(16);
                    newSpawn.MeleeTexture2 = buffer.ReadUInt32();
                    buffer.SkipBytes(16);
                }

                if (newSpawn.EquipChest2 == 255)
                {
                    newSpawn.EquipChest2 = 0;
                }

                if (newSpawn.Helm == 255)
                {
                    newSpawn.Helm = 0;
                }

                UInt32 Position1 = buffer.ReadUInt32();

                UInt32 Position2 = buffer.ReadUInt32();

                UInt32 Position3 = buffer.ReadUInt32();

                UInt32 Position4 = buffer.ReadUInt32();

                UInt32 Position5 = buffer.ReadUInt32();

                newSpawn.YPos = Utils.EQ19ToFloat((Int32)((Position1 >> 12) & 0x7FFFF));

                newSpawn.ZPos = Utils.EQ19ToFloat((Int32)(Position2) & 0x7FFFF);

                newSpawn.XPos = Utils.EQ19ToFloat((Int32)(Position4 >> 13) & 0x7FFFF);

                newSpawn.Heading = Utils.EQ19ToFloat((Int32)(Position3 >> 13) & 0xFFF);

                if ((OtherData & 16) > 0)
                {
                    newSpawn.Title = buffer.ReadString(false);
                }

                if ((OtherData & 32) > 0)
                {
                    newSpawn.Suffix = buffer.ReadString(false);
                }

                // unknowns
                buffer.SkipBytes(8);

                newSpawn.IsMercenary = buffer.ReadByte();

                buffer.SkipBytes(54);
                var expectedLength = buffer.Length();
                var currentPoint   = buffer.GetPosition();
                Debug.Assert(currentPoint == expectedLength, "Length mismatch while parsing zone spawns");

                ZoneSpawns.Add(newSpawn);
            }
            return(ZoneSpawns);
        }
Example #22
0
 public WaterZombie() :
     base(NPCType.GetByKeyNameOrDefault(Key), new Path(), GameLoader.StubColony)
 {
 }
 /// <summary>
 /// Checks if there are any active NPCs of specified type
 /// </summary>
 /// <param name="type">NPCType of the NPC to check for</param>
 /// <returns>True if active, false if not</returns>
 public static bool IsNPCSummoned(NPCType type)
 {
     return IsNPCSummoned((int)type);
 }
Example #24
0
                } // end npcReachDict

                public static bool TryGetNPCReach(NPCType type, out float reach) {
                    return npcReachDict.TryGetValue(type, out reach);
                } // end TryGetNPCReach
 public static int NewNPC(int x, int y, NPCType type, int start = 0, bool makespawn = false)
 {
     return NewNPC (x, y, (int)type, start, makespawn);
 }
Example #26
0
 public PandaZombie(NPCType nPCType, Path path, Players.Player originalGoal) :
     base(nPCType, path, originalGoal)
 {
 }
Example #27
0
 public Hoarder() :
     base(NPCType.GetByKeyNameOrDefault(Key), new Path(), new Players.Player(NetworkID.Invalid))
 {
 }
        public static bool EvaluateSettlers(Players.Player p)
        {
            var update = false;

            if (p.IsConnected)
            {
                var colony = Colony.Get(p);
                var state  = PlayerState.GetPlayerState(p);

                if (state.NextGenTime == 0)
                {
                    state.NextGenTime = Time.SecondsSinceStartDouble +
                                        Random.Next(8,
                                                    16 - Pipliz.Math.RoundToInt(p.GetTempValues(true)
                                                                                .GetOrDefault(PandaResearch.GetResearchKey(PandaResearch.TimeBetween),
                                                                                              0f))) * TimeCycle
                                        .SecondsPerHour;
                }

                if (Time.SecondsSinceStartDouble > state.NextGenTime && colony.FollowerCount >= MAX_BUYABLE)
                {
                    var chance =
                        p.GetTempValues(true)
                        .GetOrDefault(PandaResearch.GetResearchKey(PandaResearch.SettlerChance), 0f) +
                        state.Difficulty.AdditionalChance;

                    chance += SettlerEvaluation.SpawnChance(p, colony, state);

                    var rand = Random.NextFloat();

                    if (chance > rand)
                    {
                        var addCount = Math.Floor(state.MaxPerSpawn * chance);

                        // if we lost alot of colonists add extra to help build back up.
                        if (colony.FollowerCount < state.HighestColonistCount)
                        {
                            var diff = state.HighestColonistCount - colony.FollowerCount;
                            addCount += Math.Floor(diff * .25);
                        }

                        try
                        {
                            var skillChance = p.GetTempValues(true)
                                              .GetOrDefault(PandaResearch.GetResearchKey(PandaResearch.SkilledLaborer),
                                                            0f);

                            var numbSkilled = 0;

                            rand = Random.NextFloat();

                            try
                            {
                                if (skillChance > rand)
                                {
                                    numbSkilled =
                                        state.Rand.Next(1,
                                                        2 + Pipliz.Math.RoundToInt(p.GetTempValues(true)
                                                                                   .GetOrDefault(PandaResearch.GetResearchKey(PandaResearch.NumberSkilledLaborer),
                                                                                                 0f)));
                                }
                            }
                            catch (Exception ex)
                            {
                                PandaLogger.Log("NumberSkilledLaborer");
                                PandaLogger.LogError(ex);
                            }


                            if (addCount > 0)
                            {
                                if (addCount > 30)
                                {
                                    addCount = 30;
                                }

                                var reason = string.Format(SettlerReasoning.GetSettleReason(), addCount);

                                if (numbSkilled > 0)
                                {
                                    if (numbSkilled == 1)
                                    {
                                        reason += string.Format(" {0} of them is skilled!", numbSkilled);
                                    }
                                    else
                                    {
                                        reason += string.Format(" {0} of them are skilled!", numbSkilled);
                                    }
                                }

                                PandaChat.Send(p, reason, ChatColor.magenta);
                                var playerPos = new Vector3Int(p.Position);

                                for (var i = 0; i < addCount; i++)
                                {
                                    var newGuy = new NPCBase(NPCType.GetByKeyNameOrDefault("pipliz.laborer"),
                                                             BannerTracker.GetClosest(p, playerPos).KeyLocation.Vector,
                                                             colony);

                                    SettlerInventory.GetSettlerInventory(newGuy);
                                    newGuy.GetTempValues().Set(ISSETTLER, true);

                                    if (i <= numbSkilled)
                                    {
                                        var npcTemp = newGuy.GetTempValues(true);
                                        npcTemp.Set(GameLoader.ALL_SKILLS, state.Rand.Next(1, 10) * 0.002f);
                                    }

                                    update = true;
                                    ModLoader.TriggerCallbacks(ModLoader.EModCallbackType.OnNPCRecruited, newGuy);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            PandaLogger.Log("SkilledLaborer");
                            PandaLogger.LogError(ex);
                        }

                        if (colony.FollowerCount > state.HighestColonistCount)
                        {
                            state.HighestColonistCount = colony.FollowerCount;
                        }
                    }


                    state.NextGenTime = Time.SecondsSinceStartDouble +
                                        Random.Next(8,
                                                    16 - Pipliz.Math.RoundToInt(p.GetTempValues(true)
                                                                                .GetOrDefault(PandaResearch.GetResearchKey(PandaResearch.TimeBetween),
                                                                                              0f))) * TimeCycle
                                        .SecondsPerHour;

                    colony.SendUpdate();
                }
            }

            return(update);
        }
Example #29
0
        /// <summary>
        /// Generate a random NPC of the specified type (Profession or Adventurer)
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static DmNPC GenerateNPC( NPCType type )
        {
            DmNPC npc = new DmNPC();

              npc.race    = (NPCRace)rand.Next( Enum.GetValues( typeof(NPCRace) ).Length );
              AdjustStatsForRace( npc );

              npc.gender  = (NPCGender)rand.Next( Enum.GetValues( typeof(NPCGender) ).Length );
              npc.name    = DmNameGenerator.GenerateName( npc.race, npc.gender );

              npc.age     = (NPCAge)rand.Next( Enum.GetValues( typeof(NPCAge) ).Length );
              int numFeatures = rand.Next(11)-5;

              for( int i=0; i<numFeatures; i++ )
              {
            NPCFeatures feature = (NPCFeatures)rand.Next( Enum.GetValues( typeof( NPCFeatures ) ).Length );

            while( npc.features.Contains( feature ) )
              feature = (NPCFeatures)rand.Next( Enum.GetValues( typeof( NPCFeatures ) ).Length );

            npc.features.Add( feature );
              }

              npc.eyeColor = (NPCEyeColor)rand.Next( Enum.GetValues( typeof( NPCEyeColor ) ).Length );

              npc.hairColor = (NPCHairColor)rand.Next( Enum.GetValues( typeof( NPCHairColor ) ).Length );
              npc.hairStyle = (NPCHairStyle)rand.Next( Enum.GetValues( typeof( NPCHairStyle ) ).Length );
              npc.hairLength= (NPCHairLength)rand.Next( Enum.GetValues( typeof( NPCHairLength ) ).Length );

              if( npc.gender == NPCGender.Male )
            npc.facialHair = (NPCFacialHair)rand.Next( Enum.GetValues( typeof( NPCFacialHair ) ).Length );

              npc.bodySize = (NPCBodySize)rand.Next( Enum.GetValues( typeof( NPCBodySize ) ).Length );
              npc.bodyBuild = (NPCBodyBuild)rand.Next( Enum.GetValues( typeof( NPCBodyBuild ) ).Length );

              npc.characterType = type;
              if( npc.characterType == NPCType.Adventurer )
              {
            // make sure we choose something other than 'None'
            NPCTypeAdventurer iType = NPCTypeAdventurer.None;

            while( iType == NPCTypeAdventurer.None )
              iType = (NPCTypeAdventurer)rand.Next( Enum.GetValues( typeof( NPCTypeAdventurer ) ).Length );

            npc.characterClass = iType;
              }
              else
              {
            // unlike adventurer types, Profession can be 'None' - which indicates some sort of beggar or unemployed commoner
            npc.characterProfession= (NPCTypeProfession)rand.Next( Enum.GetValues( typeof( NPCTypeProfession ) ).Length );
              }

              npc.clothing  = GenerateClothing( npc );
              npc.armor     = GenerateArmor( npc );
              npc.weapons   = GenerateWeapons( npc );
              npc.inventory = GenerateInventory( npc );

              npc.mentalState = (NPCMentalState)rand.Next( Enum.GetValues( typeof( NPCMentalState ) ).Length );
              npc.mood        = (NPCMood)rand.Next( Enum.GetValues( typeof( NPCMood ) ).Length );
              npc.personality = (NPCPersonaliy)rand.Next( Enum.GetValues( typeof( NPCPersonaliy ) ).Length );

              return npc;
        }
Example #30
0
 public static void Init()
 {
     NPCType.AddSettings(_callToArmsNPCSettings);
     CallToArmsNPCType = NPCType.GetByKeyNameOrDefault(_callToArmsNPCSettings.keyName);
 }
Example #31
0
 public static void RegisterJobs()
 {
     NPCType.AddSettings(NPCTypeSettings);
     NPCType = NPCType.GetByKeyNameOrDefault(NPCTypeSettings.keyName);
 }
Example #32
0
        /// <summary>
        /// loads character from xml
        /// </summary>
        /// <param name="path">path to xml configuration</param>
        private void LoadFromFile(String path)
        {
            XmlDataDocument doc = new XmlDataDocument();

            doc.Load(path);

            foreach (XmlNode node in doc.GetElementsByTagName("NPC"))
            {
                foreach (XmlNode child in node.ChildNodes)
                {
                    switch (child.Name)
                    {
                    case "Name":
                        this.name = child.InnerText;
                        break;

                    case "Side":
                        this.side = (Side)Convert.ToInt32(child.InnerText);
                        break;

                    case "Type":
                        this.type = (NPCType)Convert.ToInt32(child.InnerText);
                        break;

                    case "VisualRange":
                        this.visualRange = Convert.ToInt32(child.InnerText);
                        break;

                    case "Attributes":
                        this.hp      = Convert.ToInt32(child.Attributes[hp].InnerText);
                        this.level   = Convert.ToInt32(child.Attributes["level"].InnerText);
                        this.mana    = Convert.ToInt32(child.Attributes["mana"].InnerText);
                        this.power   = Convert.ToInt32(child.Attributes["power"].InnerText);
                        this.defense = Convert.ToInt32(child.Attributes["defense"].InnerText);
                        break;

                    case "Priors":
                        Priorities priors = new Priorities();
                        priors.priorsList = new List <int>();
                        priors.killPrior  = Convert.ToInt32(child.Attributes["kill"].Value);
                        priors.priorsList.Add(priors.killPrior);
                        priors.livePrior = Convert.ToInt32(child.Attributes["live"].Value);
                        priors.priorsList.Add(priors.livePrior);
                        priors.hidePrior = Convert.ToInt32(child.Attributes["hide"].Value);
                        priors.priorsList.Add(priors.helpPrior);
                        priors.overviewPrior = Convert.ToInt32(child.Attributes["overview"].Value);
                        priors.priorsList.Add(priors.overviewPrior);
                        priors.surprisePrior = Convert.ToInt32(child.Attributes["surprise"].Value);
                        priors.priorsList.Add(priors.surprisePrior);
                        priors.boostPrior = Convert.ToInt32(child.Attributes["boost"].Value);
                        priors.priorsList.Add(priors.boostPrior);
                        priors.coverPrior = Convert.ToInt32(child.Attributes["cover"].Value);
                        priors.priorsList.Add(priors.coverPrior);
                        priors.helpPrior = Convert.ToInt32(child.Attributes["help"].Value);
                        priors.priorsList.Add(priors.helpPrior);
                        this.priors = priors;
                        break;
                    }
                }
            }
        }
Example #33
0
        public bool DrawMarker(NPCType type)
        {
            String npcType = Global.Instance.Info.MarkerImageToName(Enum.GetName(typeof(NPCType), type));

            if (this.settings.MarkerStates.ContainsKey(npcType))
                return this.settings.MarkerStates[npcType].Drawing;

            return false;
        }
Example #34
0
 public static void Init()
 {
     Logger.Log("Init Sick Job");
     NPCType.AddSettings(SickNPCSettings);
     SickNPCType = NPCType.GetByKeyNameOrDefault(SickNPCSettings.keyName);
 }
        private static void SpawnNpc(NPCType type, int spawnX, int spawnY, bool homeless)
        {
            int index = NPC.NewNPC(spawnX * 16, spawnY * 16, type, 0, true);
            Main.npcs[index].homeless = homeless;

            Main.npcs[index].homeTileX = Main.spawnTileX;
            Main.npcs[index].homeTileY = Main.spawnTileY;
            Main.npcs[index].direction = 1;
        }
Example #36
0
 public Hoarder() :
     base(NPCType.GetByKeyNameOrDefault(Key), new Path(), GameLoader.StubColony)
 {
 }
Example #37
0
 public JackbNimble() :
     base(NPCType.GetByKeyNameOrDefault(Key), new Path(), GameLoader.StubColony)
 {
 }
Example #38
0
        public void OnGUI()
        {
            Rect windowRect = npcEditor.position;

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, new GUILayoutOption[] {
                GUILayout.Height(windowRect.height),
                GUILayout.Width(windowRect.width)
            });

            EditorGUILayout.LabelField("please input information of npc");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("npc数据源", labelLayouts);

            rect        = EditorGUILayout.GetControlRect(GUILayout.Width(300));
            npcDataPath = EditorGUI.TextField(rect, npcDataPath);
            //如果鼠标正在拖拽中或拖拽结束时,并且鼠标所在位置在文本输入框内
            if ((UnityEngine.Event.current.type == UnityEngine.EventType.DragUpdated ||
                 UnityEngine.Event.current.type == UnityEngine.EventType.DragExited) &&
                rect.Contains(UnityEngine.Event.current.mousePosition))
            {
                //改变鼠标的外表
                DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
                {
                    npcDataPath = DragAndDrop.paths [0];
                }
            }


            EditorGUILayout.EndHorizontal();

            bool loadNpcData = GUILayout.Button("加载npc数据", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(150)
            });

            if (loadNpcData)
            {
                dialogGroups.Clear();
                chatDialogGroups.Clear();
                taskDialogGroups.Clear();

                dialogGroupFoldoutList.Clear();
                dialogFoldoutList.Clear();
                rewardTypeCountList.Clear();
                taskFoldoutList.Clear();

                string npcDataFileName = Path.GetFileName(npcDataPath);

                npcDataPath = string.Format("{0}/NPCs/{1}", CommonData.originDataPath, npcDataFileName);

                string npcTypeStr = npcDataFileName.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries)[0];


                npc = DataHandler.LoadDataToSingleModelWithPath <MyNpc> (npcDataPath);



                switch (npcTypeStr)
                {
                case "Normal":
                    npcType = NPCType.Normal;
                    break;

                case "Trader":
                    npcType          = NPCType.Trader;
                    goodsIdsInString = TransferGoodsIdsToString(npc);
                    break;
                }

                Debug.Log(npcDataPath);

                for (int i = 0; i < npc.chatDialogGroups.Count; i++)
                {
                    dialogGroups.Add(npc.chatDialogGroups [i]);
                    chatDialogGroups.Add(npc.chatDialogGroups [i]);

                    bool foldout = false;
                    dialogGroupFoldoutList.Add(foldout);

                    List <bool> foldoutList = new List <bool> ();
                    dialogFoldoutList.Add(foldoutList);

                    List <int> rewardTypeCounts = new List <int> ();
                    rewardTypeCountList.Add(rewardTypeCounts);

                    for (int j = 0; j < npc.chatDialogGroups [i].dialogs.Count; j++)
                    {
                        Dialog d             = npc.chatDialogGroups [i].dialogs [j];
                        bool   dialogFoldout = false;
                        foldoutList.Add(dialogFoldout);

                        rewardTypeCounts.Add(d.rewardIds.Length);
                    }
                }

                for (int i = 0; i < npc.tasks.Count; i++)
                {
                    dialogGroups.Add(npc.tasks [i].taskDialogGroup);
                    bool foldout = false;
                    taskFoldoutList.Add(foldout);
                    dialogGroupFoldoutList.Add(dialogGroupFoldout);
                    List <bool> foldoutList = new List <bool> ();
                    dialogFoldoutList.Add(foldoutList);
                    List <int> rewardTypeCounts = new List <int> ();
                    rewardTypeCountList.Add(rewardTypeCounts);

                    for (int j = 0; j < npc.tasks [i].taskDialogGroup.dialogs.Count; j++)
                    {
                        Dialog d             = npc.tasks [i].taskDialogGroup.dialogs [j];
                        bool   dialogFoldout = false;
                        foldoutList.Add(dialogFoldout);

                        rewardTypeCounts.Add(d.rewardIds.Length);
                    }
                }

                for (int i = 0; i < npc.attachedFunctions.Length; i++)
                {
                    if (npc.attachedFunctions [i] == NPCAttachedFunctionType.SkillPromotion)
                    {
                        skillPromotionFunction = true;
                    }
                    if (npc.attachedFunctions [i] == NPCAttachedFunctionType.PropertyPromotion)
                    {
                        propertyPromotionFunction = true;
                    }
                    if (npc.attachedFunctions [i] == NPCAttachedFunctionType.Task)
                    {
                        taskFunction = true;
                    }
                    if (npc.attachedFunctions [i] == NPCAttachedFunctionType.CharactersTrade)
                    {
                        characterTradeFunction = true;
                    }
                }
            }

            CreateNPCBaseInformationGUI();



            EditorGUILayout.BeginHorizontal();
            bool createNewDialogGroup = GUILayout.Button("新建对话组", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(200)
            });

            bool removeLastDialogGroup = GUILayout.Button("删除尾部对话组", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(200)
            });

            EditorGUILayout.EndHorizontal();

            if (createNewDialogGroup)
            {
                DialogGroup chatDialogGroup = new DialogGroup();
                dialogGroups.Add(chatDialogGroup);
                bool foldout = true;
                dialogGroupFoldoutList.Add(foldout);
                List <bool> foldoutList = new List <bool> ();
                dialogFoldoutList.Add(foldoutList);
                List <int> rewardTypeCounts = new List <int> ();
                rewardTypeCountList.Add(rewardTypeCounts);
                ReCalculateDialogGroups();
            }

            if (removeLastDialogGroup && chatDialogGroups.Count > 0)
            {
                DialogGroup dg = chatDialogGroups [chatDialogGroups.Count - 1];

                int index = dialogGroups.FindIndex(delegate(DialogGroup obj) {
                    return(obj == dg);
                });
                dialogGroupFoldoutList.RemoveAt(index);
                dialogFoldoutList.RemoveAt(index);
                rewardTypeCountList.RemoveAt(index);

                chatDialogGroups.Remove(dg);
                dialogGroups.Remove(dg);

                ReCalculateDialogGroups();
            }



            for (int i = 0; i < chatDialogGroups.Count; i++)
            {
                DialogGroup dg = chatDialogGroups [i];

                int index = dialogGroups.FindIndex(delegate(DialogGroup obj) {
                    return(obj == dg);
                });

                List <bool> currentDialogFoldoutList = dialogFoldoutList [index];

                List <int> currentDialogRewardTypeCountList = rewardTypeCountList [index];

                dialogGroupFoldoutList [index] = EditorGUILayout.Foldout(dialogGroupFoldoutList [index], "对话组编辑区");

                if (dialogGroupFoldoutList [index])
                {
                    CreateDialogGroupGUI(dg, currentDialogFoldoutList, currentDialogRewardTypeCountList);
                }
            }


            EditorGUILayout.BeginHorizontal();
            bool createNewTask = GUILayout.Button("新建任务", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(200)
            });

            bool removeLastTask = GUILayout.Button("删除尾部任务", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(200)
            });

            EditorGUILayout.EndHorizontal();


            if (createNewTask)
            {
                Task task = new Task();
                npc.tasks.Add(task);
                DialogGroup taskDialogGroup = new DialogGroup();
                dialogGroups.Add(taskDialogGroup);
                task.taskDialogGroup = taskDialogGroup;
                bool foldout = true;
                taskFoldoutList.Add(foldout);
                dialogGroupFoldoutList.Add(dialogGroupFoldout);
                List <bool> foldoutList = new List <bool> ();
                dialogFoldoutList.Add(foldoutList);
                List <int> rewardIdsCount = new List <int> ();
                rewardTypeCountList.Add(rewardIdsCount);
                ReCalculateDialogGroups();
            }

            if (removeLastTask && npc.tasks.Count > 0)
            {
                Task task = npc.tasks [npc.tasks.Count - 1];

                npc.tasks.RemoveAt(npc.tasks.Count - 1);

                taskFoldoutList.RemoveAt(taskFoldoutList.Count - 1);



                int index = dialogGroups.FindIndex(delegate(DialogGroup obj) {
                    return(obj == task.taskDialogGroup);
                });

                dialogGroupFoldoutList.RemoveAt(index);
                dialogFoldoutList.RemoveAt(index);
                rewardTypeCountList.RemoveAt(index);

                taskDialogGroups.Remove(task.taskDialogGroup);
                dialogGroups.Remove(task.taskDialogGroup);

                ReCalculateDialogGroups();
            }

            for (int i = 0; i < npc.tasks.Count; i++)
            {
                Task task = npc.tasks [i];
                taskFoldoutList [i] = EditorGUILayout.Foldout(taskFoldoutList [i], "任务编辑区");
                if (taskFoldoutList [i])
                {
                    CreateTaskGUI(task);
                }
            }

//			EditorGUILayout.Separator ();
//			EditorGUILayout.LabelField ("************************结束*************************", new GUILayoutOption[] {
//				GUILayout.Height (20),
//				GUILayout.Width (600)
//			});
            bool saveNpcData = GUILayout.Button("保存NPC数据", new GUILayoutOption[] {
                GUILayout.Width(500),
                GUILayout.Height(20)
            });

            if (saveNpcData)
            {
                SaveNpcData();
            }



            EditorGUILayout.EndScrollView();
        }
Example #39
0
        //this entire system is a mess and I hate the specific location access for the values, but for now it will do, need to refactor.
        public bool unlockNPC(NPCType type)
        {
            NPC currNPC = (NPC)NPCs[(int)type];

            int npcCost = currNPC.getCost();
            if (spendMoney(npcCost))
            {
                //money -= npcCost;
                currNPC.isAvaliable = true;
                return true;
            }
            return false;
        }
Example #40
0
 public WaterZombie(Path path, Colony originalGoal) :
     base(NPCType.GetByKeyNameOrDefault(Key), path, originalGoal)
 {
     TotalHealth   = _totalHealth;
     CurrentHealth = _totalHealth;
 }
Example #41
0
 public NPC(string _name, NPCType _type)
 {
     this.name = _name;
     this.type = _type;
 }