public void ShowPath(Pointer.PointerEventArgs e) { if (!Map.Instance.IsShowingRange()) { return; } foreach (var tile in tilesForMovement) { tile.GetComponent <SpriteRenderer>().color = Color.blue; } var tileFinal = lastDijkstraSearch.FirstOrDefault(d => d.t.Coordinate == e.Coordinate); if (tileFinal == null) { return; } foreach (var tilePath in tileFinal.Path) { var tile = tilesForMovement.FirstOrDefault(t => t.transform.position == new Vector3(tilePath.Coordinate.x, tilePath.Coordinate.y)); if (tile != null) { tile.GetComponent <SpriteRenderer>().color = Color.green; } } var tileDestino = tilesForMovement.FirstOrDefault(t => t.transform.position == new Vector3(e.Coordinate.x, e.Coordinate.y)); if (tileDestino != null) { tileDestino.GetComponent <SpriteRenderer>().color = Color.green; } return; }
private static void UpdateTileStatus(Pointer.PointerEventArgs e) { var t = Map.Instance.GetTile(e.Coordinate); AvoidText.text = t.AvoidValue.ToString(); DefenseText.text = t.Defense.ToString(); if (t.Type == TileType.Cliff || t.Type == TileType.Castle) { AvoidText.text = "-"; DefenseText.text = "-"; } TitleText.text = t.Name; switch (t.Type) { case TileType.Castle: case TileType.Cliff: TitleBackground.color = new Color32(200, 200, 200, 190); break; case TileType.Forest: TitleBackground.color = new Color32(0, 135, 15, 190); break; case TileType.Gate: case TileType.Home: TitleBackground.color = new Color32(255, 185, 15, 190); break; case TileType.Mountain: case TileType.Peak: TitleBackground.color = new Color32(245, 165, 96, 190); break; case TileType.Plain: TitleBackground.color = new Color32(160, 230, 120, 190); break; default: break; } UpdateCharacterStatus(t.Coordinate); }
/// <summary> /// Does the "Action" button action send from the pointer. /// </summary> private void OnActionPointer(Pointer.PointerEventArgs e) { if (!IsPlayerTurn) { return; } var c = Map.GetCharacterFromTile(e.Coordinate); if (c == null) { switch (Action) { case Action.Move: if (MoveCharacter(e.Coordinate)) { print("eligio una celda vacia para moverse."); Pointer.EnableActions = false; } else { print("eligio una celda fuera de rango de movimiento."); return; } break; case Action.Attack: //isAttacking) if (AttackCharacter(c)) { Pointer.EnableActions = false; } else { print("clickeo una celda vacia al estar atacando"); } break; case Action.Skill: if (UseSkillCharacter(c)) { Pointer.EnableActions = false; } else { print("clickeo una celda vacia al estar usando un skill"); } break; default: print("clickeo una celda vacia, sin haber seleccionado un personaje antes"); break; } } if (c != null) //TODO: despues de checkear todas las instancias cambiar el if a else, xq es mas performante. { if (c.Team != PlayerFaction) { if (Action != Action.Attack && Action != Action.Skill)//!isAttacking && !isUsingSkill) { print("clickeo un personaje enemigo por primera vez, no para atacar."); } else if (Action == Action.Attack) //isAttacking) //depurar si no hay mas condiciones a solo else. { print("clickeo a un personaje enemigo, cuando estaba atacando"); if (AttackCharacter(c)) { Pointer.EnableActions = false; } } else if (Action == Action.Skill) { print("clickeo a un personaje enemigo, cuando estaba usando un skill"); if (UseSkillCharacter(c)) { Pointer.EnableActions = false; } } } else { if (Action == Action.None)//!isAttacking && !isMoving) //Eligio un personaje para actuar por primera vez. { print("clickeo a un personaje propio, para inciar su accion"); if (c.HasMoved || c.HasFinished) { //Character already moved (should never enter here) (for example clicking an already moved character) or finished his turn. Debug.Log(c.HasMoved); Debug.Log(c.HasFinished); return; //OpenOptionsMenu. } Map.ShowRange(c); SelectedCharacter = c; Action = Action.Move; //isMoving = true; } else if (Action == Action.Move && c != SelectedCharacter) // isMoving { print("clickeo a un personaje propio, cuando se estaba moviendo"); //Ultimo cambio deberia ser imposible q pase. } else if (Action == Action.Move && c == SelectedCharacter) //isMoving { if (MoveCharacter(e.Coordinate)) { print("eligio al mismo personaje, para no moverse y abrir el menu."); Pointer.EnableActions = false; } else { //print("eligio una celda fuera de rango de movimiento."); return; } } else if (Action == Action.Attack)//isAttacking) { print("clickeo a un personaje aliado, cuando estaba atacando"); if (AttackCharacter(c)) { Pointer.EnableActions = false; } } else if (Action == Action.Skill)//isAttacking) { print("clickeo a un personaje aliado, cuando estaba usando una skill"); if (UseSkillCharacter(c)) { Pointer.EnableActions = false; } } } } //TODO: Ver el caso se clickear un personaje aliado luego de otro }