public void selectchessman() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit = Physics2D.Raycast(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0f); if (hit) { if (hit.transform.gameObject.tag != "allowed") { if (ismove == false) { Highlight.instance.hidehighlight(); } } } if (selected == true) { lastselect.GetComponent <SpriteRenderer>().color = Color.white; } if (hit) { if (hit.transform.gameObject.tag == activepiece) { if (playerinfo[(int)hit.transform.gameObject.transform.position.x, (int)hit.transform.gameObject.transform.position.y]) { hit.transform.gameObject.GetComponent <SpriteRenderer>().color = Color.cyan; lastselect = hit.transform.gameObject; player = playerinfo[(int)lastselect.transform.position.x, (int)lastselect.transform.position.y]; allowedmoves = playerinfo[(int)lastselect.transform.position.x, (int)lastselect.transform.position.y].possiblemove(); selected = true; ismove = false; Highlight.instance.highlightallowedmoves(allowedmoves); } } else { return; } } else { return; } } }
// Start is called before the first frame update void Start() { info = GameObject.FindWithTag("Info").GetComponent <playerinfo>(); foreach (Collectibles item in info.inventory) { item.player = this.gameObject; } // Makes sure game is "unpaused" isGamePaused = false; Time.timeScale = 1.0f; // Make sure all menus are filled in FindAllMenus(); //Start player with initial health and score //health = 100; //score = 0; }
public override bool[,] possiblemove() { playerinfo p; playerinfo player = GameManager.boardmanager.playerinfo[currentx, currenty]; bool[,] r = new bool[80, 80]; // left move and forward move. if (currentx <= 70 && currentx >= 0) { for (int i = 10; currentx - i >= 0; i += 10) { p = GameManager.boardmanager.playerinfo[currentx - i, currenty]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - i, currenty] = true; break; } else { break; } } else { r[currentx - i, currenty] = true; } } for (int i = 10; currenty + i <= 70; i += 10) { p = GameManager.boardmanager.playerinfo[currentx, currenty + i]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx, currenty + i] = true; break; } else { break; } } else { r[currentx, currenty + i] = true; } } } //right move. if (currentx != 70) { for (int i = 10; currentx + i <= 70; i += 10) { p = GameManager.boardmanager.playerinfo[currentx + i, currenty]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + i, currenty] = true; break; } else { break; } } else { r[currentx + i, currenty] = true; } } } // backward move. if (currenty != 0) { for (int i = 10; currenty - i >= 0; i += 10) { p = GameManager.boardmanager.playerinfo[currentx, currenty - i]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx, currenty - i] = true; break; } else { break; } } else { r[currentx, currenty - i] = true; } } } // forward left moves if (currentx != 0 && currenty != 70) { for (int i = 10; currentx - i >= 0; i += 10) { if (currenty + i <= 70) { p = GameManager.boardmanager.playerinfo[currentx - i, currenty + i]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - i, currenty + i] = true; break; } else { break; } } else { r[currentx - i, currenty + i] = true; } } else { continue; } } } //forward right moves if (currentx != 70 && currenty != 70) { for (int i = 10; currentx + i <= 70; i += 10) { if (currenty + i <= 70) { p = GameManager.boardmanager.playerinfo[currentx + i, currenty + i]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + i, currenty + i] = true; break; } else { break; } } else { r[currentx + i, currenty + i] = true; } } else { continue; } } } //backward right moves if (currentx != 70 && currenty != 0) { for (int i = 10; currenty - i > 0; i += 10) { if (currentx + i <= 70) { p = GameManager.boardmanager.playerinfo[currentx + i, currenty - i]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + i, currenty - i] = true; break; } else { break; } } else { r[currentx + i, currenty - i] = true; } } else { continue; } } } //backward left moves if (currentx != 0 && currenty != 0) { for (int i = 10; currenty - i > 0; i += 10) { if (currentx - i >= 0) { p = GameManager.boardmanager.playerinfo[currentx - i, currenty - i]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - i, currenty - i] = true; break; } else { break; } } else { r[currentx - i, currenty - i] = true; } } else { continue; } } } return(r); }
public override bool[,] possiblemove() { playerinfo p; playerinfo player = GameManager.boardmanager.playerinfo[currentx, currenty]; bool[,] r = new bool[80, 80]; // special move. if (GameManager.boardmanager.specialmove == true) { playerinfo p1, p2, p3, p4; if (currenty == 0) { p = GameManager.boardmanager.playerinfo[currentx - 10, currenty]; p1 = GameManager.boardmanager.playerinfo[currentx - 20, currenty]; p2 = GameManager.boardmanager.playerinfo[currentx - 30, currenty]; p3 = GameManager.boardmanager.playerinfo[currentx + 10, currenty]; p4 = GameManager.boardmanager.playerinfo[currentx + 20, currenty]; if (p == null && p1 == null && p2 == null) { r[currentx - 20, currenty] = true; } if (p3 == null && p4 == null) { r[currentx + 20, currenty] = true; } } else if (currenty == 70) { p = GameManager.boardmanager.playerinfo[currentx - 10, currenty]; p1 = GameManager.boardmanager.playerinfo[currentx - 20, currenty]; p2 = GameManager.boardmanager.playerinfo[currentx - 30, currenty]; p3 = GameManager.boardmanager.playerinfo[currentx + 10, currenty]; p4 = GameManager.boardmanager.playerinfo[currentx + 20, currenty]; if (p == null && p1 == null && p2 == null) { r[currentx - 20, currenty] = true; } if (p3 == null && p4 == null) { r[currentx + 20, currenty] = true; } } } // forward move. if (currenty != 70) { p = GameManager.boardmanager.playerinfo[currentx, currenty + 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx, currenty + 10] = true; } } else { r[currentx, currenty + 10] = true; } } // backward move. if (currenty != 0) { p = GameManager.boardmanager.playerinfo[currentx, currenty - 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx, currenty - 10] = true; } } else { r[currentx, currenty - 10] = true; } } // left move. if (currentx != 0) { p = GameManager.boardmanager.playerinfo[currentx - 10, currenty]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - 10, currenty] = true; } } else { r[currentx - 10, currenty] = true; } } // right move. if (currentx != 70) { p = GameManager.boardmanager.playerinfo[currentx + 10, currenty]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + 10, currenty] = true; } } else { r[currentx + 10, currenty] = true; } } // forward and backward right diagonal move. if (currentx != 70) { // forward right diagonal move. if (currenty != 0) { p = GameManager.boardmanager.playerinfo[currentx + 10, currenty - 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + 10, currenty - 10] = true; } } else { r[currentx + 10, currenty - 10] = true; } } // backward right diagonal move. if (currenty != 70) { p = GameManager.boardmanager.playerinfo[currentx + 10, currenty + 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + 10, currenty + 10] = true; } } else { r[currentx + 10, currenty + 10] = true; } } } // forward and backward left diagonal move. if (currentx != 0) { // forward left diagonal move. if (currenty != 0) { p = GameManager.boardmanager.playerinfo[currentx - 10, currenty - 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - 10, currenty - 10] = true; } } else { r[currentx - 10, currenty - 10] = true; } } // backward left diagonal move. if (currenty != 70) { p = GameManager.boardmanager.playerinfo[currentx - 10, currenty + 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - 10, currenty + 10] = true; } } else { r[currentx - 10, currenty + 10] = true; } } } return(r); }
void ShowLotery(BasePlayer player, string[] args) { if (!Economy.IsLoaded) { SendReply(player, lang.GetMessage("NoEconomy", this, player.UserIDString)); return; } int multiplier = 1; int bet = 0; int from = 0; double currentBalance = (double)Economy?.Call("GetPlayerMoney", player.userID.ToString()); playerinfo playerbet = new playerinfo(); if (Currentbet.ContainsKey(player.userID)) { Currentbet.TryGetValue(player.userID, out playerbet); } else { Currentbet.Add(player.userID, new playerinfo()); Currentbet.TryGetValue(player.userID, out playerbet); } if (args != null && args.Length > 0) { if (args[0].Contains("less") || args[0].Contains("plus")) { if (args[0].Contains("plus")) { if (currentBalance >= playerbet.currentbet * (playerbet.multiplicator + 1)) { int.TryParse(args[1], out multiplier); playerbet.multiplicator += multiplier; } } if (args[0].Contains("less")) { if (playerbet.multiplicator > 1) { playerbet.multiplicator -= 1; } } } if (args[0].Contains("bet")) { int.TryParse(args[1], out bet); if (currentBalance < (playerbet.currentbet + bet) * playerbet.multiplicator) { SendReply(player, lang.GetMessage("NotEnoughMoney", this, player.UserIDString)); } else { playerbet.currentbet += bet; } } if (args[0].Contains("page")) { int.TryParse(args[1], out from); } } int i = 0; double jackpots = Math.Round(Currentbet.Sum(v => v.Value.totalbet)); jackpots += jackpot; var win = new CuiElementContainer(); var containerwin = win.Add(new CuiPanel { Image = { Color = "0.1 0.1 0.1 1" }, RectTransform = { AnchorMin = "0.8 0.2", AnchorMax = "1 0.8" }, CursorEnabled = true }, "Hud", "containerwin"); win.Add(new CuiLabel { Text = { Text = "Win Rate", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.1 0.85", AnchorMax = "0.9 1" } }, containerwin); if (UseSR && ServerRewards.IsLoaded) { foreach (var elem in SRRates) { var pos = 0.86 - (i - from) / 10.0; var pos2 = 0.91 - (i - from) / 20.0; win.Add(new CuiLabel { Text = { Text = elem.Key + ": " + elem.Value + " point(s)", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = $"{0.1} {pos}", AnchorMax = $"{0.9} {pos2}" } }, containerwin); i++; } } else { foreach (var elem in IndividualRates) { if (i == 0) { var pos = 0.81 - (i - from) / 10.0; var pos2 = 0.86 - (i - from) / 20.0; win.Add(new CuiLabel { Text = { Text = elem.Key + ": " + elem.Value + " %", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = $"{0.1} {pos}", AnchorMax = $"{0.9} {pos2}" } }, containerwin); } else if (i >= from && i < from + 9) { var pos = 0.81 - (i - from) / 10.0; var pos2 = 0.86 - (i - from) / 20.0; win.Add(new CuiLabel { Text = { Text = elem.Key + ": " + elem.Value + " %", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = $"{0.1} {pos}", AnchorMax = $"{0.9} {pos2}" } }, containerwin); } i++; } var minfrom = from <= 10 ? 0 : from - 10; var maxfrom = from + 10 >= i ? from : from + 10; win.AddRange(ChangeBonusPage(minfrom, maxfrom)); } var elements = new CuiElementContainer(); #region background var container = elements.Add(new CuiPanel { Image = { Color = "0.1 0.1 0.1 1" }, RectTransform = { AnchorMin = "0 0.2", AnchorMax = "0.8 0.8" }, CursorEnabled = true }, "Hud", "container"); #endregion #region closebutton var closeButton = new CuiButton { Button = { Command = "cmdDestroyUI", Close = container, Color = "0.8 0.8 0.8 0.2" }, RectTransform = { AnchorMin = "0.86 0.92", AnchorMax = "0.97 0.98" }, Text = { Text = "X", FontSize = 22, Align = TextAnchor.MiddleCenter } }; elements.Add(closeButton, container); #endregion #region currency elements.Add(new CuiLabel { Text = { Text = string.Format(lang.GetMessage("Balance", this, player.UserIDString), currentBalance.ToString(CultureInfo.CurrentCulture)), FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.1 0.91", AnchorMax = "0.9 0.98" } }, container); #endregion #region multiplier elements.Add(new CuiLabel { Text = { Text = "Multiplier : x" + playerbet.multiplicator, FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.05 0.81", AnchorMax = "0.15 0.88" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdLess", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "-", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.2 0.81", AnchorMax = "0.3 0.88" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdPlus", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "+", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.31 0.81", AnchorMax = "0.41 0.88" } }, container); #endregion #region bet elements.Add(new CuiLabel { Text = { Text = "Bet modifiers :", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.05 0.61", AnchorMax = "0.15 0.68" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdBet 1", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "+1", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.05 0.51", AnchorMax = "0.15 0.58" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdBet 5", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "+5", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.155 0.51", AnchorMax = "0.255 0.58" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdBet 10", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "+10", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.26 0.51", AnchorMax = "0.36 0.58" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdBet 100", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "+100", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.365 0.51", AnchorMax = "0.485 0.58" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdBet 1000", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "+1000", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.05 0.41", AnchorMax = "0.15 0.48" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdBet 10000", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "+10000", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.155 0.41", AnchorMax = "0.255 0.48" } }, container); elements.Add(new CuiButton { Button = { Command = "cmdPlaceBet", Close = container, Color = "0.8 0.8 0.8 0.2" }, Text = { Text = "Place Bet", FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.05 0.31", AnchorMax = "0.255 0.38" } }, container); #endregion #region winpart elements.Add(new CuiLabel { Text = { Text = string.Format(lang.GetMessage("CurrentBet", this, player.UserIDString), playerbet.currentbet * playerbet.multiplicator), FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.71 0.71", AnchorMax = "0.99 0.81" } }, container); if (UseSR && ServerRewards.IsLoaded) { var mini = string.Format(lang.GetMessage("MinimumSRBet", this, player.UserIDString), MinBetjackpot, SRjackpot); elements.Add(new CuiLabel { Text = { Text = mini, FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.71 0.39", AnchorMax = "0.99 0.59" } }, container); } else { elements.Add(new CuiLabel { Text = { Text = string.Format(lang.GetMessage("Roll", this, player.UserIDString), JackpotNumber, jackpots), FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = "0.71 0.39", AnchorMax = "0.99 0.59" } }, container); } #endregion CuiHelper.AddUi(player, elements); CuiHelper.AddUi(player, win); Currentbet.Remove(player.userID); Currentbet.Add(player.userID, playerbet); SaveData(Currentbet); }
void cmdPlaceBet(ConsoleSystem.Arg arg) { Dictionary <ulong, playerinfo> playerinfos = new Dictionary <ulong, playerinfo>(); GUIDestroy(arg.Player()); if (arg.Player() == null) { return; } playerinfo playerbet = new playerinfo(); if (!Currentbet.ContainsKey(arg.Player().userID)) { Currentbet.Add(arg.Player().userID, new playerinfo()); } else { Currentbet.TryGetValue(arg.Player().userID, out playerbet); } if (playerbet.currentbet == 0) { SendReply(arg.Player(), lang.GetMessage("NoBet", this, arg.Player().UserIDString)); return; } int random = UnityEngine.Random.Range(DefaultMinRange, DefaultMaxRange); if (UseSR && ServerRewards.IsLoaded) { if (SRMinBet <= playerbet.currentbet * playerbet.multiplicator) { double reward = FindReward(arg.Player(), (int)playerbet.currentbet, random, playerbet.multiplicator); if (playerbet.currentbet * playerbet.multiplicator >= MinBetjackpot) { if (random == SRJackpotNumber) { foreach (var resetbet in Currentbet) { resetbet.Value.totalbet = 0; resetbet.Value.multiplicator = 1; playerinfos.Add(resetbet.Key, resetbet.Value); } Currentbet.Clear(); Currentbet = playerinfos; ServerRewards?.Call("AddPoints", new object[] { arg.Player().userID, reward }); SendReply(arg.Player(), string.Format(lang.GetMessage("Jackpot", this, arg.Player().UserIDString), random, reward)); return; } } if (reward != 0 && random != SRJackpotNumber) { Currentbet.Remove(arg.Player().userID); Currentbet.Add(arg.Player().userID, playerbet); ServerRewards?.Call("AddPoints", new object[] { arg.Player().userID, reward }); SendReply(arg.Player(), string.Format(lang.GetMessage("WinPoints", this, arg.Player().UserIDString), random, reward)); } else if (reward == 0) { SendReply(arg.Player(), string.Format(lang.GetMessage("NoWin", this, arg.Player().UserIDString), random)); } else { ServerRewards?.Call("AddPoints", new object[] { arg.Player().userID, reward }); SendReply(arg.Player(), string.Format(lang.GetMessage("WinPoints", this, arg.Player().UserIDString), random, reward)); } playerbet.totalbet += playerbet.currentbet * (10 / 100.0); Economy?.CallHook("Withdraw", arg.Player().userID, playerbet.currentbet * playerbet.multiplicator); playerbet.currentbet = 0; playerbet.multiplicator = 1; } else { SendReply(arg.Player(), string.Format(lang.GetMessage("MiniSRBet", this, arg.Player().UserIDString), SRMinBet)); } } else { double reward = FindReward(arg.Player(), (int)playerbet.currentbet, random, playerbet.multiplicator); if (random == JackpotNumber) { foreach (var resetbet in Currentbet) { resetbet.Value.totalbet = 0; resetbet.Value.multiplicator = 1; playerinfos.Add(resetbet.Key, resetbet.Value); } Currentbet.Clear(); Currentbet = playerinfos; Economy?.CallHook("Deposit", arg.Player().userID, reward); SendReply(arg.Player(), string.Format(lang.GetMessage("Jackpot", this, arg.Player().UserIDString), random, reward)); } else if (reward != 0 && random != JackpotNumber) { Currentbet.Remove(arg.Player().userID); Currentbet.Add(arg.Player().userID, playerbet); Economy?.CallHook("Deposit", arg.Player().userID, reward); SendReply(arg.Player(), string.Format(lang.GetMessage("Win", this, arg.Player().UserIDString), random, reward)); } else if (reward == 0) { SendReply(arg.Player(), string.Format(lang.GetMessage("NoWin", this, arg.Player().UserIDString), random)); } else { Economy?.CallHook("Deposit", arg.Player().userID, reward); SendReply(arg.Player(), string.Format(lang.GetMessage("Win", this, arg.Player().UserIDString), random, reward)); } playerbet.totalbet += playerbet.currentbet * (10 / 100.0); Economy?.CallHook("Withdraw", arg.Player().userID, playerbet.currentbet * playerbet.multiplicator); playerbet.currentbet = 0; playerbet.multiplicator = 1; } SaveData(Currentbet); }
public override bool[,] possiblemove() { playerinfo p; playerinfo player = GameManager.boardmanager.playerinfo[(int)transform.position.x, (int)transform.position.y]; bool[,] r = new bool[80, 80]; //right forward move in y-axis. if (currentx != 0 && currenty != 60 && currenty != 70) { p = GameManager.boardmanager.playerinfo[currentx - 10, currenty + 20]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - 10, currenty + 20] = true; } } else { r[currentx - 10, currenty + 20] = true; } } //left forward move in y-axis. if (currentx != 70 && currenty != 60 && currenty != 70) { p = GameManager.boardmanager.playerinfo[currentx + 10, currenty + 20]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + 10, currenty + 20] = true; } } else { r[currentx + 10, currenty + 20] = true; } } //right backward move in y-axis. if (currentx != 0 && currenty != 0 && currenty != 10) { p = GameManager.boardmanager.playerinfo[currentx - 10, currenty - 20]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - 10, currenty - 20] = true; } } else { r[currentx - 10, currenty - 20] = true; } } //left backward move in y-axis. if (currentx != 70 && currenty != 0 && currenty != 10) { p = GameManager.boardmanager.playerinfo[currentx + 10, currenty - 20]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + 10, currenty - 20] = true; } } else { r[currentx + 10, currenty - 20] = true; } } //left forward move in x- axis. if (currentx != 0 && currentx != 10 && currenty != 70) { p = GameManager.boardmanager.playerinfo[currentx - 20, currenty + 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - 20, currenty + 10] = true; } } else { r[currentx - 20, currenty + 10] = true; } } //right forward move in x- axis. if (currentx != 60 && currentx != 70 && currenty != 70) { p = GameManager.boardmanager.playerinfo[currentx + 20, currenty + 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + 20, currenty + 10] = true; } } else { r[currentx + 20, currenty + 10] = true; } } //left backward move in x- axis. if (currentx != 0 && currentx != 10 && currenty != 0) { p = GameManager.boardmanager.playerinfo[currentx - 20, currenty - 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx - 20, currenty - 10] = true; } } else { r[currentx - 20, currenty - 10] = true; } } //right backward move in x- axis. if (currentx != 60 && currentx != 70 && currenty != 0) { p = GameManager.boardmanager.playerinfo[currentx + 20, currenty - 10]; if (p != null) { if (p.iswhite == !player.iswhite) { r[currentx + 20, currenty - 10] = true; } } else { r[currentx + 20, currenty - 10] = true; } } return(r); }
public void movechessman() { playerinfo p; if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit1 = Physics2D.Raycast(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0f); if (hit1) { if (hit1.transform.gameObject.tag == "allowed" && ismove == false) { // captaure gameobject p = playerinfo[(int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y]; if (p != null) { if (p.GetType() == typeof(king)) { // GameOver gameover = true; if (p.iswhite) { whitewin.SetActive(true); } else { blackwin.SetActive(true); } } if (p != null && p.iswhite != Iswhite) { activechessprefap.Remove(p.gameObject); Destroy(p.gameObject); } } // capture pawns by Enpassent move. if (enpassent[0] == (int)hit1.transform.gameObject.transform.position.x && enpassent[1] == (int)hit1.transform.gameObject.transform.position.y) { if (Iswhite) { p = playerinfo[(int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y - 10]; } else { p = playerinfo[(int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y + 10]; } Destroy(p.gameObject); } enpassent[0] = -1; enpassent[1] = -1; // enpassent move if (player.GetType() == typeof(pawns)) { if ((int)hit1.transform.gameObject.transform.position.y == 70) { activechessprefap.Remove(player.gameObject); Destroy(player.gameObject); placechessmens(0, new Vector2((int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y), 0); player = playerinfo[(int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y]; lastselect = player.gameObject; } else if ((int)hit1.transform.gameObject.transform.position.y == 0) { activechessprefap.Remove(player.gameObject); Destroy(player.gameObject); placechessmens(9, new Vector2((int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y), 180); player = playerinfo[(int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y]; lastselect = player.gameObject; } if (player.currenty == 10 && (int)hit1.transform.gameObject.transform.position.y == 30) { enpassent[0] = (int)hit1.transform.gameObject.transform.position.x; enpassent[1] = (int)hit1.transform.gameObject.transform.position.y - 10; } else if (player.currenty == 60 && (int)hit1.transform.gameObject.transform.position.y == 40) { enpassent[0] = (int)hit1.transform.gameObject.transform.position.x; enpassent[1] = (int)hit1.transform.gameObject.transform.position.y + 10; } } // spawn rook and king. if (specialmove == true) { if (player.GetType() == typeof(king)) { if ((int)hit1.transform.gameObject.transform.position.x == player.currentx + 20 || (int)hit1.transform.gameObject.transform.position.x == player.currentx - 20) { if ((int)hit1.transform.gameObject.transform.position.x == player.currentx - 20) { playerinfo[0, player.currenty].gameObject.transform.position = new Vector3(30, player.currenty, 0); } else { playerinfo[70, player.currenty].gameObject.transform.position = new Vector3(50, player.currenty, 0); } } } } playerinfo[player.currentx, player.currenty] = null; lastselect.transform.position = hit1.transform.gameObject.transform.position; // special move. if (player.GetType() == typeof(rook) || player.GetType() == typeof(king)) { specialmove = false; } playerinfo[(int)hit1.transform.gameObject.transform.position.x, (int)hit1.transform.gameObject.transform.position.y] = player; player.currentx = (int)hit1.transform.gameObject.transform.position.x; player.currenty = (int)hit1.transform.gameObject.transform.position.y; Iswhite = !Iswhite; Highlight.instance.hidehighlight(); if (activepiece == "white") { activepiece = "black"; } else { activepiece = "white"; } } } } }