public static void Skill_Qiangbing03(Wujiang wujiang, Coordinates target) { Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); Wujiang targetWujiang = wujiangExpeditions[target]; // 1.伤害 targetWujiang.OnDamage(5000); // 2.移动 Coordinates c1 = wujiang.GetCoordinates(); Coordinates c2 = targetWujiang.GetCoordinates(); int dx = (c2.HexX - c1.HexX) * 2; int dy = (c2.HexY - c1.HexY) * 2; Coordinates myCoordinates = new Coordinates(); Coordinates otherCoordinates = new Coordinates(); myCoordinates.SetHexXY(c1.HexX + dx, c1.HexY + dy); otherCoordinates.SetHexXY(c2.HexX + dx, c2.HexY + dy); if (!Skills.CanMoveIn(myCoordinates)) { return; } else if (!Skills.CanMoveIn(otherCoordinates)) { targetWujiang.Move(myCoordinates); } else { targetWujiang.Move(otherCoordinates); } }
void Start() { mCoordinates = MapManager.GetInstance().TerrainPositionToCorrdinate(transform.position); BattleGameManager.GetInstance().GetWujiangData().SetWujiangExpeditionCorrdinates(mCoordinates, this); mHealthValue = int.Parse(mHealth.text); }
// 2-贯射 public static List <Coordinates> ShowSkillTarget_Nubing02(Wujiang myWujiang) { List <Coordinates> targets = new List <Coordinates>(); Coordinates c1 = MapManager.GetInstance().TerrainPositionToCorrdinate(BattleGameManager.GetInstance().GetWujiangTransparent().transform.position); List <Coordinates> neighbours = new List <Coordinates>(); MapManager.GetInstance().GetAroundN(neighbours, c1, 2); Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); foreach (Coordinates c in neighbours) { if (wujiangExpeditions.ContainsKey(c)) { // 不能是自己 if (!myWujiang.GetCoordinates().Equals(c)) { // 必须是一条直线上 if (MapManager.GetInstance().CheckInLine(c, c1)) { targets.Add(c); } } } } return(targets); }
public bool ShowBattleMeun(Vector3 position) { Coordinates coordinates = MapManager.GetInstance().TerrainPositionToCorrdinate(position); foreach (KeyValuePair <Coordinates, Node> node in mPathfindingResult) { if (node.Value.nodeCurrentCosted <= mWujiangPathfindingCost) { if (coordinates.Equals(node.Key)) { // 如果移动的目标点为都市、关口、港口,那么让武将进城 City city = BattleGameManager.GetInstance().GetCityData().GetCity(coordinates); // 不能回当前的城池 if (GetWujiangState() == WujiangState.WujiangState_Prepare_Expedition) { if (city == mCity) { return(true); } } // 透明武将 GameObject wujiangTransparent = BattleGameManager.GetInstance().GetWujiangTransparent(); wujiangTransparent.SetActive(true); wujiangTransparent.transform.position = MapManager.GetInstance().CorrdinateToTerrainPosition(coordinates); // 显示战斗菜单 BattleGameManager.GetInstance().GetCanvasBattleMenu().SetWujiang(this); BattleGameManager.GetInstance().GetCanvasBattleMenu().ShowMenu(Input.mousePosition); } } } return(false); }
// 骑兵:2 public static void Skill_Qibing02(Wujiang wujiang, Coordinates target) { Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); Wujiang targetWujiang = wujiangExpeditions[target]; // 1.伤害 targetWujiang.OnDamage(3000); // 2.移动 Coordinates c1 = wujiang.GetCoordinates(); Coordinates c2 = targetWujiang.GetCoordinates(); int dx = (c2.HexX - c1.HexX); int dy = (c2.HexY - c1.HexY); Coordinates myCoordinates = new Coordinates(); myCoordinates.SetHexXY(c2.HexX + dx, c2.HexY + dy); if (!Skills.CanMoveIn(myCoordinates)) { if (targetWujiang.GetWujiangState() == WujiangState.WujiangState_Dead) { wujiang.Move(c2); return; } return; } wujiang.Move(myCoordinates); }
public void Move(Vector3 position, StartSkillDelegate StartSkillDelegate = null, Coordinates attackCoordinates = null) { Coordinates coordinates = MapManager.GetInstance().TerrainPositionToCorrdinate(position); Node node = mPathfindingResult[coordinates]; City city = BattleGameManager.GetInstance().GetCityData().GetCity(coordinates); // 计算路径 List <Vector3> waypoints = new List <Vector3>(); while (node != null) { waypoints.Insert(0, MapManager.GetInstance().CorrdinateToTerrainPosition(node.nodeCoordinates)); node = node.nodeParent; } // 播放动画 if (waypoints.Count < 2) { // 如果小于2个点,那么直接隐藏路径即可 HidePath(); // 如果有技能的话,放技能 if (StartSkillDelegate != null) { StartSkillDelegate(attackCoordinates); } } else { BattleGameManager.msIgnoreRaycast = true; Tween t = transform.DOPath(waypoints.ToArray(), 0.1f * (waypoints.Count - 1), PathType.CatmullRom).SetEase(Ease.Linear); t.onComplete = delegate() { BattleGameManager.msIgnoreRaycast = false; if (city) { // 1.回到城市 foreach (WujiangBean wujiangBean in mWujiangBeans) { if (wujiangBean != null) { city.GetWujiangBeans().Add(wujiangBean); } } Destroy(gameObject); } else { // 2.正常移动 transform.position = MapManager.GetInstance().CorrdinateToTerrainPosition(coordinates); BattleGameManager.GetInstance().GetWujiangData().UpdateWujiangExpeditionCorrdinates(mCoordinates, coordinates); mCoordinates = coordinates; } SetWujiangState(WujiangState.WujiangState_Battle); HidePath(); // 如果有技能的话,放技能 if (StartSkillDelegate != null) { StartSkillDelegate(attackCoordinates); } }; } }
public Dictionary <Coordinates, Node> ShowPath(Wujiang wujiang) { // 所有出征的武将 Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); ClearNode(); // 1.查找可走路径点 Coordinates current = MapManager.GetInstance().TerrainPositionToCorrdinate(wujiang.transform.position); Queue <Node> queue = new Queue <Node>(); Node startNode = GetNode(current); startNode.nodeCurrentCosted = 1; queue.Enqueue(startNode); mResult[startNode.nodeCoordinates] = startNode; while (queue.Count > 0) { Node currentNode = queue.Dequeue(); List <Coordinates> neighbours = MapManager.GetInstance().GetNeighbours(currentNode.nodeCoordinates); foreach (Coordinates c in neighbours) { // 检查是否越界 if (MapManager.GetInstance().CheckBoundary(c)) { Node node = GetNode(c); // 创建node float newCost = currentNode.nodeCurrentCosted + node.nodeCost; if (newCost < node.nodeCurrentCosted) { node.nodeCurrentCosted = newCost; // 1.当前点的cost小于总cost if (node.nodeCurrentCosted <= wujiang.GetWujiangPathfindingCost()) { // 2.不能移动到其他武将的点上,所以去掉这个点 if (wujiangExpeditions.ContainsKey(node.nodeCoordinates)) { Wujiang wujiangNode = wujiangExpeditions[node.nodeCoordinates]; if (wujiangNode && wujiangNode != wujiang) { continue; } } queue.Enqueue(node); node.nodeParent = currentNode; mResult[node.nodeCoordinates] = node; } } } } } // 2.显示可走路径点 mIsShowingPath = true; foreach (KeyValuePair <Coordinates, Node> node in mResult) { GameObject g = GetGridNode(); g.SetActive(true); g.transform.position = MapManager.GetInstance().CorrdinateToTerrainPosition(node.Key); } return(mResult); }
public static void Skill_Nubing01(Wujiang wujiang, Coordinates target) { Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); Wujiang targetWujiang = wujiangExpeditions[target]; // 1.伤害 targetWujiang.OnDamage(3000); }
// 移动和放技能 public void MoveAndStartSkill(Coordinates attackCoordinates) { // 1.先移动,再放技能 // 注意这里有两个坐标概念: // 1.要移动到的位置 // 2.点击攻击的目标coordinates mWujiang.Move(BattleGameManager.GetInstance().GetWujiangTransparent().transform.position, StartSkill, attackCoordinates); BattleGameManager.GetInstance().GetWujiangTransparent().SetActive(false); }
private void Awake() { gameEvents = BattleGameObjects.instance.gameEvents; if (instance == null) { instance = this; } else { Destroy(this); } }
public static void Skill_Jibing03(Wujiang wujiang, Coordinates target) { Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); List <Coordinates> neighbors = MapManager.GetInstance().GetNeighbours(wujiang.GetCoordinates()); foreach (Coordinates c in neighbors) { if (wujiangExpeditions.ContainsKey(c)) { wujiangExpeditions[c].OnDamage(5000); } } }
public static void Skill_Nubing02(Wujiang myWujiang, Coordinates target) { Coordinates c1 = myWujiang.GetCoordinates(); Coordinates c2 = target; List <Coordinates> targets = new List <Coordinates>(); if (c1.HexX == c2.HexX) { int count = c2.HexY - c1.HexY; int step = count > 0 ? 1 : -1; for (int i = c2.HexY; i != c1.HexY; i -= step) { Coordinates c = new Coordinates(); c.SetHexXY(c1.HexX, i); targets.Add(c); } } else if (c1.HexY == c2.HexY) { int count = c2.HexX - c1.HexX; int step = count > 0 ? 1 : -1; for (int i = c2.HexX; i != c1.HexX; i -= step) { Coordinates c = new Coordinates(); c.SetHexXY(i, c1.HexY); targets.Add(c); } } else if (c1.HexZ == c2.HexZ) { int count = c2.HexY - c1.HexY; int step = count > 0 ? 1 : -1; for (int i = c2.HexY; i != c1.HexY; i -= step) { Coordinates c = new Coordinates(); c.SetHexXY(-c1.HexZ - i, i); targets.Add(c); } } Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); foreach (Coordinates c in targets) { if (wujiangExpeditions.ContainsKey(c)) { wujiangExpeditions[c].OnDamage(4000); } } }
public void Move(Coordinates targetCoordinates) { List <Vector3> waypoints = new List <Vector3>(); waypoints.Add(transform.position); Vector3 targetPosition = MapManager.GetInstance().CorrdinateToTerrainPosition(targetCoordinates); waypoints.Add(targetPosition); Tween t = transform.DOPath(waypoints.ToArray(), 0.02f * (waypoints.Count - 1), PathType.CatmullRom).SetEase(Ease.Linear); t.onComplete = delegate() { // 正常移动 transform.position = targetPosition; BattleGameManager.GetInstance().GetWujiangData().UpdateWujiangExpeditionCorrdinates(mCoordinates, targetCoordinates); mCoordinates = targetCoordinates; }; }
public static List <Coordinates> ShowSkillTarget_Qibing01(Wujiang wujiang) { List <Coordinates> targets = new List <Coordinates>(); List <Coordinates> neighbour = MapManager.GetInstance().GetNeighbours(MapManager.GetInstance().TerrainPositionToCorrdinate(BattleGameManager.GetInstance().GetWujiangTransparent().transform.position)); Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions(); foreach (Coordinates c in neighbour) { if (wujiangExpeditions.ContainsKey(c)) { // 不能是自己 if (!wujiang.GetCoordinates().Equals(c)) { targets.Add(c); } } } return(targets); }
/// <summary> /// Try use card. If card need target and there is no available target, return false /// 尝试使用卡牌,如果卡牌需要指定目标,但没有合适目标,则使用失败,返回false /// </summary> /// <returns></returns> private bool TryUseCard(CardBase card) { TargetInfo ti = card.CardInfo.TargetInfo; HashSet <Type> sefs = GetSideEffectFunctionsByCardInfo(card.CardInfo); if (card.CardInfo.BaseInfo.CardType == CardTypes.Spell || card.CardInfo.BaseInfo.CardType == CardTypes.Energy) { if (!ti.HasTarget) { BattleGameManager.OnClientUseSpellCardRequest(new UseSpellCardRequest(ClientID, card.M_CardInstanceId)); return(true); } else { if (ti.HasTargetShip) { switch (ti.targetShipRange) { case TargetRange.Ships: { if (card.CardInfo.GetCardUseBias() < 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); } else if (card.CardInfo.GetCardUseBias() > 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); } else { Random rd = new Random(); int ran = rd.Next(0, 2); if (ran == 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); } else { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); } } return(true); } case TargetRange.SelfShip: { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); return(true); } case TargetRange.EnemyShip: { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); return(true); } case TargetRange.AllLife: { if (card.CardInfo.GetCardUseBias() < 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); } else if (card.CardInfo.GetCardUseBias() > 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); } else { Random rd = new Random(); int ran = rd.Next(0, 2); if (ran == 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); } else { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); } } return(true); } case TargetRange.SelfLife: { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); return(true); } case TargetRange.EnemyLife: { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); return(true); } case TargetRange.Decks: { if (card.CardInfo.GetCardUseBias() < 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); } else if (card.CardInfo.GetCardUseBias() > 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); } else { Random rd = new Random(); int ran = rd.Next(0, 2); if (ran == 0) { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); } else { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); } } return(true); } case TargetRange.SelfDeck: { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { ClientID })); return(true); } case TargetRange.EnemyDeck: { BattleGameManager.OnClientUseSpellCardToShipRequest(new UseSpellCardToShipRequest(ClientID, card.M_CardInstanceId, new List <int> { BattleGameManager.PlayerA.ClientId })); return(true); } } } if (ti.HasTargetMech) { ModuleMech mech = GetTargetMechByTargetInfo(sefs, ti); if (mech != null) { DebugLog.PrintError("SpelltoMech: " + card.CardInfo.BaseInfo.CardNames["zh"] + " " + mech.CardInfo.BaseInfo.CardNames["zh"]); BattleGameManager.OnClientUseSpellCardToMechRequest(new UseSpellCardToMechRequest(ClientID, card.M_CardInstanceId, new List <(int, bool)> { (mech.M_MechID, false) }));
void OnDestroy() { BattleGameManager.GetInstance().GetWujiangData().SetWujiangExpeditionCorrdinates(mCoordinates, null); }
void Start() { mTargetPrefab = Resources.Load(WUJIANG_TARGET) as GameObject; mTargetParent = new GameObject("TargetParent"); mTargetParent.transform.position = new Vector3(0, 0, 0); // 第一级菜单监听,显示第二级菜单位置 for (int i = 0; i < mMenuFirstBtns.Length; i++) { int index = i; mMenuFirstBtns[index].GetComponent <Button>().onClick.AddListener(delegate() { if (index == 0) { // 隐藏整个菜单(一级菜单) gameObject.SetActive(false); // 待机(目前为移动) mWujiang.Move(BattleGameManager.GetInstance().GetWujiangTransparent().transform.position); mWujiang.Seclet(false); BattleGameManager.GetInstance().GetWujiangTransparent().SetActive(false); } else if (index == 3) { // 显示技能菜单(二级菜单) Vector3 scale = mMenuFirstBtns[index].transform.lossyScale; Vector2 sizeDelta = mMenuFirstBtns[index].GetComponent <RectTransform>().sizeDelta; mSecondMenu.transform.position = mMenuFirstBtns[index].transform.position + new Vector3(sizeDelta.x * scale.x / 2, sizeDelta.y * scale.y / 2, 0); // 根据武将适性显示技能个数 for (int j = 0; j < mMenuSecondBtns.Length; j++) { if (j < mWujiang.mSkills.mSkillNames.Count) { mMenuSecondBtns[j].SetActive(true); mMenuSecondBtns[j].GetComponentInChildren <Text>().text = mWujiang.mSkills.mSkillNames[j]; // 根据是否可以释放技能来决定是否只用按钮 if (mWujiang.mSkills.mAllTargets[j].Count > 0) { EnabelBtn(mMenuSecondBtns[j]); } else { DisabelBtn(mMenuSecondBtns[j]); } } else { mMenuSecondBtns[j].SetActive(false); } } } else { // 隐藏二级菜单 mSecondMenu.GetComponent <RectTransform>().anchoredPosition = new Vector2(1000, 1000); } }); } // 第二级菜单监听 for (int i = 0; i < mMenuSecondBtns.Length; i++) { int index = i; mMenuSecondBtns[i].GetComponent <Button>().onClick.AddListener(delegate() { // 显示技能能攻击的目标集合 mSkillIndex = index; mTargets = mWujiang.mSkills.mAllTargets[index]; mWujiang.SetWujiangState(WujiangState.WujiangState_Prepare_Attack); ShowSkillTarget(mTargets); gameObject.SetActive(false); }); } mSecondMenu.GetComponent <RectTransform>().anchoredPosition = new Vector2(1000, 1000); }
// Start is called before the first frame update void Start() { battleManager = FindObjectOfType <BattleGameManager>(); startUI.SetActive(true); }
private void Awake() { msBattleGameManager = this; }
public void AIOperation() { while (true) { bool lastOperation = false; bool failedAgain = false; while (true) { // Try preset combo first CardCombo cc = FindCardComboInHand(); if (cc != null) { foreach (int cardID in cc.ComboCardIDList) { CardBase cb = MyPlayer.HandManager.SelectHandCardByCardID(cardID); if (cb != null) { TryUseCard(cb); } } } // Try cards by card priority CardBase card = FindCardUsable(); ModuleMech mech = FindMechMovable(); if (card == null && mech == null) { if (!lastOperation) { failedAgain = true; //try twice and both failed, then stop } break; } else { if (card != null) { if (TryUseCard(card)) //succeed { lastOperation = true; } else { TriedCards.Add(card.M_CardInstanceId); //don't try the cards already tried } } if (mech != null) { if (TryAttack(mech)) //succeed { lastOperation = true; } else { TriedMechs.Add(mech.M_MechID); //don't try the mechs already tried } } } } TriedCards.Clear(); TriedMechs.Clear(); if (failedAgain) { break; } } BattleGameManager.OnEndRoundRequest(new EndRoundRequest(ClientID)); }