/// <summary> /// 对单个目标进行伤害处理 /// </summary> /// <param name="targeter"></param> /// <param name="attackerModel"></param> /// <param name="attacker">技能道具等情况下 attacker 为 null </param> /// <param name="factor"></param> public static void ProcessDamageOneTargeter(TileEntity targeter, EntityModel attackerModel, TileEntity attacker = null, float factor = 1.0f) { if (!targeter.IsDead()) { // 计算伤害 float damage = CalcDamageValue(targeter.model, attackerModel, attacker, factor); // 处理伤害 targeter.MakeDamage(damage); // 没死亡时附加buffer效果 if (!targeter.IsDead()) { GameBufferComponent bufferMgr = targeter.GetComponent <GameBufferComponent>(); if (bufferMgr != null) { bufferMgr.AddBuffer(attackerModel); } } else { // [特殊技能] 死亡后大回复 if (EntityTypeUtil.IsTraitBlessing(targeter.model)) { // TODO: } } // [特殊技能] 吸血 REMARK:考虑是否需要回血光效? if (attacker != null && damage > 0 && EntityTypeUtil.IsTraitSuckBlood(attackerModel)) { attacker.MakeDamage(-damage * Constants.SUCK_BLOOD_RATIO); } } }
/// <summary> /// 添加一个工人 /// </summary> /// <param name="workman"></param> /// <returns></returns> public bool AddAWorkman(TileEntity workman) { var comp = workman.GetComponent <WorkmanComponent>(); // 没有工作能力的工人 o(╯□╰)o if (comp == null) { return(false); } Assert.Should(_workerHash != null); _workerHash.Add(workman, comp); comp.OnAddToWorkerHouse(Entity); return(true); }
private void RefreshWallLinkerAndDirection(TileEntity entity, int entity_id) { Vector2 c = entity.GetCurrentPositionCenter(); int x = (int)c.x; int y = (int)c.y; int w = entity.width; // entity_id为0则取消连接,不为0则设置连接。 int wallLinkerId = (entity_id != 0 ? m_wallLinkerId : 0); // REMARK:目前这里只连接了一个格子(如果墙的尺寸有变 这里需要相应的调整 否则会出BUG) // +Y // w w // w // w w // -X-Y +X TileEntity wall; // 左上 if ((wall = GetWallStrict(x, y + w)) != null) { m_routeMap[x, y + 1].EntityID = wallLinkerId; wall.GetComponent <WallComponent>().RefreshWallDirection(); } // 右上 if ((wall = GetWallStrict(x + w, y)) != null) { m_routeMap[x + 1, y].EntityID = wallLinkerId; wall.GetComponent <WallComponent>().RefreshWallDirection(); } // 左下 if ((wall = GetWallStrict(x - w, y)) != null) { m_routeMap[x - 1, y].EntityID = wallLinkerId; wall.GetComponent <WallComponent>().RefreshWallDirection(); } // 右下 if ((wall = GetWallStrict(x, y - w)) != null) { m_routeMap[x, y - 1].EntityID = wallLinkerId; wall.GetComponent <WallComponent>().RefreshWallDirection(); } // 刷新新建的墙自身的显示 if (entity_id != 0) { entity.GetComponent <WallComponent>().RefreshWallDirection(); } }
public override void Death() { if (fruitName == "Choux" && QuestManager.Instance.indexQuest == 0) { QuestManager.Instance.indexQuest = 1; TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); te.tile = World.instance.GetTile(45, 52); te.transform.position = te.tile.transform.position; for (int i = 0; i < te.transform.childCount; i++) { te.transform.GetChild(i).GetComponent <MeshRenderer> ().enabled = true; } te.tile.entity = te; te.enabled = true; te.GetComponent <MeshRenderer> ().enabled = true; GameObject.Find("Boussole").GetComponent <Boussole> ().TargetNext(); } base.Death(); }
public void GenerateCell(Vector2 pos, Vector2 keyPos) { GameObject newGameObj = Instantiate(cellPrefab, pos, cellPrefab.transform.rotation); TileEntity newCell = newGameObj.GetComponent <TileEntity>(); newCell.CreateTile(Wall, Wall, Wall, Wall); newCell.Position = new Vector2Int((int)keyPos.x, (int)keyPos.y); if (mazeParent != null) { newCell.transform.parent = mazeParent.transform; } newCell.name = "Cell - X:" + keyPos.x + " Y:" + keyPos.y; if (disableCellSprite) { newCell.GetComponent <SpriteRenderer>().enabled = false; } allCells[keyPos] = newCell; unvisited.Add(newCell); }
/// <summary> /// 计算目标的伤害值(伤害公式) /// </summary> /// <param name="targeterModel"></param> /// <param name="attackerModel"></param> /// <param name="attacker">技能道具等情况下 attacker 为 null </param> /// <param name="factor">伤害修正系数</param> /// <returns></returns> private static float CalcDamageValue(EntityModel targeterModel, EntityModel attackerModel, TileEntity attacker = null, float factor = 1.0f) { float damage = 0.0f; if (EntityTypeUtil.IsCurer(attackerModel)) { // 回血为负 damage = -factor * attackerModel.cure; } else { // REMARK:伤害公式可以调整 damage = attackerModel.damage - targeterModel.defense; if (attackerModel.additionDamageSubType != Constants.EMPTY && attackerModel.additionDamageSubType == targeterModel.subType) { damage *= attackerModel.additionDamageRatio; } // 技能伤害的时候 attacker 不存在 if (attacker != null) { // [攻击提升] buffer 的情况下乘以伤害倍率 GameBufferComponent attackerBufferMgr = attacker.GetComponent <GameBufferComponent>(); if (attackerBufferMgr != null) { var buffer = attackerBufferMgr.GetBuffer(Constants.BUFF_TYPE_ATTACKUP); if (buffer != null) { damage *= buffer.buffDamage; } } } damage = Mathf.Max(damage * factor, 0); } // 处理伤害 return(damage); }
public void FailQuest() { QuestManager.Instance.finishQuest(this); if (questId == 5) { QuestManager.Instance.indexQuest = -10; new Quest(linkedNpcId, 16); } if (questId == 1) { QuestManager.Instance.indexQuest = 1; GameObject.Find("Boussole").GetComponent <Boussole> ().TargetNext(); TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); te.tile = World.instance.GetTile(45, 52); te.transform.position = te.tile.transform.position; for (int i = 0; i < te.transform.childCount; i++) { te.transform.GetChild(i).GetComponent <MeshRenderer> ().enabled = true; } te.tile.entity = te; te.enabled = true; te.GetComponent <MeshRenderer> ().enabled = true; } }
public void QuestComplete() { if (questId == 0 || questId == 3 || questId == 1 || questId == 5 || questId == 6 || questId == 7 || questId == 16) { GameObject.Find("Boussole").GetComponent <Boussole> ().TargetNext(); } if (questId == 0 || questId == 3 || questId == 6) { TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); for (int i = 0; i < te.transform.childCount; i++) { te.transform.GetChild(i).GetComponent <MeshRenderer> ().enabled = false; } te.tile.entity = null; te.enabled = false; te.GetComponent <MeshRenderer> ().enabled = false; } if (questId == 3) { QuestManager.Instance.indexQuest = 2; } if (questId == 1 || questId == 2) { QuestManager.Instance.IncreaseFood(100); if (QuestManager.Instance.indexQuest == 0) { QuestManager.Instance.indexQuest = 1; TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); te.tile = World.instance.GetTile(45, 52); te.transform.position = te.tile.transform.position; for (int i = 0; i < te.transform.childCount; i++) { te.transform.GetChild(i).GetComponent <MeshRenderer> ().enabled = true; } te.tile.entity = te; te.enabled = true; te.GetComponent <MeshRenderer> ().enabled = true; } } if (questId == 4) { GameObject.Find("Pnj (Soldier)").GetComponent <Pnj> ().moveText = "zddddddddddsssssdds"; QuestManager.Instance.indexQuest = 3; } if (questId == 5 || questId == 16) { QuestManager.Instance.indexQuest = 5; TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); te.tile = World.instance.GetTile(45, 52); te.transform.position = te.tile.transform.position; for (int i = 0; i < te.transform.childCount; i++) { te.transform.GetChild(i).GetComponent <MeshRenderer> ().enabled = true; } te.tile.entity = te; te.enabled = true; te.GetComponent <MeshRenderer> ().enabled = true; GameObject.Find("Player").GetComponent <Player> ().hasSword = true; } if (questId == 6) { QuestManager.Instance.indexQuest = 6; } if (questId == 7) { GameObject.Find("Pnj (Guard)").GetComponent <Pnj> ().moveText = "odddddddddzzzzzd"; GameObject.Find("Pnj (Guard) (1)").GetComponent <Pnj> ().moveText = "oosdddddddddzzzzzq"; if (linkedNpcId == 3) { GameObject.Find("Player").GetComponent <Player> ().moveText = "sddddddddddzzzzzz"; } else if (linkedNpcId == 4) { GameObject.Find("Player").GetComponent <Player> ().moveText = "oddddddddddzzzzzz"; } QuestManager.Instance.indexQuest = 7; } if (questId == 8) { GameObject.Find("Pnj (King)").transform.Find("Child").gameObject.SetActive(true); QuestManager.Instance.indexQuest = 9; new Quest(5, 9); } if (questId == 9) { QuestManager.Instance.indexQuest = 10; GameObject.Find("Pnj (Guard)").GetComponent <Pnj> ().moveText = "qssq"; GameObject.Find("Pnj (Guard) (1)").GetComponent <Pnj> ().moveText = "odssd"; } if (questId == 10) { QuestManager.Instance.indexQuest = 12; TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); te.tile.entity = null; te.tile = World.instance.GetTile(20, 90); te.transform.position = te.tile.transform.position; te.tile.entity = te; GameObject.Find("Player").GetComponent <Player> ().targetCoord = new Vector2(13, 91); } if (questId == 11) { QuestManager.Instance.indexQuest = 15; TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); te.Death(); } if (questId == 16) { GameObject.Find("Pnj (Soldier)").GetComponent <Pnj> ().ReallyDeath(); } QuestManager.Instance.playerKarma += karmaModifier; QuestManager.Instance.finishQuest(this); }
// Update is called oncespeedframe void Update() { bool move = true; Vector3 pPos = world.player.transform.position; if (hostile) { if (Time.time < time + actualSpeed) { return; } time = Time.time; actualSpeed = speed; if (pPos.y > transform.position.y) { orientation = Direction.NORTH; tilePos = world.GetTile(tile.x, (tile.y >= World.height - 1 ? -1 : tile.y) + 1); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x, transform.position.y + 1, 0); } } else if (pPos.x < transform.position.x) { orientation = Direction.WEST; tilePos = world.GetTile((tile.x <= 0 ? World.width : tile.x) - 1, tile.y); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x - 1, transform.position.y, 0); } } else if (pPos.y < transform.position.y) { orientation = Direction.SOUTH; tilePos = world.GetTile(tile.x, (tile.y <= 0 ? World.height : tile.y) - 1); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x, transform.position.y - 1, 0); } } else if (pPos.x > transform.position.x) { orientation = Direction.EAST; tilePos = world.GetTile((tile.x >= World.width - 1 ? -1 : tile.x) + 1, tile.y); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x + 1, transform.position.y, 0); } } else { move = false; } if (move) { tryAttack(); OnMove(); transform.eulerAngles = new Vector3(0, 0, 180 - ((int)orientation * 90)); switch (tile.GetComponent <MeshRenderer> ().material.name.Split(' ') [0]) { case "Sand": actualSpeed += 0.4f; break; case "Herbe": break; case "Champs": actualSpeed += 0.75f; break; case "Route": actualSpeed -= 0.050f; break; case "Water": actualSpeed += 1; break; case "Rail": actualSpeed += 1; break; } } return; } if (Time.time < time + sspeed) { return; } time = Time.time; if (moveText.Length > 0) { switch (moveText [0]) { case 'z': orientation = Direction.NORTH; tilePos = world.GetTile(tile.x, (tile.y >= World.height - 1 ? -1 : tile.y) + 1); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x, transform.position.y + 1, 0); moveText = moveText.Remove(0, 1); } break; case 'd': orientation = Direction.EAST; tilePos = world.GetTile((tile.x >= World.width - 1 ? -1 : tile.x) + 1, tile.y); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x + 1, transform.position.y, 0); moveText = moveText.Remove(0, 1); } break; case 's': orientation = Direction.SOUTH; tilePos = world.GetTile(tile.x, (tile.y <= 0 ? World.height : tile.y) - 1); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x, transform.position.y - 1, 0); moveText = moveText.Remove(0, 1); } break; case 'q': orientation = Direction.WEST; tilePos = world.GetTile((tile.x <= 0 ? World.width : tile.x) - 1, tile.y); if (tilePos.IsWalkable()) { transform.position = new Vector3(transform.position.x - 1, transform.position.y, 0); moveText = moveText.Remove(0, 1); } break; default: moveText = moveText.Remove(0, 1); break; } OnMove(); transform.eulerAngles = new Vector3(0, 0, 180 - ((int)orientation * 90)); } else if (moveText.Length == 0 && npcID == 2 && QuestManager.Instance.indexQuest == 3) { orientation = Direction.EAST; QuestManager.Instance.indexQuest = 4; } else if (moveText.Length == 0 && (npcID == 3 || npcID == 4) && QuestManager.Instance.indexQuest == 7) { QuestManager.Instance.indexQuest = 8; } else if (moveText.Length == 0 && (npcID == 3 || npcID == 4) && QuestManager.Instance.indexQuest == 10) { QuestManager.Instance.indexQuest = 11; TileEntity te = GameObject.Find("Pnj (Dadghost)").GetComponent <TileEntity> (); te.tile = World.instance.GetTile(82, 86); te.transform.position = te.tile.transform.position; for (int i = 0; i < te.transform.childCount; i++) { te.transform.GetChild(i).GetComponent <MeshRenderer> ().enabled = true; } te.tile.entity = te; te.enabled = true; te.GetComponent <MeshRenderer> ().enabled = true; } }