public override void Enter(object data) { GlobalGameStateManager.PosessionState = PosessionState.NON_EXORCISABLE; Tree.Eating = true; Tree.BodyParts.Eyes.SetActive(true); Tree.BodyParts.RightGrabbedNPC.SetActive(false); Tree.BodyParts.MinigameCircle.SetActive(false); // Get parameters Data parameters = data as Data; npc = parameters.NPC; npcData = GlobalGameStateManager.NPCData[npc.GetComponent<AIController>().SkinType]; Tree.BodyParts.Face.GetComponent<Animator>().enabled = true; Tree.BodyParts.Face.GetComponent<SpriteRenderer>().sprite = Tree.Sprites.Face.Crazy; Tree.BodyParts.Face.GetComponent<Animator>().SetTrigger(npcData.AnimationTrigger); // Set arm angles Tree.BodyParts.RightUpperArm.transform.eulerAngles = new Vector3(0f, 0f, npcData.RightUpperArmEndAngle); Tree.BodyParts.RightLowerForegroundArm.transform.eulerAngles = new Vector3(0f, 0f, npcData.RightLowerArmEndAngle); // Play chew sound //if (Tree.audio.isPlaying) Tree.audio.Stop(); Tree.audio.clip = Tree.Sounds.Chew; Tree.audio.Play(); timeElapsed = 0f; }
public override void Enter(object data) { GlobalGameStateManager.PosessionState = PosessionState.NON_EXORCISABLE; GlobalGameStateManager.SoulConsumedTimer = 0f; Tree.Eating = true; Tree.BodyParts.LeftArm.SetActive(false); Tree.BodyParts.RightArm.SetActive(false); Tree.BodyParts.RightUpperArm.SetActive(true); Tree.BodyParts.LeftUpperArm.SetActive(true); Tree.BodyParts.MinigameCircle.SetActive(true); Tree.BodyParts.Face.GetComponent<SpriteRenderer>().sprite = Tree.Sprites.Face.Crazy; Tree.BodyParts.MinigameCircle.GetComponent<SpriteRenderer>().color = Color.white; // Parse data Data parameters = data as Data; if(parameters.GrabbedNPCs.Length == 1) { grabbedTwo = false; } else { grabbedTwo = true; GameObject.Destroy(parameters.GrabbedNPCs[1]); } npc = parameters.GrabbedNPCs[0]; npcData = GlobalGameStateManager.NPCData[parameters.GrabbedNPCs[0].GetComponent<AIController>().SkinType]; Tree.BodyParts.RightGrabbedNPC.GetComponent<Animator>().SetTrigger(npcData.AnimationTrigger); MessageCenter.Instance.Broadcast(new CameraChangeFollowedMessage(Tree.BodyParts.MinigameCircle.transform, Vector3.zero)); MessageCenter.Instance.Broadcast(new CameraZoomMessage(1.8f, 20f)); // Play music if necessary /*if (parameters.PlayMusic) {*/ /*SoundManager soundManager = GameObject.FindObjectOfType<SoundManager>(); soundManager.PauseMusic();*/ Tree.audio.clip = Tree.Sounds.Music; Tree.audio.Play(); /*}*/ // Handle tutorial if (TutorialManager.Instance.Phase == 0 || TutorialManager.Instance.Phase == 6 || TutorialManager.Instance.Phase == 12 || TutorialManager.Instance.Phase == 16) TutorialManager.Instance.AdvancePhase(); initialized = false; Initialize(); }
public override void Enter(object data) { GlobalGameStateManager.PosessionState = PosessionState.NON_EXORCISABLE; Tree.Eating = true; Tree.BodyParts.Eyes.SetActive(true); Tree.BodyParts.RightGrabbedNPC.SetActive(false); Tree.BodyParts.MinigameCircle.SetActive(false); // Get parameters Data parameters = data as Data; npc = parameters.NPC; npcData = GlobalGameStateManager.NPCData[npc.GetComponent<AIController>().SkinType]; /*Tree.BodyParts.Face.GetComponent<Animator>().enabled = true; Tree.BodyParts.Face.GetComponent<SpriteRenderer>().sprite = Tree.Sprites.Face.Crazy; Tree.BodyParts.Face.GetComponent<Animator>().SetTrigger(npcData.AnimationTrigger);*/ // Choose the texture array based on the character skin switch(npc.GetComponent<AIController>().SkinType) { case NPCSkinType.Bopper: sprites = Tree.Sprites.EatingNPCs.Bopper; break; case NPCSkinType.Boppina: sprites = Tree.Sprites.EatingNPCs.Boppina; break; case NPCSkinType.Critter: sprites = Tree.Sprites.EatingNPCs.Critter; break; case NPCSkinType.Hippie: sprites = Tree.Sprites.EatingNPCs.Hippie; break; case NPCSkinType.Hottie: sprites = Tree.Sprites.EatingNPCs.Hottie; break; case NPCSkinType.MowerMan: sprites = Tree.Sprites.EatingNPCs.MowerMan; break; case NPCSkinType.OldMan: sprites = Tree.Sprites.EatingNPCs.OldMan; break; default: throw new System.ApplicationException("The tree ate something it shouldn't have..."); } sprite = 0; Tree.BodyParts.Face.GetComponent<SpriteRenderer>().sprite = sprites[sprite]; // Set arm angles Tree.BodyParts.RightUpperArm.transform.eulerAngles = new Vector3(0f, 0f, npcData.RightUpperArmEndAngle); Tree.BodyParts.RightLowerForegroundArm.transform.eulerAngles = new Vector3(0f, 0f, npcData.RightLowerArmEndAngle); // Play chew sound //if (Tree.audio.isPlaying) Tree.audio.Stop(); Tree.audio.clip = Tree.Sounds.Chew; Tree.audio.Play(); spriteTimer = 0f; timeElapsed = 0f; }
public static NPCData fillById(NPCData.creatureTemplate id, int level) { int _id = (int)id; NPCData npc = new NPCData(); NPCTemplate template = NPCTemplate.get(_id); npc.name = template.name; npc.template = _id; npc.race = template.creatureRace; npc.subRace = template.creatureSubRace; npc.level = level; npc.health = template.healthBase * level; npc.isAggresive = template.isAgressive; return npc; }
public override void Enter(object data) { GlobalGameStateManager.PosessionState = PosessionState.NON_EXORCISABLE; Tree.Eating = true; Tree.BodyParts.LeftArm.SetActive(false); Tree.BodyParts.RightArm.SetActive(false); Tree.BodyParts.RightUpperArm.SetActive(true); Tree.BodyParts.LeftUpperArm.SetActive(true); Tree.BodyParts.Face.GetComponent<SpriteRenderer>().sprite = Tree.Sprites.Face.Crazy; // Choose a random button float range = Random.Range(0f, 1f); if (range <= 0.25f) button = 1; else if (range > 0.25f && range <= 0.5f) button = 2; else if (range > 0.5f && range <= 0.75f) button = 0; else if (range > 0.75f && range <= 1f) button = 3; // Get data Data parameters = data as Data; npc = parameters.NPC; npcData = GlobalGameStateManager.NPCData[npc.GetComponent<AIController>().SkinType]; Tree.BodyParts.RightGrabbedNPC.GetComponent<Animator>().SetTrigger(npcData.AnimationTrigger); MessageCenter.Instance.Broadcast(new CameraChangeFollowedMessage(Tree.BodyParts.MinigameCircle.transform, Vector3.zero)); MessageCenter.Instance.Broadcast(new CameraZoomMessage(1.2f, 20f)); UpdateArms(1f); SoundManager soundManager = GameObject.FindObjectOfType<SoundManager>(); soundManager.PauseMusic(); Tree.audio.clip = Tree.Sounds.Music; Tree.audio.Play(); buttonScale = 1f; buttonScaleDirection = 1f; won = false; }
public override void Enter(object data) { GlobalGameStateManager.PosessionState = PosessionState.NON_EXORCISABLE; Tree.Eating = true; // Choose a random button float range = Random.Range(0f, 1f); if (range <= 0.25f) button = 1; else if (range > 0.25f && range <= 0.5f) button = 2; else if (range > 0.5f && range <= 0.75f) button = 0; else if (range > 0.75f && range <= 1f) button = 3; //Tree.BodyParts.MinigameCircle.GetComponent<SpriteRenderer>().sprite = Tree.Sprites.EatingMinigame.Circle[Percentage]; Tree.BodyParts.MinigameCircle.GetComponent<SpriteRenderer>().color = Colors[button]; MessageCenter.Instance.Broadcast(new CameraZoomMessage(1.2f, 20f)); // Get data Data parameters = data as Data; npc = parameters.NPC; npcData = GlobalGameStateManager.NPCData[npc.GetComponent<AIController>().SkinType]; percentage = (float)parameters.Percentage / 100f; /*if (TutorialManager.Instance.Phase > 1) percentage = (1f / 3f); else percentage = 0.25f;*/ timeElapsed = 0f; UpdateArms(1f - percentage); sampledTime = 0f; averagePercentage = 0f; ticks = 0; buttonScale = 1f; buttonScaleDirection = 1f; won = false; }
/// <summary> /// Builds a new npc. /// </summary> /// <returns>The new npc.</returns> public GameObject BuildNewNpc<T>() where T : Human { _npcGO = new GameObject("NPC"); _npcGO.transform.localScale = new Vector3(0.35f, 0.35f, 1); _spriteRenderer = _npcGO.AddComponent<SpriteRenderer>() as SpriteRenderer; //_npcAnimator = _npcGO.AddComponent<Animator>() as Animator; _boxCollider2D = _npcGO.AddComponent<BoxCollider2D>() as BoxCollider2D; T npcScript = _npcGO.AddComponent<T>(); _spriteRenderer.sortingOrder = 1; //_npcAnimator.runtimeAnimatorController = npcSkins[ Random.Range(0, npcSkins.Length) ] as RuntimeAnimatorController; NPCData data = npcData[Random.Range(0, npcData.Length)]; _spriteRenderer.sprite = data.normalSprite; npcScript.SetSprites(data.normalSprite, data.sadSprite); _boxCollider2D.isTrigger = true; return _npcGO; }
public NPC(int snoId) : base(snoId) { this.FileData = Actor.SNOToFile[SNOId]; this.Data = new NPCData(); this.Data = NPCData.XMLDeserialize(this.FileData + ".xml"); this.NPCType = (NPCType)this.Data.NPCType; this.ShopInventory = new ShopInventory(this); this.ShopInventory.loadData("Test"); this.TranslateSpeed = 0.2f; /*this.Attributes[GameAttributeStaticList.Is_NPC] = true; * this.Attributes[GameAttributeStaticList.Hitpoints_Max] = 510; * this.Attributes[GameAttributeStaticList.Hitpoints_Cur] = 402.1f;*/ //this.Attributes.BroadcastChangedIfRevealed(); }
public void Initialize(NPCData about) { QuestGenerator qg = QuestGenerator.Instance(); List <List <string> > patterns = new List <List <string> > (); patterns.Add(new List <string> { "kill", "loot", "use" }); patterns.Add(new List <string> { "get", "use" }); patterns.Add(new List <string> { "listen" }); List <string> pattern = patterns [Random.Range(0, patterns.Count)]; this.subActions = qg.assignActions(pattern); }
private void LoadMapFiles() { Log.Info("Loading map data please wait..."); foreach (var mapId in this.Conf.Maps) { var map = new Map(mapId); var mapParser = new MapParser(this.Conf.GetMapFilePath(mapId)); mapParser.ParseFile(ref map); var ndtParser = new NdtParser(this.Conf.GetNdtFilePath(mapId)); ndtParser.ParseFile(ref map); foreach (var shop in map.Shops) { if (this.GameData.NPCData.ContainsKey(shop.Id)) { continue; } var npcData = new NPCData(); var npcDataParser = new NPCDataParser(this.Conf.GetNpcFilePath(shop.Id)); npcDataParser.ParseData(ref npcData); this.GameData.NPCData.Add(shop.Id, npcData); } foreach (var monster in map.Monsters) { if (this.GameData.NPCData.ContainsKey(monster.Id)) { continue; } var npcData = new NPCData(); var npcDataParser = new NPCDataParser(this.Conf.GetNpcFilePath(monster.Id)); npcDataParser.ParseData(ref npcData); this.GameData.NPCData.Add(monster.Id, npcData); } this.GameData.Maps.Add(mapId, map); } Log.Info("Loaded " + this.GameData.Maps.Count + " maps"); }
private void buttonUpdateAll_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridViewNPCs.Rows) { NPCData npc = (NPCData)row.DataBoundItem; if (!string.IsNullOrEmpty(textBoxBoarding.Text)) { npc.Boarding = ushort.Parse(textBoxBoarding.Text); } if (!string.IsNullOrEmpty(textBoxCombat.Text)) { npc.Combat = ushort.Parse(textBoxCombat.Text); } if (!string.IsNullOrEmpty(textBoxEngineering.Text)) { npc.Engineering = ushort.Parse(textBoxEngineering.Text); } if (!string.IsNullOrEmpty(textBoxLeadership.Text)) { npc.Leadership = ushort.Parse(textBoxLeadership.Text); } if (!string.IsNullOrEmpty(textBoxManagement.Text)) { npc.Management = ushort.Parse(textBoxManagement.Text); } if (!string.IsNullOrEmpty(textBoxMorale.Text)) { npc.Morale = ushort.Parse(textBoxMorale.Text); } if (!string.IsNullOrEmpty(textBoxNavigation.Text)) { npc.Navigation = ushort.Parse(textBoxNavigation.Text); } if (!string.IsNullOrEmpty(textBoxScience.Text)) { npc.Science = ushort.Parse(textBoxScience.Text); } } dataGridViewNPCs.DataSource = null; dataGridViewNPCs.DataSource = sge.NPCs[(string)comboBoxFaction.SelectedItem]; }
public void Initialize(NPCData npc) { QuestGenerator qg = QuestGenerator.Instance(); List <List <string> > patterns = new List <List <string> > (); patterns.Add(new List <string> { "learn" }); patterns.Add(new List <string> { }); foreach (string act in patterns[Random.Range(0, patterns.Count)]) { if (act == "learn") { subActions.Add(new Learn(npc)); } } }
/// <summary> /// Настроить персонажа в соответствии с сохранёнными данными /// </summary> public void SetData(InterObjData _intObjData) { NPCData npcData = (NPCData)_intObjData; if (npcData != null) { List <Dialog> _dialogs = dialogs; dialogs = new List <Dialog>(); for (int i = 0; i < npcData.dialogs.Count; i++) { Dialog dialog = _dialogs.Find(x => (x.dialogName == npcData.dialogs[i])); if (dialog != null) { dialogs.Add(dialog); } } } #if UNITY_EDITOR UnityEditor.EditorUtility.SetDirty(this); #endif //UNITY_EDITOR }
public NonPlayerCharacter() { EditorID = new SimpleSubrecord <String>("EDID"); ObjectBounds = new ObjectBounds("OBND"); Model = new Model(); BaseStats = new NPCBaseStats("ACBS"); VoiceType = new RecordReference("VTCK"); Race = new RecordReference("RNAM"); UnarmedAttackAnimation = new SimpleSubrecord <UInt16>("EAMT"); AIData = new AIData("AIDT"); Class = new RecordReference("CNAM"); Data = new NPCData("DATA"); HairColor = new SimpleSubrecord <Color>("HCLR"); ImpactMaterialType = new SimpleSubrecord <MaterialTypeUInt>("NAM4"); FaceGenGeometrySymmetric = new SimpleSubrecord <byte[]>("FGGS", new byte[4]); FaceGenGeometryAsymmetric = new SimpleSubrecord <byte[]>("FGGA", new byte[4]); FaceGenTexture = new SimpleSubrecord <byte[]>("FGTS", new byte[4]); Unknown = new SimpleSubrecord <UInt16>("NAM5"); Height = new SimpleSubrecord <Single>("NAM6"); Weight = new SimpleSubrecord <Single>("NAM7"); }
public static void insertNPCs() { NPCData npc; npc = new NPCData (); npc.id = 1; npc.name = "Mike Ghole"; npc.level = 25; npc.type = NPCData.creatureType.Human; npc.subType = NPCData.creatureSubType.Seller; npc.create (); npc = new NPCData (); npc.id = 2; npc.name = "Araña del castillo"; npc.level = 5; npc.type = NPCData.creatureType.Monster; npc.subType = NPCData.creatureSubType.Normal; npc.isAggresive = true; npc.create (); }
public static NPCData LoadNPC(string name) { string path = Application.persistentDataPath + "/" + name + ".sol"; // Debug.Log(path); if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); NPCData data = formatter.Deserialize(stream) as NPCData; stream.Close(); return(data); } else { Debug.LogError("Save file not found in" + path); return(null); } }
///////////////////////////////////////////////////////////////////////////////////////////////// /// public void Test() { var tPlayerData = new PlayerData(DataConfigManager.GetInstance(), 1) { Guid = 1, HP = 30, MP = 30, Position = new Vector3(0, 0, 0) }; CreatePlayer(tPlayerData); for (int i = 0; i < 0; i++) { tPlayerData = new PlayerData(DataConfigManager.GetInstance(), 1) { Guid = (uint)(2 + i), HP = 30, MP = 30, Position = new Vector3(10f * (float)Math.Cos(i * 1f), 0, 10f * (float)Math.Sin(i * 1f)) }; CreatePlayer(tPlayerData); } GameSceneManager.GetInstance().SetCameraObject(Self); var tNPCData = new NPCData(DataConfigManager.GetInstance(), 1) { Guid = 1, Position = new Vector3(15, 0, 15) }; CreatNPC(tNPCData); tNPCData = new NPCData(DataConfigManager.GetInstance(), 1) { Guid = 2, Position = new Vector3(0, 0, 0) }; CreatNPC(tNPCData); }
public void LoadFromData(NPCData data) { if (data == null) { return; } base.LoadFromData(data); ItemStashData inventoryData = data.inventoryData; inventory.LoadFromInventoryData(inventoryData); npcName = data.name; name = Constants.NPC_NAME + npcName; hasQuest = data.hasQuest; questActive = data.questActive; if (hasQuest && !questActive) { interactable.ShowQuestIcon(); } friendliness = data.friendliness; destination = new Vector3(data.destX, data.destY, data.destZ); isMoving = data.isMoving; canSearchForDest = data.canSearchForDest; UpdateSortingLayer(); if (isMoving) { SetNewDestination(destination); } else if (!canSearchForDest) { StartCoroutine(ArriveDelay()); } }
CreatNpcDepandency ctorToShowcase(NPCRuntimeData rt, NPCConfigData cfg, int[] BuffIDList, UVec3 TargetVec3) { NPCData data = new NPCData() { configData = cfg, rtData = rt, }; //有碰撞 bool Collide = true; CreatNpcDepandency depandency = new CreatNpcDepandency() { IsCollide = Collide, Source = data, Buff_IDs = BuffIDList, TargetVector3 = new List <Vec3F>(), }; depandency.TargetVector3.Add(TargetVec3.toCustomVec3()); return(depandency); }
public void Drop() { transform.parent = null; carriedBy.carryingItem = null; var copy = carriedBy; carriedBy = null; RaycastHit hitInfo; //Shoots a ray into the 3D world starting at our mouseposition if (Physics.Raycast(transform.position, Vector3.down, out hitInfo)) { transform.position = hitInfo.point; transform.rotation = Quaternion.identity; } if (onPickedDown != null) { onPickedDown.Invoke(copy); } }
/// <summary> /// Load all flyff npcs. /// </summary> private void LoadNpc() { this.LoadNpcDialogs(); Log.Loading("Loading NPC data..."); string[] files = { "data//res//dataSub1//character.inc", "data//res//dataSub1//character-etc.inc", "data//res//dataSub1//character-school.inc" }; foreach (var npcFile in files) { string path = Path.Combine(Global.DataPath, npcFile); var npcGroupFile = new ResourceGroup(npcFile); npcGroupFile.Parse(); foreach (var npc in npcGroupFile.Groups) { var newNpc = new NPCData(); newNpc.Name = npc.Name; if (!npcData.ContainsKey(newNpc.Name)) { npcData.Add(newNpc.Name, newNpc); } else { npcData[newNpc.Name] = newNpc; } } } Log.Done("{0} npcs data loaded!\t\t\t", npcData.Count); }
public Trigger CreateNewTrigger(int x, int y, eSlotAonTypeObj typeObj) { Trigger trigger = null; int idGen = -1; if (typeObj == eSlotAonTypeObj.Warps) { idGen = WarpsData.Count; WarpsData.Add(new Warps()); trigger = WarpsData[idGen]; } else if (typeObj == eSlotAonTypeObj.Signposts) { idGen = SignpostsData.Count; SignpostsData.Add(new Signposts()); trigger = SignpostsData[idGen]; } else if (typeObj == eSlotAonTypeObj.Person) { idGen = NPCData.Count; NPCData.Add(new NPC()); trigger = NPCData[idGen]; // ComboBoxHelper.Instance.ResetDataNPCList(); } else if (typeObj == eSlotAonTypeObj.Script) { idGen = ScriptData.Count; ScriptData.Add(new Script()); trigger = ScriptData[idGen]; // ComboBoxHelper.Instance.ResetDataScriptList(); } if (trigger != null) { // CheckInitArray(ref TriggerLink, TileMapWidth, TileMapHeight, -1); ComboBoxHelper.Instance.ResetTypeObj(typeObj); TriggerLink[x, y] = idGen; } return(trigger); }
public void ExportData(string filePath) { LoadFile(filePath); if (m_dicNPCCache.ContainsKey(curSceneID)) { m_dicNPCCache[curSceneID] = new List <NPCData>(); } else { m_dicNPCCache.Add(curSceneID, new List <NPCData>()); } { var __array2 = transform.GetComponentsInChildren <NPCPresent>(false); var __arrayLength2 = __array2.Length; for (int __i2 = 0; __i2 < __arrayLength2; ++__i2) { var child = (NPCPresent)__array2[__i2]; { NPCData curNPC = new NPCData(); curNPC.Id = child.Id; curNPC.name = child.NPCName; curNPC.sceneID = curSceneID; curNPC.dataID = child.DataID; curNPC.xPos = child.transform.position.x; curNPC.yPos = child.transform.position.z; curNPC.rad = DirClientToServer(child.transform.rotation); curNPC.visiableInMiniMap = child.ShowInMiniMap; curNPC.createInScene = child.CreateInScene; curNPC.randCoordStartId = child.RandCoordStartId; curNPC.randCoordEndId = child.RandCoordEndId; curNPC.group = child.Group; m_dicNPCCache[curSceneID].Add(curNPC); } } } WriteFile(filePath); //ConvertFile(filePath); }
void Update() { if (currentComfortValue != NPCData.GetComfortValue()) { SetNPCImage(); if (!Sound.muted) { if (NPCData.isComfortValPositive) { System.Random r = new System.Random(); int randomInt = r.Next(1, 3); // range 1 - 2 npcAudioClip = Resources.Load <AudioClip>("Sounds/approving" + randomInt); } else { npcAudioClip = Resources.Load <AudioClip>("Sounds/disapproving2"); } npcAudioSource.clip = npcAudioClip; npcAudioSource.Play(); } } currentComfortValue = NPCData.GetComfortValue(); }
private void CreateDictionaries() { npcDetailsDictionary = new Dictionary <int, NPCDetails>(); npcDataDictionary = new Dictionary <int, NPCData>(); socialLinks = new Dictionary <int, SocialLinkDetails>(); foreach (NPCDetails detail in npcList.npcDetails) { npcDetailsDictionary.Add(detail.npcCode, detail); NPCData data = new NPCData(); data.npcCode = detail.npcCode; data.SetSchedule(detail.startingSchedule); npcDataDictionary.Add(detail.npcCode, data); } foreach (SocialLinkDetails sl in socialLinkList.socialLinks) { if (!socialLinks.ContainsKey(sl.npcCode)) { socialLinks.Add(sl.npcCode, sl); } } }
public void OpenPanel(NPCData currentNPC) { this.currentNPC = currentNPC; itemTable.OpenPanel(currentNPC.ShopData); interactPanel.OpenPanel(); for (int i = 0; i < CategoryToggles.Length; ++i) { CategoryToggles[i].gameObject.SetActive(false); } for (int i = 0; i < currentNPC.ShopData.SalesItemTypes.Length; ++i) { CategoryToggles[i].Refresh(currentNPC.ShopData.SalesItemTypes[i]); } if (currentNPC.ShopData.SalesItemTypes.Length > 0) { CategoryToggles[0].GetComponent <Toggle>().isOn = true; SelectCategoryToggle(currentNPC.ShopData.SalesItemTypes[0]); } gameObject.SetActive(true); }
/// <summary> /// 数据的初始化 /// </summary> /// <param name="go">Go.</param> /// <param name="camp">Camp.</param> /// <param name="initedData">Inited data.</param> void InitedData(GameObject go, CAMP camp, NPCData initedData) { ClientNPC curHero = go.GetComponent <ClientNPC>(); /// /// 填充阵营 /// curHero.Camp = camp; /// /// 填充NPC数据 /// NPCData dynamicData = initedData; dynamicData.btData = new NPCBattleData(); curHero.data = dynamicData; /// /// 向WarClientNpcManager注册 /// cliNpcMgr.SignID(curHero); }
public void AddXPAmount(int npcID, string jobtype, ushort amount, Colony owner) { if (GetLevel(jobtype) != NPCManager.maxLevel) { if (XPAmounts.ContainsKey(jobtype)) { XPAmounts[jobtype] += amount; } else { XPAmounts.Add(jobtype, amount); } if (XPLevels.ContainsKey(jobtype)) { //Utilities.WriteLog("Level: " + XPLevels[jobtype] + "/" + getLevel(jobtype)); if (GetLevel(jobtype) > XPLevels[jobtype]) { NPCData n = NPCManager.GetNPCData(npcID, owner); // the NPC has levelled up! XPLevels[jobtype] += 1; if (NPCManager.Silent == false) { foreach (Players.Player own in owner.Owners) { Helpers.Chat.Send(own, String.Format("{0} [{1}] has gained a level in {2} (Level: {3}, {4}% efficiency boost)", n.Name, npcID, jobtype, XPLevels[jobtype], Math.Round((1 - GetCraftingMultiplier(jobtype)) * 100, 0)), Helpers.Chat.ChatColour.orange); } } } } else { //Utilities.WriteLog("Job type level: " + jobtype + " does not exist, adding..."); XPLevels.Add(jobtype, 0); } } //Utilities.WriteLog("Updated XP for NPC for job " + jobtype + " added " + amount + "XP to total " + XPAmounts[jobtype]); }
void makeUpData(WarCamp camp) { if (camp == WarCamp.FirstCamp || camp == WarCamp.SecondCamp) { List <RoomCharactor> chalist = null; bool exist = allCharactors.TryGetValue(camp, out chalist); if (exist) { foreach (RoomCharactor charactor in chalist) { if (charactor.team is WrapperTeam) { continue; } WrapperTeam wTeam = new WrapperTeam() { dataTeam = new List <NPCData>(), }; foreach (RoomNpc npc in charactor.team.team) { NPCConfigData config = Model.get(npc.NpcNum); NPCData data = new NPCData() { configData = config, rtData = new NPCRuntimeData(config), }; wTeam.dataTeam.Add(data); } wTeam.team = charactor.team.team; charactor.team = wTeam; } } } }
public void SetCharactorData(int id, int _country) { generalID = id; country = _country; if (country == 0) { GeneralData data = GeneralDataManager.Instance.GetGeneralData(id); //获取武将 int level = PlayerData.Instance.GetGeneralLevel(id); //获取武将等级 life = data.lifeBase + level * data.lifeRate; attack = data.attBase + level * data.attRate; def = data.defBase + level * data.defRate; crit = data.criBase + level * data.criRate; attackMax = data.attackMax; } else //敌方角色 { NPCData npcdata = NPCDataManager.Instance.GetNPCData(id); life = npcdata.life; attack = npcdata.attack; def = npcdata.def; crit = npcdata.crit; attackMax = npcdata.attackMax; } }
public static bool cb(CSVReader csv_reader, NPCData data, ref uint key) { data.id = (int)key; csv_reader.Pop(ref data.npcType); csv_reader.Pop(ref data.npcModelID); csv_reader.Pop(ref data.sexID); csv_reader.Pop(ref data.faceTypeID); csv_reader.Pop(ref data.skinColorID); csv_reader.Pop(ref data.hairStyleID); csv_reader.Pop(ref data.hairColorID); csv_reader.Pop(ref data.bdy); csv_reader.Pop(ref data.hlm); csv_reader.Pop(ref data.arm); csv_reader.Pop(ref data.leg); csv_reader.Pop(ref data.anim); csv_reader.Pop(ref data.name); csv_reader.Pop(ref data.displayName); csv_reader.Pop(ref data.specialModelID); if (string.IsNullOrEmpty(data.displayName)) { data.displayName = data.name; } return(true); }
public static bool GetNpcFunctionData(GameClient client, int extensionID, NPCData npcData, SystemXmlItem systemNPC) { if (null == systemNPC) { return(false); } //查询是否有系统功能 string operaIDsByString = systemNPC.GetStringValue("Operations"); operaIDsByString.Trim(); if (operaIDsByString != "") { int[] operaIDsByInt = Global.StringArray2IntArray(operaIDsByString.Split(',')); if (null == npcData.OperationIDs) { npcData.OperationIDs = new List <int>(); } for (int i = 0; i < operaIDsByInt.Length; i++) { //过滤功能 if (Global.FilterNPCOperationByID(client, operaIDsByInt[i], extensionID)) { continue; } npcData.OperationIDs.Add(operaIDsByInt[i]); } } //查询是否有NPC功能脚本 string scriptIDsByString = systemNPC.GetStringValue("Scripts"); if (null != scriptIDsByString) { scriptIDsByString = scriptIDsByString.Trim(); } if (!string.IsNullOrEmpty(scriptIDsByString)) { int[] scriptIDsByInt = Global.StringArray2IntArray(scriptIDsByString.Split(',')); if (null == npcData.ScriptIDs) { npcData.ScriptIDs = new List <int>(); } for (int i = 0; i < scriptIDsByInt.Length; i++) { int errorCode = 0; //过滤功能脚本 if (Global.FilterNPCScriptByID(client, scriptIDsByInt[i], out errorCode)) { continue; } npcData.ScriptIDs.Add(scriptIDsByInt[i]); } } return(true); }
public static bool GetNpcTaskData(GameClient client, int extensionID, NPCData npcData) { //再查询属于指定NPC的是否有可以接的任务(要判断前置任务和后置任务等条件,以及级别等条件) //查询NPC上挂载的任务 List <int> tasksList = null; if (!GameManager.NPCTasksMgr.SourceNPCTasksDict.TryGetValue(extensionID, out tasksList)) { return(false); //npc上没任务 } if (0 == tasksList.Count) { return(false); //npc上没任务 } Dictionary <int, NpcCircleTaskData> all_circleTask = null; //遍历npc上挂载的所有任务,将跑环任务暂存起来稍后处理,非跑环任务直接处理 for (int i = 0; i < tasksList.Count; i++) { int taskID = tasksList[i]; SystemXmlItem systemTask = null; if (!GameManager.SystemTasksMgr.SystemXmlItemDict.TryGetValue(taskID, out systemTask)) { continue; //配置错误,没这个任务 } int taskClass = systemTask.GetIntValue("TaskClass"); if (taskClass >= (int)TaskClasses.CircleTaskStart && taskClass <= (int)TaskClasses.CircleTaskEnd) //如果是跑环任务 { // 是否能接这种跑环任务 if (!Global.CanTaskPaoHuanTask(client, taskClass)) { continue; } //判断是否是能接的新任务 if (!Global.CanTakeNewTask(client, taskID, systemTask)) { continue; } //本次请求内是否处理过这种跑环任务 NpcCircleTaskData circletask = null; if (null == all_circleTask || !all_circleTask.TryGetValue(taskClass, out circletask)) { circletask = new NpcCircleTaskData(); circletask.taskclass = taskClass; //之前随机的任务ID circletask.oldTaskID = PaoHuanTasksMgr.FindPaoHuanHistTaskID(client.ClientData.RoleID, taskClass); if (circletask.oldTaskID >= 0) { //验证还是否能继续接 //判断是否是能接的新任务 if (!Global.CanTakeNewTask(client, circletask.oldTaskID)) { circletask.oldTaskID = -1; } } if (null == all_circleTask) { all_circleTask = new Dictionary <int, NpcCircleTaskData>(); } all_circleTask[taskClass] = circletask; } //添加到列表 if (null != circletask) { circletask.NpcAttachedTaskID.Add(taskID); } } else //非跑环任务,比如主线任务 { //判断是否是能接的新任务 if (!Global.CanTakeNewTask(client, taskID, systemTask)) { continue; } //记录这个任务 if (null == npcData.NewTaskIDs) { npcData.NewTaskIDs = new List <int>(); } npcData.NewTaskIDs.Add(taskID); if ((int)TaskClasses.SpecialTask == taskClass) //如果是循环任务,要计算已经做过的次数 { OldTaskData oldTaskData = Global.FindOldTaskByTaskID(client, tasksList[i]); int doneCount = (null == oldTaskData) ? 0 : oldTaskData.DoCount; if (null == npcData.NewTaskIDsDoneCount) { npcData.NewTaskIDsDoneCount = new List <int>(); } npcData.NewTaskIDsDoneCount.Add(doneCount); } else { if (null == npcData.NewTaskIDsDoneCount) { npcData.NewTaskIDsDoneCount = new List <int>(); } npcData.NewTaskIDsDoneCount.Add(0); } } } //处理刚才暂存的跑环任务 if (null == all_circleTask) { return(true); } foreach (var circletask in all_circleTask) { bool needRandom = false; if (-1 != circletask.Value.oldTaskID) { //之前随机过任务ID if (0 == circletask.Value.NpcAttachedTaskID.Count) { continue; //npc上没这种跑环任务 } //验证之前随机到的任务是否是存在的 if (-1 != circletask.Value.NpcAttachedTaskID.IndexOf(circletask.Value.oldTaskID)) { //记录这个任务 if (null == npcData.NewTaskIDs) { npcData.NewTaskIDs = new List <int>(); } npcData.NewTaskIDs.Add(circletask.Value.oldTaskID); if (null == npcData.NewTaskIDsDoneCount) { npcData.NewTaskIDsDoneCount = new List <int>(); } npcData.NewTaskIDsDoneCount.Add(0); } else { needRandom = true; } } else { needRandom = true; } if (needRandom) { int randTaskId = circletask.Value.DoRandomTaskID(client); if (-1 != randTaskId) { //记录这个任务 if (null == npcData.NewTaskIDs) { npcData.NewTaskIDs = new List <int>(); } npcData.NewTaskIDs.Add(randTaskId); if (null == npcData.NewTaskIDsDoneCount) { npcData.NewTaskIDsDoneCount = new List <int>(); } npcData.NewTaskIDsDoneCount.Add(0); PaoHuanTasksMgr.SetPaoHuanHistTaskID(client.ClientData.RoleID, circletask.Value.taskclass, randTaskId); } } } return(true); }
public void AttachTo(NPCData creature) { //this.attphys = creature.attPhysical; // = new Stat(); attphys.OnGet += this.HandleAttPhysGet; }
public void DetachFrom(NPCData creature) { this.attphys.OnGet -= this.HandleAttPhysGet; }
private static void AddNPCType(IDictionary<NPCSkinType, NPCData> data, NPCSkinType skinType, NPCData npcData) { data[skinType] = npcData; npcData.SkinType = skinType; }
public void InitData(NPCData data) { m_data = data; m_refData = data; }
public void Start() { if (Id == 0) { throw new Exception ("Id not assigned"); } data = NPC.get (Id); Color color; try { anim = transform.FindChild("Model").GetComponent<Animation> (); } catch (Exception) {} namePlate = transform.FindChild ("NamePlate").GetComponent<NamePlate>(); this.OriginalAttacksPerSecond = data.attacksPerSecond; this.initialPos = this.transform.position; this.maxHealth = this.health; if (data.isAggresive) { color = NamePlate.COLOR_ENEMY; } else { color = NamePlate.COLOR_NORMAL; } namePlate.setName (data.name, color); namePlate.setLevel (data.level); }
public void Add(NPCData npcData) { if (GetNPC(npcData.name) == null){ npcs.Add(npcData); } }
public override void SetupShop(int type, Chest shop, ref int nextSlot) { NPCData.AddItemToTownNPCShop(type, shop, ref nextSlot, NPCID.Merchant, ItemID.TargetDummy, NPC.downedBoss1, ModContent.GetInstance <DesiccationGlobalConfig>().Merchant_TargetDummy); NPCData.AddItemToTownNPCShopWithCustomBuyPrice(type, shop, ref nextSlot, NPCID.Wizard, ItemID.LunarCraftingStation, Item.buyPrice(1, 0, 0, 0), NPC.downedAncientCultist, ModContent.GetInstance <DesiccationGlobalConfig>().Wizard_AncientManipulator); NPCData.AddItemToTownNPCShopWithCustomBuyPrice(type, shop, ref nextSlot, NPCID.Merchant, ItemID.WhoopieCushion, Item.buyPrice(0, 1, 0, 0), NPC.downedBoss2); }