private static void Move(GameObject target, Location from, Location to, bool upload = true) { /// Set Location Data if (upload) { new GameEvent(from, to, Login.playerID).Upload(); } OnEnterGame.gameInfo.Move(from, to); target.GetComponent <PieceInfo>().piece.location = to; target.transform.parent = boardCanvas.Find(to.ToString()); target.transform.localPosition = Vector3.Lerp(target.transform.localPosition, new Vector3(0, 0, target.transform.position.z), speed); GameObject fromObject = boardSetup.pieces[from]; boardSetup.pieces.Remove(from); boardSetup.pieces.Add(to, fromObject); if (OnEnterGame.gameInfo.traps.ContainsKey(to)) { onEnterGame.TriggerTrap(to); } // need to add game events Trigger trigger = target.GetComponent <PieceInfo>().trigger; trigger.AfterMove(); if (boardAttributes.InEnemyRegion(to.x, to.y)) { trigger.InEnemyRegion(); } else if (boardAttributes.InEnemyPalace(to.x, to.y)) { trigger.InEnemyRegion(); } else if (boardAttributes.InEnemyCastle(to.x, to.y)) { trigger.InEnemyCastle(); } else if (boardAttributes.AtEnemyBottom(to.x, to.y)) { trigger.AtEnemyBottom(); } //onEnterGame.AskTrigger(pieceInfo.piece, trigger, "AfterMove"); //if (boardAttributes.InEnemyRegion(to.x, to.y)) onEnterGame.AskTrigger(pieceInfo.piece, trigger, "InEnemyRegion"); //else if (boardAttributes.InEnemyPalace(to.x, to.y)) onEnterGame.AskTrigger(pieceInfo.piece, trigger, "InEnemyPalace"); //else if (boardAttributes.InEnemyCastle(to.x, to.y)) onEnterGame.AskTrigger(pieceInfo.piece, trigger, "InEnemyCastle"); //else if (boardAttributes.AtEnemyBottom(to.x,to.y)) onEnterGame.AskTrigger(pieceInfo.piece, trigger, "AtEnemyBottom"); }
public static void DecodeGameEvent(GameEvent gameEvent) { gameEvent.FlipLocation(); // because location is different from different views switch (gameEvent.result) { case "EndTurn": onEnterGame.NextTurn(false); break; case "Victory": onEnterGame.Defeat(false); break; case "Defeat": onEnterGame.Draw(false); break; case "Draw": onEnterGame.Victory(false); break; case "Move": MovementController.Move(OnEnterGame.gameInfo.board[gameEvent.eventLocation], gameEvent.eventLocation, gameEvent.targetLocation, false); break; case "Kill": Eliminate(OnEnterGame.gameInfo.board[gameEvent.eventLocation]); break; case "Freeze": FreezePiece(gameEvent.targetLocation, gameEvent.amount); break; case "Flag": PlaceFlag(gameEvent.eventLocation, gameEvent.eventPlayerID, gameEvent); break; case "RemoveFlag": RemoveFlag(gameEvent.eventLocation); break; case "Trap": onEnterGame.TriggerTrap(gameEvent.eventLocation); break; case "PieceCost": ChangePieceOreCost(gameEvent.eventLocation, gameEvent.amount, gameEvent); break; case "PieceHealth": ChangePieceHealth(gameEvent.eventLocation, gameEvent.amount, gameEvent); break; case "TacticGold": ChangeTacticGoldCost(gameEvent.targetTriggerName, gameEvent.amount, gameEvent); break; case "TacticOre": ChangeTacticOreCost(gameEvent.targetTriggerName, gameEvent.amount, gameEvent); break; case "Discard": RemoveTactic(new Tactic(Database.FindTacticAttributes(gameEvent.targetTriggerName)), false); break; } }