override public void skillEvent() { GameNpc myNpc = this.gameObject.GetComponent <GameNpc>(); GameNpc enemyNpc = myNpc.enemyNpc; this.attackNpc(enemyNpc, GameNpc.getPhysicsRealAttack(myNpc, enemyNpc)); }
//结束战斗-进入战斗后不可使用backMove() public void endFight(GameNpc winer, GameNpc loser) { //初始化战斗信息 destroyButton(); if (loser.isCanDie) { Destroy(loser.gameObject); } else { if (!loser.isNpc) { loser.deleteExp(loser.exp / 2f); } loser.hp = loser.maxHp; loser.mp = loser.maxMp; loser.isCanFight = false; loser.speedTime = 0; } if (winer.isAutoFullStaut) { winer.hp = winer.maxHp; winer.mp = winer.maxMp; } winer.isCanFight = false; winer.speedTime = 0; this.enemyNpc = null; functionButton.transform.Find("StatusPanel").gameObject.SetActive(true); functionButton.transform.Find("BackPack").gameObject.SetActive(true); if (isShowStatusPanel) { this.statusPanel.gameObject.SetActive(true); } else if (isShowBackpackPanel) { this.backpackPanel.gameObject.SetActive(true); } winer.transform.SetParent(GameObject.Find("Game").transform.Find("GameNpc").transform); loser.transform.SetParent(GameObject.Find("Game").transform.Find("GameNpc").transform); winer.backLastPos(); loser.backLastPos(); winer.mode = MainGame.MODE_MOVE; loser.mode = MainGame.MODE_MOVE; changeMode(MainGame.MODE_MOVE); setTextMove("经验+" + loser.exp * (loser.dropExpOdds / 100f + 1f) * (winer.extraExpOdds / 100f + 1f), 0.3f, winer.gameObject); setTextMove("金钱+" + loser.money * (loser.dropMoneyOdds / 100f + 1f) * (winer.extraMoneyOdds / 100f + 1f), 0.3f, winer.gameObject); winer.addMoney(loser.money * (loser.dropMoneyOdds / 100f + 1f) * (winer.extraMoneyOdds / 100f + 1f)); int n = winer.addExp(loser.exp * (loser.dropExpOdds / 100f + 1f) * (winer.extraExpOdds / 100f + 1f)); if (n > 0) { setTextMove("等级+" + n, 0.3f, winer.gameObject); setTextMove("最大生命" + n * 5, 0.6f, winer.gameObject); setTextMove("最大法力" + n * 3, 0.9f, winer.gameObject); setTextMove("物理攻击上限" + n * 2, 1.2f, winer.gameObject); setTextMove("物理攻击下限" + n * 1, 1.5f, winer.gameObject); setTextMove("魔法攻击上限" + n * 1.2, 1.8f, winer.gameObject); setTextMove("魔法攻击下限" + n * 0.6, 2.1f, winer.gameObject); } }
/****************************** *对外开放的接口 * * ******************************/ /******************* *用户输入相关 * * *******************/ //返回移动状态 public void backMove() { if (this.mode != MainGame.MODE_FIGHT) { destroyButton(); string str; GameNpc tempNpc = nowObject.GetComponent <GameNpc>(); str = nowObject.ObjectName; if (tempNpc == null) { str += '\n'; } else { Color color = Color.black; str += "(<color=#FFFF00>" + tempNpc.lvl + "</color>"; //HP color.r = 1f - tempNpc.hp / tempNpc.maxHp; color.g = tempNpc.hp / tempNpc.maxHp; color.b = 0f; str += "<color=" + ColorToHex.colorToHex(color) + ">" + tempNpc.hp + "</color>" + "/" + tempNpc.maxHp + " "; //MP color.r = 1f - tempNpc.mp / tempNpc.maxMp; color.b = tempNpc.mp / tempNpc.maxMp; color.g = 0f; str += "<color=" + ColorToHex.colorToHex(color) + ">" + tempNpc.mp + "</color>" + "/" + tempNpc.maxMp + " "; str += "<color=#FF00FF>" + tempNpc.getFightPower() + "</color>)\n"; } str += "--------------\n"; str += nowObject.introduce + "\n"; setText(str); this.mode = MainGame.MODE_MOVE; } }
private static void loadSkill(GameNpc npc, int id) { string sId = id.ToString(); int skillId; for (int i = 0; i < skillCount; i++) { skillId = PlayerPrefs.GetInt(sId + "_Skill" + "_" + (i + 1)); FightEvent temp = null; //找到技能 if (skillId != 0) { switch (skillId) { case 1: npc.gameObject.AddComponent <FightNormalAttack>(); temp = npc.gameObject.GetComponent <FightNormalAttack>(); break; } if (temp != null) { temp.skillName = PlayerPrefs.GetString(sId + "_Skill" + "_" + skillId + "_name"); temp.skillText = PlayerPrefs.GetString(sId + "_Skill" + "_" + skillId + "_text"); temp.skillLvl = PlayerPrefs.GetInt(sId + "_Skill" + "_" + skillId + "_lvl"); temp.skillMaxLvl = PlayerPrefs.GetInt(sId + "_Skill" + "_" + skillId + "_maxLvl"); temp.skillExp = PlayerPrefs.GetFloat(sId + "_Skill" + "_" + skillId + "_exp"); temp.skillMaxExp = PlayerPrefs.GetFloat(sId + "_Skill" + "_" + skillId + "_maxExp"); temp.skillHurtAmp = PlayerPrefs.GetFloat(sId + "_Skill" + "_" + skillId + "_hurtAmp"); temp.skillHurtAdd = PlayerPrefs.GetFloat(sId + "_Skill" + "_" + skillId + "_hurtAdd"); } } } }
/******************* *战斗相关 * * *******************/ //开始战斗-进入战斗后不可使用backMove() public void startFight(GameNpc enemyNpc) { //初始化战斗信息 enemyNpc.isCanFight = false; enemyNpc.speedTime = 0; myNpc.isCanFight = false; myNpc.speedTime = 0; this.enemyNpc = enemyNpc; functionButton.transform.Find("StatusPanel").gameObject.SetActive(false); functionButton.transform.Find("BackPack").gameObject.SetActive(false); this.statusPanel.gameObject.SetActive(false); this.backpackPanel.gameObject.SetActive(false); enemyNpc.transform.SetParent(GameObject.Find("Game").transform.Find("GameFight").transform); myNpc.transform.SetParent(GameObject.Find("Game").transform.Find("GameFight").transform); myNpc.mode = MainGame.MODE_FIGHT; enemyNpc.mode = MainGame.MODE_FIGHT; enemyNpc.enemyNpc = myNpc; myNpc.enemyNpc = enemyNpc; Vector3 pos = Vector3.zero; pos.x = 5f; pos.y = 0; enemyNpc.moveToPosOfParent(pos); pos.x = -5f; pos.y = 0; myNpc.moveToPosOfParent(pos); changeMode(MainGame.MODE_FIGHT); }
//获得攻击 public static float getMagicRealAttack(GameNpc attNpc, GameNpc defNpc) { float pAtt = Random.Range(attNpc.pAttLow, attNpc.pAttHigh); float pDef = defNpc.pDefPower; if (Random.Range(1, 100) <= attNpc.pVioHurtOdds) //暴击时 { pAtt *= ((attNpc.pVioHurtAmp / 100f) + 1f); pAtt += attNpc.pVioHurtAdd; if (Random.Range(1, 100) >= attNpc.pVioHurtMissDefOdds) { if (1 - attNpc.pVioHurtMissDefAmp / 100f <= 0) { pDef = 0; } else { pDef *= 1 - attNpc.pVioHurtMissDefAmp / 100f; } if (attNpc.pVioHurtMissDefAdd >= pDef) { pDef = 0; } else { pDef -= attNpc.pVioHurtMissDefAdd; } } } pAtt -= pDef; return(pAtt); }
public static int loadNpc(GameNpc npc, int id) { if (npc == null) { return(0); } string sId = id.ToString(); //读取基本信息 npc.id = PlayerPrefs.GetInt(sId + "_id"); if (npc.id == 0) { return(0); } npc.npcName = PlayerPrefs.GetString(sId + "_name"); Vector3 pos = Vector3.zero; pos.x = PlayerPrefs.GetFloat(sId + "_x"); pos.y = PlayerPrefs.GetFloat(sId + "_y"); pos.z = PlayerPrefs.GetFloat(sId + "_z"); npc.transform.position = pos; npc.hp = PlayerPrefs.GetFloat(sId + "_hp"); npc.maxHp = PlayerPrefs.GetFloat(sId + "_maxHp"); npc.mp = PlayerPrefs.GetFloat(sId + "_mp"); npc.maxMp = PlayerPrefs.GetFloat(sId + "_maxMp"); npc.pAttLow = PlayerPrefs.GetFloat(sId + "_pAttlow"); npc.pAttHigh = PlayerPrefs.GetFloat(sId + "_pAttHigh"); npc.mAttLow = PlayerPrefs.GetFloat(sId + "_mAttlow"); npc.mAttHigh = PlayerPrefs.GetFloat(sId + "_mAttHigh"); npc.pDefPower = PlayerPrefs.GetFloat(sId + "_pDefPower"); npc.mDefPower = PlayerPrefs.GetFloat(sId + "_mDefPower"); npc.lvl = PlayerPrefs.GetInt(sId + "_lvl"); npc.maxLvl = PlayerPrefs.GetInt(sId + "_maxLvl"); npc.exp = PlayerPrefs.GetFloat(sId + "_exp"); npc.maxExp = PlayerPrefs.GetFloat(sId + "_maxExp"); npc.money = PlayerPrefs.GetFloat(sId + "_money"); npc.maxMoney = PlayerPrefs.GetFloat(sId + "_maxMoney"); npc.liliang = PlayerPrefs.GetInt(sId + "_liliang"); npc.minjie = PlayerPrefs.GetInt(sId + "_minjie"); npc.zhili = PlayerPrefs.GetInt(sId + "_zhili"); npc.tizhi = PlayerPrefs.GetInt(sId + "_tizhi"); npc.norFightSpeed = PlayerPrefs.GetFloat(sId + "_norFightSpeed"); npc.fightSpeedAmp = PlayerPrefs.GetFloat(sId + "_fightSpeedAmp"); npc.pVioHurtAmp = PlayerPrefs.GetFloat(sId + "_pVioHurtAmp"); npc.pVioHurtAdd = PlayerPrefs.GetFloat(sId + "_pVioHurtAdd"); npc.pVioHurtOdds = PlayerPrefs.GetFloat(sId + "_pVioHurtOdds"); npc.pVioHurtMissDefAmp = PlayerPrefs.GetFloat(sId + "_pVioHurtMissDefAmp"); npc.pVioHurtMissDefAdd = PlayerPrefs.GetFloat(sId + "_pVioHurtMissDefAdd"); npc.pVioHurtMissDefOdds = PlayerPrefs.GetFloat(sId + "_pVioHurtMissDefOdds"); npc.doeOdds = PlayerPrefs.GetFloat(sId + "_doeOdds"); npc.recoverHpPerSecond = PlayerPrefs.GetFloat(sId + "_recoverHpPerSecond"); npc.recoverMpPerSecond = PlayerPrefs.GetFloat(sId + "_recoverMpPerSecond"); npc.recoverHpPerHit = PlayerPrefs.GetFloat(sId + "_recoverHpPerHit"); npc.recoverMpPerHit = PlayerPrefs.GetFloat(sId + "_recoverMpPerHit"); npc.extraItemOdds = PlayerPrefs.GetFloat(sId + "_extraItemOdds"); npc.extraExpOdds = PlayerPrefs.GetFloat(sId + "_extraExpOdds"); npc.extraMoneyOdds = PlayerPrefs.GetFloat(sId + "_extraMoneyOdds"); loadSkill(npc, id); return(1); }
public override void runEvent() { GameNpc myNpc = this.gameObject.GetComponent <GameNpc>(); if (myNpc.isCanFight) { string skillName; if (id < 10) { skillName = "skill_0" + id; } else { skillName = "skill_" + id; } GameObject obj = (GameObject)Instantiate(Resources.Load("Prefabs\\Skill\\" + skillName), Vector3.zero, Quaternion.identity); obj.transform.SetParent(this.transform); obj.transform.localPosition = Vector3.zero; obj.GetComponent <AnimatorEvent>().startFight(myNpc, this.gameObject.GetComponent <GameNpc>().enemyNpc, this); if (selectMainGame()) { mainGame.getTextEvent().setNotice(this.conText, 0.5f, true); } myNpc.speedTime = 0; } else { if (selectMainGame()) { mainGame.getTextEvent().setNotice("现在还不能释放技能喔!", 0.5f, true); } } }
public void startFight(GameNpc myNpc, GameNpc enemyNpc, FightEvent fightEvent) { this.myNpc = myNpc; this.enemyNpc = enemyNpc; this.fightEvent = fightEvent; runEvent(); }
public void startFight(GameNpc myNpc, GameNpc enemyNpc, FightEvent fightEvent, float maxTime) { this.myNpc = myNpc; this.enemyNpc = enemyNpc; this.fightEvent = fightEvent; this.maxTime = maxTime; runEvent(); }
public void startFight(GameNpc myNpc, GameNpc enemyNpc) { this.myNpc = myNpc; this.enemyNpc = enemyNpc; this.fightEvent = null; this.maxTime = 0; runEvent(); }
//电脑AI,战斗时 private void fightNpcAI(GameNpc tNpc, GameNpc tNpc2) { if (tNpc.isCanFight) { tNpc.speedTime = 0; FightEvent[] fight = tNpc.GetComponents <FightEvent>(); fight[(int)Random.Range(0, fight.Length)].runEvent(); } }
void OnTriggerEnter2D(Collider2D other) { GameNpc npc = other.gameObject.GetComponent <GameNpc>(); if (npc != null) { npc.autoHeal += healOdds; } }
/// <summary> /// Actor Iterator (consider all party members) /// </summary> /// <param Name="parameter">if 1 or more, ID; if 0, all</param> List <GameActor> IterateActor(int parameter) { // If entire party if (parameter == 0) { // Loop for entire party return(InGame.Party.Actors); } // If single actor else { // Get actor GameActor actor = InGame.Actors[parameter - 1]; // Evaluate block if (actor != null) { return new List <GameActor>() { actor } } ; } // Empty return(new List <GameActor>()); } /// <summary> /// Enemy Iterator (consider all troop members) /// </summary> /// <param Name="parameter">If 0 or above, index; if -1, all</param> List <GameNpc> IterateEnemy(int parameter) { // If entire troop if (parameter == -1) { return(InGame.Troops.Npcs); } // If single enemy else { // Get enemy GameNpc enemy = InGame.Troops.Npcs[parameter]; // Evaluate block if (enemy != null) { return new List <GameNpc>() { enemy } } ; } return(new List <GameNpc>()); }
/// <summary> /// Set npc displayed in window /// </summary> /// <param Name="npc">Name and status displaying npc</param> public void SetNpc(GameNpc npc) { string _text = npc.Name; string _state_text = MakeBattlerStateText(npc, 112, false); if (_state_text != "") { _text += " " + _state_text; } SetText(_text, 1); }
/// <summary> /// Enemy Appearance /// </summary> bool Command335() { // Get enemy GameNpc enemy = InGame.Troops.Npcs[InGame.Troops.Npcs.Count - 1 - intParams[0]]; // Clear hidden flag if (enemy != null) { enemy.IsHidden = false; } return(true); }
/// <summary> /// Enemy Transform /// </summary> bool Command336() { // Get enemy GameNpc enemy = InGame.Troops.Npcs[InGame.Troops.Npcs.Count - 1 - intParams[0]]; // Transform processing if (enemy != null) { enemy.Transform(intParams[1]); } return(true); }
/// <summary> /// Deal Damage for Npc /// </summary> /// <param Name="Battler">Npc</param> void dealDamage(int value,GameNpc battler) { // If Battler exists if (battler.IsExist) { // Change HP battler.Hp -= value; // If in battle if (InGame.Temp.IsInBattle) { // Set damage battler.Damage = value.ToString(); battler.IsDamagePop = true; } } }
/// <summary> /// Deal Damage for Npc /// </summary> /// <param Name="Battler">Npc</param> void dealDamage(int value, GameNpc battler) { // If Battler exists if (battler.IsExist) { // Change HP battler.Hp -= value; // If in battle if (InGame.Temp.IsInBattle) { // Set damage battler.Damage = value.ToString(); battler.IsDamagePop = true; } } }
public bool Destroy() { m_szWords = ""; if (m_pShop != null && Vending) { m_vending = false; m_pNpc.Vending = false; m_pNpc.Name = ""; m_pMap.RemoveNpc(m_pShop); m_pOwner.Action = EntityAction.STAND; m_pNpc = null; m_pShop = null; } Items.Clear(); return(true); }
/************************ *不对外开放的函数 * * ************************/ /******************* *基础相关 * * *******************/ //初始化函数,系统自动调用 void Start() { buttonList = new LinkedList <GameObject>(); //初始化移动相关 ani = npc.transform.GetComponent <Animator>(); move = npc.transform.GetComponent <Move>(); //文本相关 textEvent = GameObject.Find("Game").transform.Find("GameGraphics").transform.Find("NoticeCanvas").transform.Find("Notice").transform.GetComponent <TextEvent>(); this.textOfStatusPanel = this.statusPanel.GetComponentInChildren <Text>(); //摄像头相关 gameCanvas = this.transform.Find("GameGraphics").transform.Find("UICanvas").GetComponent <Canvas>(); gameCamera = this.transform.Find("GameCamera").GetComponent <Camera>(); fightCamera = this.transform.Find("GameFight").transform.Find("FightCamera").GetComponent <Camera>(); uiCamera = this.transform.Find("UICamera").GetComponent <Camera>(); //战斗相关 this.myNpc = npc.GetComponent <GameNpc>(); this.myHp = status.transform.Find("MyHp").gameObject; this.myMp = status.transform.Find("MyMp").gameObject; this.mySpeed = status.transform.Find("MySpeed").gameObject; this.enemyHp = status.transform.Find("EnemyHp").gameObject; this.enemyMp = status.transform.Find("EnemyMp").gameObject; this.enemySpeed = status.transform.Find("EnemySpeed").gameObject; //数据相关 this.data = new GameData(this, myNpc); //开始界面 this.textDoc.gameObject.SetActive(false); this.statusPanel.gameObject.SetActive(false); this.backpackPanel.gameObject.SetActive(false); uiCamera.gameObject.SetActive(false); gameCanvas.gameObject.SetActive(false); gameCamera.gameObject.SetActive(false); fightCamera.gameObject.SetActive(false); textEvent.setNotice("任意键继续", 100f, true); PlayerPrefs.SetInt("nowId", 0); PlayerPrefs.SetInt("AllIdCount", 0); }
public bool Create() { m_pMap = m_pOwner.Map; Items = new ConcurrentDictionary <uint, BoothItem>(); m_pNpc = m_pMap.GameObjects.Values.FirstOrDefault(x => x.MapX == m_pOwner.MapX - 2 && x.MapY == m_pOwner.MapY) as GameNpc; if (m_pNpc == null) { return(false); } if (m_pNpc.Vending) { return(false); } Vending = true; m_szWords = ""; m_pOwner.Direction = FacingDirection.SOUTH_EAST; m_pOwner.Action = EntityAction.SIT; var tempDb = new DbDynamicNPC { Id = ((m_pOwner.Identity % 1000000) + ((m_pOwner.Identity / 1000000) * 100000)), Name = m_pOwner.Name, Cellx = (ushort)(m_pNpc.MapX + 3), Celly = m_pNpc.MapY, Type = NpcTypes.BOOTH_NPC, Lookface = 406, Mapid = m_pOwner.MapIdentity, Datastr = "PlayerShop" }; m_pShop = new DynamicNpc(tempDb) { Name = m_pOwner.Name }; m_dwIdentity = m_pShop.Identity; m_pMap.AddDynaNpc(m_pShop); return(true); }
private static uint GetActionIdentity(Character pUser, IScreenObject pNpc) { uint idAction = 0; if (pNpc is GameNpc) { GameNpc pGameNpc = pNpc as GameNpc; for (int i = 0; i < 8; i++) { switch (i) { case 0: idAction = pGameNpc.Task0; break; case 1: idAction = pGameNpc.Task1; break; case 2: idAction = pGameNpc.Task2; break; case 3: idAction = pGameNpc.Task3; break; case 4: idAction = pGameNpc.Task4; break; case 5: idAction = pGameNpc.Task5; break; case 6: idAction = pGameNpc.Task6; break; case 7: idAction = pGameNpc.Task7; break; } TaskStruct pTask; if (ServerKernel.GameTasks.TryGetValue(idAction, out pTask)) { bool bItem1 = true, bItem2 = true, bMoney = true, bProf = true, bSex = true, bMinPk = true, bMaxPk = true, bTeam = true, bMetem = true, bMarriage = true; if (pTask.Itemname1 != "") { bItem1 = pUser.Inventory.Items.Values.FirstOrDefault(x => x.Itemtype.Name == pTask.Itemname1) != null; } if (pTask.Itemname2 != "") { bItem2 = pUser.Inventory.Items.Values.FirstOrDefault(x => x.Itemtype.Name == pTask.Itemname2) != null; } if (pTask.Money > 0) { bMoney = pUser.Silver >= pTask.Money; } if (pTask.Profession > 0) { if (pTask.Profession > 9) { bProf = pUser.Profession / 10 == pTask.Profession; } else { bProf = pUser.Profession == pTask.Profession; } } if (pTask.Sex > 0 && pTask.Sex < 999) { bSex = pUser.Gender == pTask.Sex; } bMinPk = pUser.PkPoints >= pTask.MinPk; bMaxPk = pUser.PkPoints <= pTask.MaxPk; if (pTask.Team != 0 && pTask.Team != 999) { bTeam = pUser.Team != null; } if (pTask.Metempsychosis > 0) { bMetem = pUser.Metempsychosis >= pTask.Metempsychosis; } if (pTask.Marriage > 0) { bMarriage = pUser.Mate != "None"; } bool bRet = bItem1 && bItem2 && bMoney && bProf && bSex && bMinPk && bMaxPk && bTeam && bMetem && bMarriage; if (bRet) { idAction = pTask.IdNext; break; } if (!bRet && pTask.IdNextfail != 0) { idAction = pTask.IdNextfail; break; } } } } else if (pNpc is DynamicNpc) { DynamicNpc pGameNpc = pNpc as DynamicNpc; for (int i = 0; i < 8; i++) { switch (i) { case 0: idAction = pGameNpc.Task0; break; case 1: idAction = pGameNpc.Task1; break; case 2: idAction = pGameNpc.Task2; break; case 3: idAction = pGameNpc.Task3; break; case 4: idAction = pGameNpc.Task4; break; case 5: idAction = pGameNpc.Task5; break; case 6: idAction = pGameNpc.Task6; break; case 7: idAction = pGameNpc.Task7; break; } TaskStruct pTask; if (ServerKernel.GameTasks.TryGetValue(idAction, out pTask)) { bool bItem1 = true, bItem2 = true, bMoney = true, bProf = true, bSex = true, bMinPk = true, bMaxPk = true, bTeam = true, bMetem = true, bMarriage = true; if (pTask.Itemname1 != "") { bItem1 = pUser.Inventory.Items.Values.FirstOrDefault(x => x.Itemtype.Name == pTask.Itemname1) != null; } if (pTask.Itemname2 != "") { bItem2 = pUser.Inventory.Items.Values.FirstOrDefault(x => x.Itemtype.Name == pTask.Itemname2) != null; } if (pTask.Money > 0) { bMoney = pUser.Silver >= pTask.Money; } if (pTask.Profession > 0) { if (pTask.Profession > 9) { bProf = pUser.Profession / 10 == pTask.Profession; } else { bProf = pUser.Profession == pTask.Profession; } } if (pTask.Sex > 0 && pTask.Sex < 999) { bSex = pUser.Gender == pTask.Sex; } bMinPk = pUser.PkPoints >= pTask.MinPk; bMaxPk = pUser.PkPoints <= pTask.MaxPk; if (pTask.Team != 0 && pTask.Team != 999) { bTeam = pUser.Team != null; } if (pTask.Metempsychosis > 0) { bMetem = pUser.Metempsychosis >= pTask.Metempsychosis; } if (pTask.Marriage > 0) { bMarriage = pUser.Mate != "None"; } bool bRet = bItem1 && bItem2 && bMoney && bProf && bSex && bMinPk && bMaxPk && bTeam && bMetem && bMarriage; if (bRet) { idAction = pTask.IdNext; break; } if (!bRet && pTask.IdNextfail != 0) { idAction = pTask.IdNextfail; break; } } } } return(idAction); }
public float skillHurtAdd; //伤害附加 /****************************** *对继承类接口 *调用其他类的功能请在这里调用 *继承类不得自己调用 ******************************/ protected virtual void attackNpc(GameNpc enemyNpc, float hurt) { enemyNpc.minusHp(hurt); this.addExp(1); }
//一般攻击 public void normalAttack(GameNpc npc) { npc.hp -= getPhysicsRealAttack(this, npc); }
/// <summary> /// Conditional Branch /// </summary> bool Command111() { // Initialize local variable: result bool result = false; switch (intParams[0]) { #region if switch case 0: // switch result = (InGame.Switches.Arr[intParams[1]] == (intParams[2] == 0)); break; #endregion #region if variable case 1: // variable int value1 = InGame.Variables.Arr[intParams[1]]; int value2; if (intParams[2] == 0) { value2 = intParams[3]; } else { value2 = InGame.Variables.Arr[intParams[3]]; } switch (intParams[4]) { case 0: // value1 is equal to value2 result = (value1 == value2); break; case 1: // value1 is greater than or equal to value2 result = (value1 >= value2); break; case 2: // value1 is less than or equal to value2 result = (value1 <= value2); break; case 3: // value1 is greater than value2 result = (value1 > value2); break; case 4: // value1 is less than value2 result = (value1 < value2); break; case 5: // value1 is not equal to value2 result = (value1 != value2); break; } break; #endregion #region if self switch case 2: // self switch if (eventId > 0) { GameSwitch key = new GameSwitch(InGame.Map.MapId, eventId, stringParams[0]); if (intParams[1] == 0) { result = (InGame.System.GameSelfSwitches[key] == true); } else { result = (InGame.System.GameSelfSwitches[key] != true); } } break; #endregion #region if Timer case 3: // Timer if (InGame.System.IsTimerWorking) { int sec = InGame.System.Timer / Graphics.FrameRate; if (intParams[2] == 0) { result = (sec >= intParams[1]); } else { result = (sec <= intParams[1]); } } break; #endregion #region if actor case 4: // actor GameActor actor = InGame.Actors[intParams[1] - 1]; if (actor != null) { switch (intParams[2]) { case 0: // in party result = InGame.Party.Actors.Contains(actor); break; case 1: // Name result = (actor.Name == stringParams[0]); break; case 2: // skill result = (actor.IsSkillLearn(intParams[3])); break; case 3: // weapon result = (actor.WeaponId == intParams[3]); break; case 4: // armor int test = intParams[3]; result = (actor.ArmorShield == test || actor.ArmorHelmet == test || actor.ArmorBody == test || actor.ArmorAccessory == test); break; case 5: // state result = (actor.IsState(intParams[3])); break; } } break; #endregion #region if enemy case 5: // enemy GameNpc enemy = InGame.Troops.Npcs[intParams[1]]; if (enemy != null) { switch (intParams[2]) { case 0: // appear result = (enemy.IsExist); break; case 1: // state result = (enemy.IsState(intParams[3])); break; } } break; #endregion #region if Character case 6: // Character GameCharacter character = GetCharacter(intParams[1]); if (character != null) { result = (character.Dir == intParams[2]); } break; #endregion #region if gold case 7: // gold if (intParams[2] == 0) { result = (InGame.Party.Gold >= intParams[1]); } else { result = (InGame.Party.Gold <= intParams[1]); } break; #endregion #region if item case 8: // item result = (InGame.Party.ItemNumber(intParams[1]) > 0); break; #endregion #region if weapon case 9: // weapon result = (InGame.Party.WeaponNumber(intParams[1]) > 0); break; #endregion #region if armor case 10: // armor result = (InGame.Party.ArmorNumber(intParams[1]) > 0); break; #endregion #region if button case 11: // button result = (Input.IsPressed(intParams[1])); break; #endregion #region if EL case 12: // script // no scripting - result = eval(parameters[1]); result = MakeCommand.LastCondition; break; #endregion } // Store determinant results in hash branch[list[index].Indent].Result = result; // If determinant results are true if (result == true) { return(true); } // If it doesn't meet the conditions: command skip return(CommandSkip()); }
//更新 private void uploadStatus(GameNpc npc) { this.textOfStatusPanel.text = NpcStatus.getStatus(npc); }
/****************************** *对外开放的接口 * * ******************************/ public static int saveNpc(GameNpc npc, int id) { if (npc == null) { return(0); } string sId = id.ToString(); //存储基本信息 PlayerPrefs.SetInt(sId + "_id", id); PlayerPrefs.SetString(sId + "_name", npc.npcName); PlayerPrefs.SetFloat(sId + "_x", npc.transform.position.x); PlayerPrefs.SetFloat(sId + "_y", npc.transform.position.y); PlayerPrefs.SetFloat(sId + "_z", npc.transform.position.z); PlayerPrefs.SetFloat(sId + "_hp", npc.hp); PlayerPrefs.SetFloat(sId + "_maxHp", npc.maxHp); PlayerPrefs.SetFloat(sId + "_mp", npc.mp); PlayerPrefs.SetFloat(sId + "_maxMp", npc.maxMp); PlayerPrefs.SetFloat(sId + "_pAttlow", npc.pAttLow); PlayerPrefs.SetFloat(sId + "_pAttHigh", npc.pAttHigh); PlayerPrefs.SetFloat(sId + "_mAttlow", npc.mAttLow); PlayerPrefs.SetFloat(sId + "_mAttHigh", npc.mAttHigh); PlayerPrefs.SetFloat(sId + "_pDefPower", npc.pDefPower); PlayerPrefs.SetFloat(sId + "_mDefPower", npc.mDefPower); PlayerPrefs.SetInt(sId + "_lvl", npc.lvl); PlayerPrefs.SetInt(sId + "_maxLvl", npc.maxLvl); PlayerPrefs.SetFloat(sId + "_exp", npc.exp); PlayerPrefs.SetFloat(sId + "_maxExp", npc.maxExp); PlayerPrefs.SetFloat(sId + "_money", npc.money); PlayerPrefs.SetFloat(sId + "_maxMoney", npc.maxMoney); PlayerPrefs.SetInt(sId + "_liliang", npc.liliang); PlayerPrefs.SetInt(sId + "_minjie", npc.minjie); PlayerPrefs.SetInt(sId + "_zhili", npc.zhili); PlayerPrefs.SetInt(sId + "_tizhi", npc.tizhi); PlayerPrefs.SetFloat(sId + "_norFightSpeed", npc.norFightSpeed); PlayerPrefs.SetFloat(sId + "_fightSpeedAmp", npc.fightSpeedAmp); PlayerPrefs.SetFloat(sId + "_pVioHurtAmp", npc.pVioHurtAmp); PlayerPrefs.SetFloat(sId + "_pVioHurtAdd", npc.pVioHurtAdd); PlayerPrefs.SetFloat(sId + "_pVioHurtOdds", npc.pVioHurtOdds); PlayerPrefs.SetFloat(sId + "_pVioHurtMissDefAmp", npc.pVioHurtMissDefAmp); PlayerPrefs.SetFloat(sId + "_pVioHurtMissDefAdd", npc.pVioHurtMissDefAdd); PlayerPrefs.SetFloat(sId + "_pVioHurtMissDefOdds", npc.pVioHurtMissDefOdds); PlayerPrefs.SetFloat(sId + "_doeOdds", npc.doeOdds); PlayerPrefs.SetFloat(sId + "_recoverHpPerSecond", npc.recoverHpPerSecond); PlayerPrefs.SetFloat(sId + "_recoverMpPerSecond", npc.recoverMpPerSecond); PlayerPrefs.SetFloat(sId + "_recoverHpPerHit", npc.recoverHpPerHit); PlayerPrefs.SetFloat(sId + "_recoverMpPerHit", npc.recoverMpPerHit); PlayerPrefs.SetFloat(sId + "_extraItemOdds", npc.extraItemOdds); PlayerPrefs.SetFloat(sId + "_extraExpOdds", npc.extraExpOdds); PlayerPrefs.SetFloat(sId + "_extraMoneyOdds", npc.extraMoneyOdds); //存储技能 FightEvent[] f = npc.GetComponents <FightEvent>(); for (int i = 0; i < f.Length; i++) { PlayerPrefs.SetInt(sId + "_Skill" + "_" + f[i].id, f[i].id); PlayerPrefs.SetString(sId + "_Skill" + "_" + f[i].id + "_name", f[i].skillName); PlayerPrefs.SetString(sId + "_Skill" + "_" + f[i].id + "_text", f[i].skillText); PlayerPrefs.SetInt(sId + "_Skill" + "_" + f[i].id + "_lvl", f[i].skillLvl); PlayerPrefs.SetInt(sId + "_Skill" + "_" + f[i].id + "_maxLvl", f[i].skillMaxLvl); PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_exp", f[i].skillExp); PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_maxExp", f[i].skillMaxExp); PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_hurtAmp", f[i].skillHurtAmp); PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_hurtAdd", f[i].skillHurtAdd); } return(1); }
/// <summary> /// Control Variables /// </summary> bool Command122() { // Initialize value int value = 0; // Branch with operand switch (intParams[3]) { case 0: // invariable value = intParams[4]; break; case 1: // variable value = InGame.Variables.Arr[intParams[4]]; break; case 2: // random number value = intParams[4] + InGame.Rnd.Next(intParams[5] - intParams[4] + 1); break; case 3: // item value = InGame.Party.ItemNumber(intParams[4]); break; case 4: // actor GameActor actor = InGame.Actors[intParams[4] - 1]; if (actor != null) { switch (intParams[5]) { case 0: // level value = actor.Level; break; case 1: // EXP value = actor.Exp; break; case 2: // HP value = actor.Hp; break; case 3: // SP value = actor.Sp; break; case 4: // MaxHp value = actor.MaxHp; break; case 5: // MaxSp value = actor.MaxSp; break; case 6: // strength value = actor.Str; break; case 7: // dexterity value = actor.Dex; break; case 8: // agility value = actor.Agi; break; case 9: // intelligence value = actor.Intel; break; case 10: // attack power value = actor.Atk; break; case 11: // physical defense value = actor.Pdef; break; case 12: // magic defense value = actor.Mdef; break; case 13: // evasion value = actor.Eva; break; } } break; case 5: // enemy GameNpc enemy = InGame.Troops.Npcs[intParams[4]]; if (enemy != null) { switch (intParams[5]) { case 0: // HP value = enemy.Hp; break; case 1: // SP value = enemy.Sp; break; case 2: // MaxHp value = enemy.MaxHp; break; case 3: // MaxSp value = enemy.MaxSp; break; case 4: // strength value = enemy.Str; break; case 5: // dexterity value = enemy.Dex; break; case 6: // agility value = enemy.Agi; break; case 7: // intelligence value = enemy.Intel; break; case 8: // attack power value = enemy.Atk; break; case 9: // physical defense value = enemy.Pdef; break; case 10: // magic defense value = enemy.Mdef; break; case 11: // evasion correction value = enemy.Eva; break; } } break; case 6: // Character if (intParams[4] == -1) { value = ChangeGamePlayer(); } else { GameCharacter character = GetCharacter(intParams[4]); value = ChangeGameEvent(ref character); } break; case 7: // other switch (intParams[4]) { case 0: // map ID value = InGame.Map.MapId; break; case 1: // number of party members value = InGame.Party.Actors.Count; break; case 2: // gold value = InGame.Party.Gold; break; case 3: // steps value = InGame.Party.Steps; break; case 4: // play time value = Graphics.FrameCount / Graphics.FrameRate; break; case 5: // Timer value = InGame.System.Timer / Graphics.FrameRate; break; case 6: // save count value = InGame.System.SaveCount; break; } break; } // Loop for group control for (int i = intParams[0]; i <= intParams[1]; i++) { // Branch with control switch (intParams[2]) { case 0: // substitute InGame.Variables.Arr[i] = value; break; case 1: // add InGame.Variables.Arr[i] += value; break; case 2: // subtract InGame.Variables.Arr[i] -= value; break; case 3: // multiply InGame.Variables.Arr[i] *= value; break; case 4: // divide if (value != 0) { InGame.Variables.Arr[i] /= value; } break; case 5: // remainder if (value != 0) { InGame.Variables.Arr[i] %= value; } break; } // Maximum limit check if (InGame.Variables.Arr[i] > 99999999) { InGame.Variables.Arr[i] = 99999999; } // Minimum limit check if (InGame.Variables.Arr[i] < -99999999) { InGame.Variables.Arr[i] = -99999999; } // Refresh map InGame.Map.IsNeedRefresh = true; } // Continue return(true); }
public static string getStatus(GameNpc npc) { Color color = Color.black; string str; //LVL color.r = 1f - npc.lvl / npc.maxLvl; color.g = 1f - npc.lvl / npc.maxLvl; color.b = 1f - npc.lvl / npc.maxLvl; str = "等级:" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.lvl + "</color>" + "/" + npc.maxLvl; //EXP color.r = 1f - npc.exp / npc.maxExp; color.g = 1f - npc.exp / npc.maxExp; color.b = 1f - npc.exp / npc.maxExp; str += "(" + npc.exp + "/" + npc.maxExp + ")\n"; //HP color.r = 1f - npc.hp / npc.maxHp; color.g = npc.hp / npc.maxHp; color.b = 0f; str += "HP:" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.hp + "</color>" + "/" + npc.maxHp + " "; //MP color.r = 1f - npc.mp / npc.maxMp; color.b = npc.mp / npc.maxMp; color.g = 0f; str += " MP :" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.mp + "</color>" + "/" + npc.maxMp + "\n"; //物理攻击 str += " 物理伤害 :" + "<color=#FF6400FF>" + npc.pAttLow + "</color>" + "/" + npc.pAttHigh + " "; //法术攻击 str += " 法术伤害 :" + "<color=#3D00FFFF>" + npc.mAttLow + "</color>" + "/" + npc.mAttHigh + "\n"; //物理防御 str += " 物理防御 :" + "<color=#FF6400FF>" + npc.pDefPower + "</color> "; //法术防御 str += " 法术防御 :" + "<color=#3D00FFFF>" + npc.mDefPower + "</color>\n"; //力量 color.r = 1f; color.g = npc.liliang / npc.lvl * 50; color.b = 1f; str += " 力量 :" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.liliang + "</color>" + " "; //敏捷 color.r = 1f; color.g = npc.minjie / npc.lvl * 50; color.b = 1f; str += " 敏捷 :" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.minjie + "</color>" + " "; //智力 color.r = 1f; color.g = npc.zhili / npc.lvl * 50; color.b = 1f; str += " 智力 :" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.zhili + "</color>" + " "; //体质 color.r = 1f; color.g = npc.tizhi / npc.lvl * 50; color.b = 1f; str += " 体质 :" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.tizhi + "</color>" + "\n"; //攻击速度 color = Color.yellow; str += " 速度 :" + "<color=" + ColorToHex.colorToHex(color) + ">" + npc.norFightSpeed + "</color>" + "+" + "<color=#FF0000FF>" + (npc.fightSpeedAmp * npc.norFightSpeed) + "</color> "; //闪避概率 str += " 闪避几率 :" + "<color=#00DB89FF>" + npc.doeOdds + "</color> "; //物理暴击概率 str += " 物暴几率 :" + "<color=#FF6400FF>" + npc.pVioHurtOdds + "</color>\n"; //物理暴击加成 str += " 物暴伤害加成 :" + "<color=#FF6400FF>" + npc.pVioHurtAmp + "</color> "; //物理暴击附加 str += " 物暴伤害附加 :" + "<color=#FF6400FF>" + npc.pVioHurtAdd + "</color>\n"; //物理暴击时无视防御力几率 str += " 物暴无视防御几率 :" + "<color=#FF6400FF>" + npc.pVioHurtMissDefOdds + "</color>\n"; //物理暴击时无视防御力比例 str += " 物暴无视防御比例 :" + "<color=#FF6400FF>" + npc.pVioHurtMissDefAmp + "</color> "; //物理暴击时无视防御力附加 str += " 物暴无视防御附加 :" + "<color=#FF6400FF>" + npc.pVioHurtMissDefAdd + "</color>\n"; //每秒回复HP str += " 每秒回复HP :" + "<color=#00FF00FF>" + npc.recoverHpPerSecond + "</color>+" + "<color=#FF0000FF>" + (npc.autoHeal * npc.maxHp / 100f) + "</color> "; //击中回复HP str += " 每秒回复HP :" + "<color=#00FF00FF>" + npc.recoverHpPerHit + "</color>\n"; //每秒回复MP str += " 每秒回复MP :" + "<color=#3D00FFFF>" + npc.recoverMpPerSecond + "</color>+" + "<color=#FF0000FF>" + (npc.autoMuse * npc.maxMp / 100f) + "</color> "; //击中回复MP str += " 每秒回复MP :" + "<color=#3D00FFFF>" + npc.recoverMpPerHit + "</color>\n"; return(str); }
public GameData(MainGame mainGame, GameNpc npc) { this.mainGame = mainGame; this.npc = npc; this.allIdCount = PlayerPrefs.GetInt("AllIDCount"); }