public static void finishCast(bool result) { if (result) { log("You cast " + GAME.curCast.name); if (GAME.curCast is CreatureCard) { GAME.addToHistory(GAME.curCast, CARD_OWN.FRIENDLY); } else { GAME.addToHistory(GAME.curCast, CARD_OWN.NEUTRAL); } GAME.activePlayer.cast(GAME.curCast); NetworkEngine.send(GAME.curCast.getCastNetworkMessage()); GAME.curCast.endCast(); } else { GAME.curCast.cancelCast(); } GAME.cardHandler.endCast(result); GAME.currentRequest = TARGET_TYPE.NONE; GAME.currentValidator = null; GAME.curCast = null; GAME.cardHandler = null; GAME.uiManager.zeroFields(); }
// Update is called once per frame void Update() { lock (dcFlagLock) { if (dcFlag) { dcFlag = false; if (GameEngine.listener != null && GameEngine.listener.IsAlive) { GameEngine.listener.Abort(); } lock (GameEngine.clientLock) { if (GameEngine.client != null) { GameEngine.client.Close(); } } endGameManager.message = "[ERROR] Server has closed connection."; SceneManager.LoadScene("endGameScene"); } } if (Input.GetKeyDown(KeyCode.Return)) { if (writing) { string message = inputField.text; if (message != "") { NetworkEngine.send("msg#" + message); log("You say: " + message); inputField.text = ""; writing = false; } } else { inputField.ActivateInputField(); writing = true; } } }
public void endTurnClick() { if (activePlayer == localPlayer) { if (curCast != null) { finishCast(false); } if (selectedField != null) { selectedField = null; selectedCreature = null; switched = false; } uiManager.zeroFields(); gmsg(""); switched = false; NetworkEngine.send("endTurn"); log("Your turn has ended"); } }
public static void fieldClick(Field f) { gmsg(""); if (GAME.activePlayer == GAME.localPlayer) { if (GAME.curCast != null) { if (GAME.currentRequest == TARGET_TYPE.FIELD) { if (!f.invalidTarget && GAME.currentValidator.validate(f)) { if (GAME.curCast.continueCast(f) == CAST_EFFECT.SUCCESS) { finishCast(true); } } else { GAME.curCast.cancelCast(); finishCast(false); } } else if (GAME.currentRequest == TARGET_TYPE.SET_OF_FIELDS) { if (!f.invalidTarget && GAME.currentValidator.validate(f)) { if (GAME.curCast.continueCast(f) == CAST_EFFECT.SUCCESS) { finishCast(true); } } else { GAME.curCast.cancelCast(); finishCast(false); } } } else { if (GAME.selectedField == null) { if (f.content != null && f.content is Creature && ((Creature)f.content).owner == GAME.localPlayer) { GAME.selectedCreature = (Creature)f.content; GAME.selectedField = f; generateMovePaths(f); updateRange(); gmsg("Select target to attack, or field to move"); } } else { if (switched) { if (GAME.selectedCreature.canSpecial()) { if (GAME.selectedCreature.parentCard.specialValidator.validate(f) && validateSpecialPath(GAME.selectedField, f)) { GAME.selectedCreature.special(f); NetworkEngine.send("rclick#" + GAME.selectedField.x + "#" + GAME.selectedField.y + "#" + f.x + "#" + f.y); } } GAME.selectedField = null; GAME.selectedCreature = null; GAME.uiManager.zeroFields(); switched = false; } else if (f.content != null) { if (GAME.selectedCreature.canAttack()) { if (f.content.owner != GAME.localPlayer && validateAttackPath(GAME.selectedField, f)) { GAME.selectedCreature.attack(f.content); NetworkEngine.send("lclick#" + GAME.selectedField.x + "#" + GAME.selectedField.y + "#" + f.x + "#" + f.y); } } GAME.selectedField = null; GAME.selectedCreature = null; GAME.uiManager.zeroFields(); } else { if (GAME.selectedCreature.canMove()) { if (GAME.selectedCreature.stats.speed >= GAME.moveDistances[f]) { log("moving"); List <Field> path = new List <Field>(); Field parent = f; while (parent != GAME.selectedField) { path.Add(parent); parent = GAME.movePaths[parent]; } List <Field> invokedPath = new List <Field>(); for (int i = path.Count - 1; i >= 0; i--) { bool interrupt = path[i].onMoveThrough(GAME.selectedCreature); invokedPath.Add(path[i]); if (interrupt) { log("interrupt at field " + path[i].x + " " + path[i].y); f = path[i]; break; } } GAME.StartCoroutine(GAME.selectedCreature.MovementAnimation(invokedPath, GAME.selectedField.contentObject)); GAME.selectedCreature.move(f); NetworkEngine.send("lclick#" + GAME.selectedField.x + "#" + GAME.selectedField.y + "#" + f.x + "#" + f.y); } } GAME.selectedField = null; GAME.selectedCreature = null; GAME.uiManager.zeroFields(); } } } } updateColors(); }