public static bool IsExistCodeFront(Pos pos, char code) { int dis; EFaceDirection face; bool rs = MoveUtil.GetFaceDirection(out dis, out face, pos, MapCode.NPC_DARK_PRINCE, (int)(Camera.main.transform.eulerAngles.z / 90)); return(rs && dis == 1 && face == EFaceDirection.Forward); }
public static void ShowDangerTip(Pos pos) { // 如果孙女反叛就不显示危险提示 if (GameData._isGrandDaughterRebel || !Singleton._npcManager.Contains(ERole.GrandDaughter) || !GameData._isGrandDaughterInQueue) { return; } int dis; EFaceDirection face; bool rs = MoveUtil.GetFaceDirection(out dis, out face, pos, MapCode.NPC_DARK_PRINCE, (int)(Camera.main.transform.eulerAngles.z / 90)); if (rs) { string label = ""; switch (face) { case EFaceDirection.Forward: label = "前"; break; case EFaceDirection.Backward: label = "后"; break; case EFaceDirection.LeftForward: label = "左前"; break; case EFaceDirection.RightForward: label = "右前"; break; case EFaceDirection.LeftBackward: label = "左后"; break; case EFaceDirection.RightBackward: label = "右后"; break; case EFaceDirection.Left: label = "左"; break; case EFaceDirection.Right: label = "右"; break; } label += "方"; label += (dis == 1 ? "一" : "两") + "米"; UIManager._Instance.SetTipInfo(string.Format(TipMessage._dirTip, label)); } }
protected override void Move(int x, int y) // 3 Enemy, 2 Pit, 1 Wall, 0 Road, { int originX = _x; int originY = _y; int newX = _x + (int)x; int newY = _y + (int)y; int curIndex = MapManager.CurIndex(newX, newY); // Debug.LogError("Move curIndex: " + curIndex); if (curIndex >= 0) { // Debug.Log("curIndex: " + curIndex + ", curMap: " + MapManager._curMap[curIndex]); if (MapManager._curMap[curIndex] == MapCode.NONE || MapManager._curMap[curIndex] == MapCode.BEFORE_UPSTAIR || MapManager._curMap[curIndex] == MapCode.BEFORE_DOWNSTAIR) { //如果人物移动,那么播放音效 Singleton._audioManager.Walk(); // int index = MapManager.CurIndex(_x, _y); _x = newX; _y = newY; ChangeStep(GameData._Step + 1); CalculateDirection(); if (PlotManager.status == EPlotStatus.Battle && !GameData._isGrandDaughterInQueue && !GameData._isGrandDaughterRebel) { MoveUtil.ShowDangerTip(new Pos(newX, newY)); } int enemyX; int enemyY; // 检测周围的八个点 if (MapManager.IsExistCodeInRange(newX, newY, out enemyX, out enemyY, MapCode.NPC_GRAND_DAUGHTER) || MapManager.IsExistCodeInRange(newX, newY, out enemyX, out enemyY, MapCode.NPC_DARK_PRINCE)) { int idx = MapManager.CurIndex(enemyX, enemyY); if ( // GameData._curMeetHint <= 0 && MapManager._curMap[idx] == MapCode.NPC_GRAND_DAUGHTER) { if (PlotManager.status == EPlotStatus.Start) { GameObject go = MapManager.GetObj(idx); NPC npc = null; if (go != null) { npc = go.GetComponent <NPC>(); } if (npc != null && npc._roleIdent == ERole.GrandDaughter) { if (GameData._curMeetHint == 0) { UIManager._Instance.SetSysMsgInfo(SystemMessage._meetHint_Find); } else { UIManager._Instance.SetSysMsgInfo(SystemMessage._meet_Find); } GameData._curMeetHint = 1; // start plot isLockMove = true; PlotManager.instance.Meet(npc._roleIdent, () => { isLockMove = false; }); } } else if (PlotManager.status == EPlotStatus.Battle) { GameObject go = MapManager.GetObj(idx); NPC npc = null; if (go != null) { npc = go.GetComponent <NPC>(); } // 如果是孙女 if (npc != null && npc._roleIdent == ERole.GrandDaughter) { int dis; EFaceDirection face; bool rs = MoveUtil.GetFaceDirection(out dis, out face, GetPos(), MapCode.NPC_GRAND_DAUGHTER, (int)(Camera.main.transform.eulerAngles.z / 90)); if (rs && (int)face <= (int)EFaceDirection.Right) { string label = ""; switch (face) { case EFaceDirection.Forward: label = "前"; break; case EFaceDirection.Backward: label = "后"; break; case EFaceDirection.Left: label = "左"; break; case EFaceDirection.Right: label = "右"; break; } UIManager._Instance.SetTipInfo(string.Format(TipMessage._grandDaughterNear, label)); } } } } else if (MapManager._curMap[idx] == MapCode.NPC_DARK_PRINCE) { // 开始剧情 // 孙女加入与否都可以见到黑王子 if (PlotManager.status == EPlotStatus.Battle_Before) { GameObject go = MapManager.GetObj(idx); NPC npc = null; if (go != null) { npc = go.GetComponent <NPC>(); } if (npc != null && npc._roleIdent == ERole.DarkPrince) { isLockMove = true; npc.GetComponent <DarkPrince>()._startMove = true; PlotManager.instance.Battle(() => { isLockMove = false; }); } } } } } else { // 下面都是未移动 if (MapManager._curMap[curIndex] == MapCode.ENEMY) { Singleton._audioManager.Attack(); // do hurt GameObject go = MapManager.GetObj(curIndex); if (go != null) { Enemy enemy = go.GetComponent <Enemy>(); int count = 1; enemy.Hurt(count); // TODO 要设置敌人的攻击力,玩家的防御力 UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._attack, "敌人", count)); } } else if (MapManager._curMap[curIndex] == MapCode.PIT) { Singleton._audioManager.Attack(); int count = 1; if (onMinusHP != null) { onMinusHP(count); } UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._hurt, count)); } // 如果将要移动的地方已经有孙女在那个位置,那么对那个位置的目标造成伤害 else if (MapManager._curMap[curIndex] == MapCode.NPC_GRAND_DAUGHTER) { Singleton._audioManager.Attack(); GameObject go = MapManager.GetObj(curIndex); if (go != null) { GrandDaughter grandDaughter = go.GetComponent <GrandDaughter>(); int count = 1; grandDaughter.Hurt(count); // TODO 要设置敌人的攻击力,玩家的防御力 UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._attack, GameData._Instance._roleLib.GetRole(ERole.GrandDaughter)._name, count)); } } else if (MapManager._curMap[curIndex] == MapCode.NPC_DARK_PRINCE) { // 由于这个时候,孙女离开队伍,爷爷一个人会迷失方向,只能攻击前面的对象 if (MoveUtil.IsExistCodeFront(new Pos(originX, originY), MapCode.NPC_DARK_PRINCE)) { Singleton._audioManager.Attack(); // do hurt GameObject tempObj = MapManager.GetObj(curIndex); if (tempObj != null) { DarkPrince price = tempObj.GetComponent <DarkPrince>(); int count = 1; price.Hurt(count); // TODO 要设置敌人的攻击力,玩家的防御力 UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._attack, GameData._Instance._roleLib.GetRole(ERole.DarkPrince)._name, count)); } } else { Singleton._audioManager.CannotMove(); CalculateDirection(false); } } else // 不是可移动区域并且没有进行攻击 { Singleton._audioManager.CannotMove(); CalculateDirection(false); // 切换下一关不要显示tip } } } // 如果将要移动的区域超出边界,那么判定在边缘,可以切换地图, // 这样不好,如果传送门在地图中间或者边缘为空并不是地图,那么就会出BUG else { if (GameData._isLockDoor) { Singleton._audioManager.CannotMove(); UIManager._Instance.SetTipInfo(Tip._lockDoor); return; } CalculateDirection(); // 为什么这里要Calc?当无法切换关卡时的处理,不应该这样 // Debug.LogError("curLevel: " + GameData._CurLevel + ", code: " + MapManager._curMap[MapManager.CurIndex(_x, _y)]); Singleton._levelManager.NextLevel(GameData._CurLevel + (MapManager._curMap[MapManager.CurIndex(_x, _y)] == '9' ? 1 : -1)); } }