// Update is called once per frame void OnMouseDown() { if (magic.GetInst().curmagic_id == 5) { status.Heal(80); EffectManager.GetInst().ShowEffect_Summon(this.CurHex.gameObject, 12, 1); CostManager.GetInst().CostDecrease(CostManager.GetInst().Curcostnum); MapManager.GetInst().ResetMapColor(); CameraManager.GetInst().ResetCameraTarget(); magic.GetInst().curmagic_id = 0; } if (magic.GetInst().curmagic_id == 8) { if (Equip == false) { EquipShield(); EffectManager.GetInst().ShowEffect_Summon(this.CurHex.gameObject, 12, 1); CostManager.GetInst().CostDecrease(CostManager.GetInst().Curcostnum); MapManager.GetInst().ResetMapColor(); CameraManager.GetInst().ResetCameraTarget(); magic.GetInst().curmagic_id = 0; } else { MapManager.GetInst().ResetMapColor(); CameraManager.GetInst().ResetCameraTarget(); } } else { PlayerManager.GetInst().select_object = this; PlayerManager.GetInst().SetPickPos(this); } }
void OnMouseDown() { if (InGame == true && PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx].act != ACT.STUN) { if (CostManager.GetInst().cur_cost_num >= cost) { if (On_active == true) { PlayerBase pb = PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx]; Manager.GetInst().MoveCamPosToTile(pb.CurHex); PlayerManager.GetInst().HilightSummons(); act = ACT.SUMMONES; CostManager.GetInst().CostDecrease(cost); On_active = false; } } } else { if (PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx].act != ACT.STUN) { CardLoadManager.GetInst().OnCard(summon_id); } } }
void OnMouseDown() { if (InGame == true && PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx].act != ACT.STUN) { if (CostManager.GetInst().cur_cost_num >= cost) { if (On_active == true) { if (magic_id == 2 || magic_id == 6) { magic.GetInst().type = "water"; } else if (magic_id == 3) { magic.GetInst().type = "wall"; Debug.Log("fire"); } else if (magic_id == 4) { magic.GetInst().type = "wind"; } else if (magic_id == 1 || magic_id == 7) { magic.GetInst().type = "fire"; } else { magic.GetInst().type = "buff"; } magic.GetInst().curmagic_id = magic_id; PlayerBase pb = PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx]; Manager.GetInst().MoveCamPosToTile(pb.CurHex); PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx].act = ACT.MAGIC; CostManager.GetInst().Curcostnum = cost; Debug.Log(CostManager.GetInst().Curcostnum); if (magic_id == 3) { MapManager.GetInst().HilightAttackRange(pb.CurHex, 2); } else { MapManager.GetInst().HilightAttackRange(pb.CurHex, 4); } On_click = true; } } } else { Debug.Log("Dww"); if (PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx].act != ACT.STUN) { CardLoadManager.GetInst().OnCard(magic_id); } } }
public void TurnOver() { MapManager.GetInst().ResetMapColor(); PlayerBase pb = Players[CurTurnIdx]; pb.CurHex.Passable = false; if (pb.act != ACT.CASTING) { pb.act = ACT.IDLE; } if (Players.Count > 0) { CurTurnIdx++; } if (CurTurnIdx >= Players.Count) { CurTurnIdx = 0; } PlayerBase pb2 = Players[CurTurnIdx]; if (pb2.m_type == Type.MAINCHARACTER) { CostManager.GetInst().AddCost(); } if (pb2.act == ACT.CASTING) { pb2.casting = true; } select_object = pb2; CameraManager.GetInst().ResetCameraTarget(); }
// Update is called once per frame void Update() { ef_time += Time.deltaTime; // if (PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx].act ==ACT.MAGIC) //{ MapManager.GetInst().ResetMapColor(); float distance = Vector3.Distance(transform.position, target); magic.GetInst().fired = true; CameraManager.GetInst().ResetCameraTarget(); if (distance > 1f) //이동중 { transform.position += (target - transform.position).normalized * 7 * Time.smoothDeltaTime; if (ef_time > 0.2) { EffectManager.GetInst().ShowEffect(this.transform, effect); ef_time = 0f; } target.y = 1; if (effect == 1) { transform.rotation = Quaternion.LookRotation((target - transform.position).normalized); Vector3 r = transform.rotation.eulerAngles; r.x -= 90; transform.rotation = Quaternion.Euler(r); } else { if (magic.GetInst().curmagic_id != 6) { transform.rotation = Quaternion.LookRotation((target - transform.position).normalized); Vector3 r = transform.rotation.eulerAngles; r.y -= 90; transform.rotation = Quaternion.Euler(r); } } } else //다음 목표 hex에 도착함 { transform.position = target; magic.GetInst().fired = false; MapManager.GetInst().MarkAttackRange(magic.GetInst().targetAI.CurHex, 2, false); PlayerManager pm = PlayerManager.GetInst(); if (effect == 1) { if (magic.GetInst().act != ACT.HIT) { EffectManager.GetInst().ShowEffect_Fire(targetHex.gameObject, this.gameObject); if (magic.GetInst().curmagic_id == 1) { magic.GetInst().targetAI.GetDamage(damage); } else { magic.GetInst().targetAI.GetDamage(100); } CostManager.GetInst().CostDecrease(CostManager.GetInst().Curcostnum); } else { Destroy(this.gameObject); } magic.GetInst().act = ACT.HIT; } else { for (int i = 0; i < pm.Players.Count; ++i) { if (pm.Players[i].CurHex.At_Marked == true) { if (pm.Players[i].m_type == Type.MONSTER) { pm.Players[i].GetDamage(damage); EffectManager.GetInst().ShowEffect_water(pm.Players[i].gameObject, this.gameObject, 4); } } } Destroy(this.gameObject); magic.GetInst().targetAI.GetDamage(damage); if (magic.GetInst().act != ACT.HIT) { EffectManager.GetInst().ShowEffect_water(targetHex.gameObject, this.gameObject, 4); CostManager.GetInst().CostDecrease(CostManager.GetInst().Curcostnum); } if (magic.GetInst().act != ACT.HIT) { magic.GetInst().act = ACT.HIT; } } //PlayerManager.GetInst().Players[PlayerManager.GetInst().CurTurnIdx].act = ACT.IDLE; MapManager.GetInst().ResetMapColor(); } // fire = false; // } }
public void MoveToNearUserPlayer(PlayerBase aiplayer) { PlayerManager pm = PlayerManager.GetInst(); MapManager mm = MapManager.GetInst(); PlayerBase nearUserPlayer = null; int nearDistance = 50; //근접 플레이어 서치 int i = Random.Range(1, 5); foreach (PlayerBase up in pm.Players) { if (up is UserPlayer) { int distance = mm.GetDistance(up.CurHex, aiplayer.CurHex); if (nearDistance > distance) { nearUserPlayer = up; nearDistance = distance; } } } if (aiplayer.m_type == Type.MONSTER || CostManager.GetInst().enemy_cost_num < 3) { if (nearUserPlayer != null) { List <Hex> path = mm.GetPath(aiplayer.CurHex, nearUserPlayer.CurHex); if (path == null) { PlayerManager.GetInst().TurnOver(); } else { if (path.Count > aiplayer.status.MoveRange) { path.RemoveRange(aiplayer.status.MoveRange, path.Count - aiplayer.status.MoveRange); } aiplayer.MoveHexes = path; if (nearUserPlayer.CurHex.MapPos == aiplayer.MoveHexes[aiplayer.MoveHexes.Count - 1].MapPos) { aiplayer.MoveHexes.RemoveAt(aiplayer.MoveHexes.Count - 1); } if (aiplayer.MoveHexes.Count == 0) { AtkAItoUser(aiplayer); return; } aiplayer.act = ACT.MOVING; } MapManager.GetInst().ResetMapColor(aiplayer.CurHex.MapPos); } } else if (CostManager.GetInst().enemy_cost_num >= 3 && CostManager.GetInst().enemy_cost_num < 5 && aiplayer.m_type == Type.BOSS) { List <Hex> path = mm.GetPath(aiplayer.CurHex, nearUserPlayer.CurHex); if (path == null) { PlayerManager.GetInst().TurnOver(); } Point v = aiplayer.CurHex.MapPos; int su_x = 0; int su_y = 0; for (int j = 0; j < MapManager.GetInst().MapSizeX; ++j) { for (int k = 0; k < MapManager.GetInst().MapSizeZ; ++k) { int x = Random.Range(-3, 3); int z = Random.Range(-3, 3); x = v.GetX() + x; z = v.GetZ() + z; if ((int)x > MapManager.GetInst().MapSizeX) { x = MapManager.GetInst().MapSizeX - 1; } if ((int)z > MapManager.GetInst().MapSizeZ) { z = MapManager.GetInst().MapSizeZ - 1; } if ((int)x <= 0) { x = 1; } if ((int)z <= 0) { z = 1; } if (MapManager.GetInst().Map[x][0][z].Passable == true) { su_x = x; su_y = z; break; } } } PlayerManager.GetInst().GenAIPlayer(su_x, su_y); EffectManager.GetInst().ShowEffect_Summon(aiplayer.CurHex.gameObject, 6, 0f); CostManager.GetInst().enemy_cost_num -= 3; //PlayerManager.GetInst().TurnOver(); } else if (CostManager.GetInst().enemy_cost_num < 8 && aiplayer.m_type == Type.BOSS) { aiplayer.act = ACT.CASTING; EffectManager.GetInst().ShowEffect_Summon(aiplayer.CurHex.gameObject, 9, 0.0f); CostManager.GetInst().enemy_cost_num -= 5; PlayerManager.GetInst().TurnOver(); } else { if (aiplayer.m_type == Type.BOSS) { List <Hex> path = mm.GetPath(aiplayer.CurHex, nearUserPlayer.CurHex); if (path == null) { PlayerManager.GetInst().TurnOver(); } Vector3 v = aiplayer.transform.position; if (path.Count < 5) { if (CostManager.GetInst().enemy_cost_num > 5) { aiplayer.act = ACT.CASTING; EffectManager.GetInst().ShowEffect_Summon(aiplayer.CurHex.gameObject, 9, 0.0f); CostManager.GetInst().enemy_cost_num -= 5; PlayerManager.GetInst().TurnOver(); } } else { if (nearUserPlayer != null) { if (path == null) { PlayerManager.GetInst().TurnOver(); } else { if (path.Count > aiplayer.status.MoveRange) { path.RemoveRange(aiplayer.status.MoveRange, path.Count - aiplayer.status.MoveRange); } aiplayer.MoveHexes = path; if (nearUserPlayer.CurHex.MapPos == aiplayer.MoveHexes[aiplayer.MoveHexes.Count - 1].MapPos) { aiplayer.MoveHexes.RemoveAt(aiplayer.MoveHexes.Count - 1); } if (aiplayer.MoveHexes.Count == 0) { AtkAItoUser(aiplayer); return; } aiplayer.act = ACT.MOVING; } MapManager.GetInst().ResetMapColor(aiplayer.CurHex.MapPos); } } Point p = aiplayer.CurHex.MapPos; int su_x = 0; int su_y = 0; for (i = 0; i < 2; ++i) { for (int j = 0; j < MapManager.GetInst().MapSizeX; ++j) { for (int k = 0; k < MapManager.GetInst().MapSizeZ; ++k) { int x = Random.Range(-3, 3); int z = Random.Range(-3, 3); x = p.GetX() + x; z = p.GetZ() + z; if ((int)x > MapManager.GetInst().MapSizeX) { x = MapManager.GetInst().MapSizeX - 1; } if ((int)z > MapManager.GetInst().MapSizeZ) { z = MapManager.GetInst().MapSizeZ - 1; } if ((int)x <= 0) { x = 1; } if ((int)z <= 0) { z = 1; } if (MapManager.GetInst().Map[x][0][z].Passable == true) { su_x = x; su_y = z; break; } } } PlayerManager.GetInst().GenAIPlayer(su_x, su_y); EffectManager.GetInst().ShowEffect_Summon(aiplayer.CurHex.gameObject, 6, 0f); CostManager.GetInst().enemy_cost_num -= 3; } } } }
void OnMouseDown() { if (act == "move") { PlayerBase pb = pm.Players[pm.CurTurnIdx]; Debug.Log(pb.m_type); if (pb.m_type == Type.USER || pb.m_type == Type.MAINCHARACTER && pb.act != ACT.STUN) { if (CostManager.GetInst().cur_cost_num >= 1) { //MapManager.GetInst().ResetMapColor(); if (pb.act != ACT.MOVING) { Manager.GetInst().MoveCamPosToTile(pb.CurHex); PlayerManager.GetInst().select_object = pb; pb.CurHex.Passable = true; SoundManager.GetInst().PlayClickSound(); if (pb.m_type != Type.MONSTER) { if (MapManager.GetInst().HilightMoveRange(pb.CurHex, pb.status.MoveRange)) { pm.Players[pm.CurTurnIdx].act = ACT.MOVEHILIGHT; } } } } } } if (act == "attack") { MapManager.GetInst().ResetMapColor(); SoundManager.GetInst().PlayClickSound(); Debug.Log("Attack"); PlayerBase pb = pm.Players[pm.CurTurnIdx]; if (pb.m_type == Type.USER || pb.m_type == Type.MAINCHARACTER && pb.act != ACT.STUN) { if (pb.act != ACT.MOVING) { Manager.GetInst().MoveCamPosToTile(pb.CurHex); pb.CurHex.Passable = true; if (pb.m_type != Type.MONSTER) { if (MapManager.GetInst().HilightAttackRange(pb.CurHex, pb.status.attackRange)) { pm.Players[pm.CurTurnIdx].act = ACT.ATTACKHIGHLIGHT; } } } } } if (act == "turnover") { PlayerBase pb = pm.Players[pm.CurTurnIdx]; if (pb.act != ACT.MOVING) { SoundManager.GetInst().PlayClickSound(); PlayerManager.GetInst().TurnOver(); } } if (act == "exit") { SoundManager.GetInst().PlayClickSound(); Debug.Log("Attack"); MapManager.GetInst().num = 0; SceneManager.LoadScene(1); } }
public void SetTarget(Hex v, Hex start, int y) { act = ACT.IDLE; if (type == "fire") { act = ACT.IDLE; if (curmagic_id == 1) { fireball[] fireb = new fireball[8]; for (int i = 0; i < 8; ++i) { fireb[i] = ((GameObject)Instantiate(magics[0])).GetComponent <fireball>(); fireb[i].targetHex = v; Vector3 v2 = v.transform.position; v2 = new Vector3(v2.x, 2, v2.z); Vector3 Start = start.transform.position; if (i == 2) { Start.z -= 6; } if (i == 3) { Start.z += 6; } if (i == 4) { Start.z += 3; } if (i == 5) { Start.z -= 3; } if (i == 6) { Start.x += 3; } if (i == 7) { Start.x += 3; } if (i == 1) { Start.x -= 6; } if (i == 0) { Start.x += 6; } Start.y = 10; fireb[i].target = v2; fireb[i].transform.position = Start; fireb[i].fire = true; } } else { fireball fireb = new fireball(); fireb = ((GameObject)Instantiate(magics[0])).GetComponent <fireball>(); fireb.targetHex = v; Vector3 v2 = v.transform.position; v2 = new Vector3(v2.x, 2, v2.z); Vector3 Start = start.transform.position; Start.y = 9; fireb.target = v2; fireb.transform.position = Start; fireb.fire = true; } } else if (type == "wall") { // wall wal = ((GameObject)Instantiate(magics[2])).GetComponent<wall>(); } else if (type == "wind") { EffectManager.GetInst().ShowEffect_Summon(v.gameObject, 10, 2); MapManager.GetInst().ResetMapColor(); MapManager.GetInst().MarkAttackRange(v, 3, false); v.At_Marked = true; CameraManager.GetInst().ResetCameraTarget(); CostManager.GetInst().CostDecrease(CostManager.GetInst().Curcostnum); } else if (type == "water") { if (curmagic_id == 2) { fireball[] fireb = new fireball[4]; for (int i = 0; i < 4; ++i) { fireb[i] = ((GameObject)Instantiate(magics[1])).GetComponent <fireball>(); fireb[i].targetHex = v; Vector3 v2 = v.transform.position; v2 = new Vector3(v2.x, 0, v2.z); Vector3 Start = start.transform.position; if (i == 2) { Start.z -= 8; } if (i == 3) { Start.z += 8; } if (i == 1) { Start.x -= 8; } if (i == 0) { Start.x += 8; } Start.y = y; fireb[i].target = v2; fireb[i].transform.position = Start; fireb[i].fire = true; } } else { fireball fireb = new fireball(); fireb = ((GameObject)Instantiate(magics[3])).GetComponent <fireball>(); fireb.targetHex = v; Vector3 v2 = v.transform.position; v2 = new Vector3(v2.x, 0, v2.z); Vector3 Start = start.transform.position; Start.y = 10f; fireb.target = v2; fireb.transform.position = Start; fireb.fire = true; } } }
void Update() { if (status.Curhp <= 0) { act = ACT.DIYING; } ShowCondition(); if (brokentime != 0) { brokentime += Time.deltaTime; if (brokentime > 1.5) { GameObject.Destroy(equip.gameObject); brokentime = 0f; } } PlayerManager pm = PlayerManager.GetInst(); if (removeTime != 0) { removeTime += Time.deltaTime; if (removeTime >= 1.5f) { for (int i = 0; i < pm.Players.Count; ++i) { if (pm.Players[i].act == ACT.DIYING) { if (pm.CurTurnIdx == i) { pm.RemoveAfter(); pm.RemovePlayer(pm.Players[i]); pm.RemoveAfter(); } else { pm.RemoveAfter(); pm.RemovePlayer(pm.Players[i]); pm.RemoveAfter(); } } } } } if (Equip == true) { Vector3 v2 = transform.position; if (equip_type == "helmet") { v2.y += 1.5f; } else { v2.y += 3.5f; } equip.transform.position = v2; } if (act == ACT.IDLE) { anim.SetBool("attack", false); anim.SetBool("run", false); // if (pm.Players[pm.CurTurnIdx] == this) // { // ///MapManager.GetInst().SetHexColor(CurHex, Color.black); // } //CurHex.Passable = true; } if (act == ACT.MOVING) {//이동처리 CameraManager.GetInst().ResetCameraTarget(); CurHex.Passable = true; Hex nextHex = MoveHexes[0]; if (MapManager.GetInst().MapSizeY > 0) { Point p = new Point(nextHex.MapPos.GetX(), nextHex.MapPos.GetY() + 1, nextHex.MapPos.GetZ()); if (MapManager.GetInst().Map[p.GetX()][p.GetY()][p.GetZ()].mesh_draw == true) { nextHex = MapManager.GetInst().Map[p.GetX()][p.GetY()][p.GetZ()]; jump = true; } else { jump = false; } } Vector3 v = nextHex.transform.position; v.y += 1.0f; float distance = Vector3.Distance(transform.position, v); if (distance >= 0.2f) //이동중 { anim.SetBool("run", true); transform.position += (v - transform.position).normalized * status.MoveSpeed * Time.smoothDeltaTime; if (jump == false) { Quaternion s = Quaternion.LookRotation((v - transform.position).normalized); Vector3 r = s.eulerAngles; r.y -= 90; if (Equip == true) { equip.transform.rotation = Quaternion.Euler(r); } transform.rotation = Quaternion.Euler(r); } } else //다음 목표 hex에 도착함 { anim.SetBool("run", false); Hex temp = nextHex; v = nextHex.transform.position; v.y += 1.0f; transform.position = v; MoveHexes.RemoveAt(0); if (MoveHexes.Count <= 0)//최종 dest { Manager.GetInst().MoveCamPos(nextHex); CameraManager.GetInst().InitPos.x = nextHex.x; CameraManager.GetInst().InitPos.z = nextHex.z; CostManager.GetInst().CostDecrease(1); Point temppos = new Point(nextHex.MapPos.GetX(), 0, nextHex.MapPos.GetZ()); CurHex = MapManager.GetInst().Map[temppos.GetX()][temppos.GetY()][temppos.GetZ()]; CurHex.Passable = false; act = ACT.IDLE; if (CurHex.obj_id == 5) { EquipHelmet(); } //PlayerManager.GetInst().TurnOver(); } } } }