private IEnumerable <string> WaitUntilTimeContains(string number) { while (true) { if (BombInfo.GetFormattedTime().Contains(number)) { if (solRequiresHold && ReleaseNumbers[solReleaseColor] == number) { Log("Button held and released corectly! Module defused."); HandlePass(); yield return(ResponseStrings.Solve); } else { if (!solRequiresHold) { Log("Button held when supposed to be tapped! Strike!"); } else { Log($"Button released at incorrect time ({BombInfo.GetFormattedTime()})! Strike!"); } HandleStrike(); yield return(ResponseStrings.Strike); } solReleaseColor = -1; yield break; } else { yield return(null); } } }
/// <summary> /// Called on every frame /// </summary> protected virtual void Update() { if (BombInfo != null) { var solveds = BombInfo.GetSolvedModuleNames(); var solvables = GetUnsolvedModuleNames(); bool complete = IgnoredModules == null ? solvables.Count <= 1 : solvables.All(IgnoredModules.Contains); if (solveds.Count > OldSolveds.Count) { var TempSolveds = solveds.ToList(); foreach (string module in OldSolveds) { TempSolveds.Remove(module); } OldSolveds = solveds; foreach (string module in TempSolveds) { if (WatchSolves && OnNewStage != null && (IgnoredModules == null || !IgnoredModules.Contains(module))) { OnNewStage(module, complete); } } } } if (TwitchID < 1) { TwitchID = GetTwitchID(); } }
public static object DeserializeBombInfo(byte[] bytes) { Vector3 startPos = Vector3.zero; Vector3 direction = Vector3.zero; PhotonPlayer shooter = PhotonNetwork.player; int shooterID = 0; Vector3 speed = Vector3.zero; int id = 0; int index = 0; ExitGames.Client.Photon.Protocol.Deserialize(out startPos.x, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out startPos.y, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out startPos.z, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out direction.x, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out direction.y, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out direction.z, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out shooterID, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out speed.x, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out speed.y, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out speed.z, bytes, ref index); ExitGames.Client.Photon.Protocol.Deserialize(out id, bytes, ref index); shooter = shooter.Get(shooterID); BombInfo bombInfo = new BombInfo(startPos, direction, shooter, speed, id); return bombInfo; }
public void SetAdditionalInfo(string name) { BombInfo tempData = JsonUtility.FromJson <BombInfo>(FileIO.ReadString("Assets/Generators/" + name + ".json")); titleText.text = tempData.name; descText.text = tempData.description; if (PlayerData.stats.ContainsKey(name)) { if (PlayerData.stats[name].win) { timeText.text = "Best Time: " + ((int)(PlayerData.stats[name].time / 60)).ToString("00") + ":" + (PlayerData.stats[name].time % 60).ToString("00.00"); completeText.text = "Complete: ✓"; } else { timeText.text = "Best Time: N/A"; completeText.text = "Complete: ✘"; } levelScoreText.text = "Best Score: " + PlayerData.stats[name].score; } else { timeText.text = "Best Time: N/A"; levelScoreText.text = "Best Score: N/A"; completeText.text = "Complete: ✘"; } }
/// <summary> /// Activate bomb text of the hexagon gameobject and set its bomb timer value to the text, /// </summary> /// <param name="bombInfo"></param> /// <param name="itemComponents"></param> private void ActivateBombText(BombInfo bombInfo, ItemComponents itemComponents) { Text text = itemComponents.text; text.enabled = true; text.text = bombInfo.bombLeftMove.ToString(); text.color = Color.black; }
//public Dictionary<string, ModuleInfo> moduleConfig = new Dictionary<string, ModuleInfo>(); // Start is called before the first frame update public void Start() { meta = JsonUtility.FromJson <BombInfo>(FileIO.ReadString("Assets/Generators/default.json")); for (int i = 0; i < moduleNames.Count; i++) { allModules.Add(moduleNames[i], prefabModules[i]); } DontDestroyOnLoad(this); SendData(); }
public void GenerateBomb(int x, int y, float timer, BombInfo info) { GameObject obj = Instantiate(bombPrefab, new Vector3(x, 0.5f, y), Quaternion.identity) as GameObject; objectDic.Add(PointToInt(new Point(x, y)), obj); Bomb bombScript = obj.AddComponent <Bomb>(); bombScript.info = info; Destroy(obj, timer); }
public void PutBomb(int x, int y, BombInfo info) { Debug.Log("PutBomb"); if (CanPutBomb(x, y)) { model.PutBomb(x, y); view.GenerateBomb(x, y, info.timer, info); StartCoroutine(ExplosionBomb(x, y, info.range, info.timer)); } }
void PutBomb() { Debug.Log(bombMaxCount); if (bombCount < bombMaxCount) { BombInfo info = new BombInfo(this, bombRange); StageController.Instance.PutBomb(CurrentPoint.x, CurrentPoint.y, info); bombCount++; AudioManager.Instance.PlaySE(Audio.UNITYCAHN2); } }
public void SetData(string jsonPath) { /*"Assets/Generators/test.json"*/ meta = JsonUtility.FromJson <BombInfo>(FileIO.ReadString(jsonPath)); /* * foreach (ModuleInfo mf in meta.modules) { * moduleConfig.Add(mf.name, mf); * } */ }
public BombInfo(BombInfo other) { this.type = other.type; this.initPosition = other.initPosition; this.initAngle = other.initAngle; this.isLocked = other.isLocked; this.timeout = other.timeout; this.movement = other.movement; this.rotate = other.rotate; }
protected override void CaulcElimList() { FindMvpCells(); if (_mvpCellList.Count > 0) { float fishDely = GameConfig.Instance.GetTime(TimeConf.fishDelay); var tarRow = _mvpCellList[0].Row; var tarCol = _mvpCellList[0].Col; var curInfo = new BombInfo(_triggerModel, fishDely, tarRow, tarCol, BombCmd.Elim); _elimInfoList.Add(curInfo); } }
protected void InitBombs() { // Init all bombs in level for (int i = 0; i < level.bombs.Count; i++) { BombInfo bombInfo = level.bombs[i]; BombManager.Instance.CreateBomb(bombInfo); if (bombInfo.timeout > 0 && bombInfo.timeout > maxTimer) { maxTimer = bombInfo.timeout; } } }
/// <summary> /// Gets the IDs of the unsolved modules /// </summary> /// <returns>The list of unsolved module IDs</returns> /// <exception cref="ModuleException">There is no KMBombInfo component attached</exception> protected List <string> GetUnsolvedModuleIDs() { if (BombInfo == null) { throw new ModuleException("There is no KMBombInfo component attached!"); } var AllModules = BombInfo.GetSolvableModuleIDs(); foreach (string module in BombInfo.GetSolvedModuleIDs()) { AllModules.Remove(module); } return(AllModules); }
public override void Init() { stages = RandomUtil.Int(3, 6); flashingColors = new int[stages]; correctColors = new int[stages]; for (int i = 0; i < stages; i++) { flashingColors[i] = RandomUtil.Int(4); } hasVowel = BombInfo.GetSerialNumberLetters().Any(x => "AEIOU".Contains(x)); CalculateCorrectColors(); PrepImages(this); }
protected void BombCellsWithDir(int offsetRow, int offsetCol, float delayTime = 0f, int distance = 100) { int curRow = _curRow + offsetRow; int curCol = _curCol + offsetCol; int curDistance = 0; while (IsInBorder(curRow, curCol) && curDistance < distance) { BombInfo curInfo = new BombInfo(_triggerModel, delayTime * curDistance, curRow, curCol, BombCmd.Elim); _elimInfoList.Add(curInfo); curRow += offsetRow; curCol += offsetCol; curDistance += 1; } }
protected override void CaulcElimList() { FindMvpCells(); if (_mvpCellList.Count > 0) { float fishDely = GameConfig.Instance.GetTime(TimeConf.fishDelay); float combinTime = GameConfig.Instance.GetTime(TimeConf.combinTriggerDelay); for (int i = 0; i < _mvpCellList.Count && i < _fishNum; i++) { var tarRow = _mvpCellList[i].Row; var tarCol = _mvpCellList[i].Col; var curInfo = new BombInfo(_triggerModel, fishDely + i * combinTime, tarRow, tarCol, BombCmd.Elim); _elimInfoList.Add(curInfo); } } }
protected override void CaulcElimList() { float colorDelay = GameConfig.Instance.GetTime (TimeConf.colorDelay); var curLvCtrl = LevelCtrl.Current; for (int curRow = _minRow; curRow < _maxRow; curRow++) { for(int curCol = _minCol; curCol < _maxCol ; curCol++) { CellCtrl curCell = curLvCtrl[curRow,curCol]; if(curCell!= null && curCell != _triggerModel && curCell.IsEliminateable && curCell.MatchEliminateColor(_elimColor)) { var curInfo = new BombInfo(_triggerModel,colorDelay,curRow,curCol,BombCmd.Elim); _elimInfoList.Add(curInfo); } } } }
public override void Init() { label = RandomUtil.Int(4); color = RandomUtil.Int(4); Log($"Button: {ColorNames[color]} {Labels[label]}"); solRequiresHold = color == 2 && label == 1 ? true : BombInfo.GetBatteryCount() > 1 && label == 1 ? false : color == 3 && BombInfo.IsIndicatorOn(Indicator.CAR) ? true : BombInfo.GetBatteryCount() > 2 && BombInfo.IsIndicatorOn(Indicator.FRK) ? false : color == 1 ? true : color == 0 && label == 2 ? false : true; Log($"Solution: " + (solRequiresHold ? "HOLD" : "PRESS")); }
protected override void CaulcElimList() { float colorDelay = GameConfig.Instance.GetTime(TimeConf.colorDelay); var curLvCtrl = LevelCtrl.Current; for (int curRow = _minRow; curRow < _maxRow; curRow++) { for (int curCol = _minCol; curCol < _maxCol; curCol++) { CellCtrl curCell = curLvCtrl[curRow, curCol]; if (curCell != null && curCell != _triggerModel && curCell.IsEliminateable && curCell.MatchEliminateColor(_elimColor)) { var curInfo = new BombInfo(_triggerModel, colorDelay, curRow, curCol, BombCmd.Elim); _elimInfoList.Add(curInfo); } } } }
public string GetEdgeworkString() { if (!BombInProgress) { return("Bomb not in progress"); } else { BombInfo bombInfo = CurrentBomb.BombInfo; return("{0}b {1}h // {2} {3} // {4} // {5}".FormatThis( bombInfo.GetBatteryCount(), bombInfo.GetBatteryHolderCount(), String.Join(" ", bombInfo.GetOnIndicators().Select(x => "*" + x)), String.Join(" ", bombInfo.GetOffIndicators()), String.Join(" ", bombInfo.GetPortPlates().Select(x => "[" + String.Join(", ", x) + "]")), bombInfo.GetSerialNumber() )); } }
// Use this for initialization void Start() { if (_infos.ContainsKey(Info.GetSerialNumber())) { _info = _infos[Info.GetSerialNumber()]; } else { _infos.Add(Info.GetSerialNumber(), new BombInfo()); _info = _infos[Info.GetSerialNumber()]; } StartCoroutine(MakeCover()); Info.OnBombExploded += delegate() { Reset(); }; Info.OnBombSolved += delegate() { if (Info.GetSolvedModuleNames().Count == Info.GetSolvableModuleNames().Count) { Reset(); } }; }
protected override void CaulcElimList() { float dyeDelay = GameConfig.Instance.GetTime(TimeConf.dyeDelay); var dyeList = new List <BombInfo> (); var curLvCtrl = LevelCtrl.Current; for (int curRow = _minRow; curRow < _maxRow; curRow++) { for (int curCol = _minCol; curCol < _maxCol; curCol++) { CellCtrl curCell = curLvCtrl[curRow, curCol]; if (curCell != null && curCell != _triggerModel && curCell.IsEliminateable && !curCell.MatchEliminateColor(_dyeColor)) { var curInfo = new BombInfo(_triggerModel, dyeDelay, curRow, curCol, BombCmd.Dye); curInfo._formColor = _dyeColor; dyeList.Add(curInfo); } } } }
/// <summary> /// Set UI components of the hexagon gameobjects like hesagon sprite, hexagon color, bomb text etc. /// </summary> /// <param name="itemComponents"></param> /// <param name="matchType"></param> /// <param name="bombInfo"></param> private void SetUIValues(ItemComponents itemComponents, MatchType matchType, BombInfo bombInfo) { if (itemComponents == null) { return; } Image image = itemComponents.image; image.sprite = matchTreeUIDataHolder.HexagonSprite; image.color = matchTreeUIDataHolder.SpriteColors[(int)matchType - 1]; if (bombInfo.hasBomb) { ActivateBombText(bombInfo, itemComponents); } else { Text text = itemComponents.text; text.enabled = false; } }
public void SetBombInfo(BombInfo aBombInfo) { m_bombInfo = aBombInfo; m_bombInfo.gameObject = this.gameObject; string teamBombPath = ""; if ((int)m_bombInfo.m_shooter.customProperties["Team"] == 1) { teamBombPath = "Bomb01"; } else { teamBombPath = "Bomb02"; } GameObject graphic = (GameObject)Instantiate((GameObject)Resources.Load(teamBombPath), transform.position, transform.rotation); graphic.transform.parent = transform; }
public static byte[] SerializeBombInfo(object aBombInfo) { BombInfo bombInfo = (BombInfo)aBombInfo; byte[] bytes = new byte[sizeof(float) * 9 + sizeof(int) * 2]; int index = 0; ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startPosition.x, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startPosition.y, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startPosition.z, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startDirection.x, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startDirection.y, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startDirection.z, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_shooter.ID, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startVelocity.x, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startVelocity.y, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_startVelocity.z, bytes, ref index); ExitGames.Client.Photon.Protocol.Serialize(bombInfo.m_bombID, bytes, ref index); return(bytes); }
protected override void CaulcElimList() { FindMvpCells (); if (_mvpCellList.Count > 0) { float fishDely = GameConfig.Instance.GetTime(TimeConf.fishDelay); float combinTime = GameConfig.Instance.GetTime(TimeConf.combinTriggerDelay); for(int i = 0 ;i < _mvpCellList.Count && i < _fishNum;i ++) { var tarRow = _mvpCellList[i].Row; var tarCol = _mvpCellList[i].Col; var curInfo = new BombInfo(_triggerModel,fishDely + i * combinTime,tarRow,tarCol,BombCmd.Elim); _elimInfoList.Add (curInfo); } } }
/// <summary> /// Set all hexagon element values to the hexagon gameobject components and activate gameobject. /// </summary> /// <param name="itemComponents"></param> /// <param name="toPosition"></param> /// <param name="matchType"></param> /// <param name="bombInfo"></param> private void SetNewType(ItemComponents itemComponents, Vector2 toPosition, MatchType matchType, BombInfo bombInfo = new BombInfo()) { itemComponents.explode.StopAllCoroutines(); itemComponents.touch.matchType = matchType; itemComponents.move.SetTransform(positionCalculator.CoordToAnchored(toPosition)); if (bombInfo.hasBomb) { Debug.Log("One bomb is dropped to the board!"); } SetUIValues(itemComponents, matchType, bombInfo); itemComponents.gameObject.SetActive(true); }
void StartClient(bool send) { while (!searching) { } try { IPHostEntry ipHostInfo = Dns.GetHostEntry("localhost"); IPAddress ipAddress = ipHostInfo.AddressList[0]; IPEndPoint remoteEP = new IPEndPoint(ipAddress, 8080); // Create a TCP/IP socket. Socket client = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); // Connect to the remote endpoint. client.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), client); connectDone.WaitOne(); if (send) { var serial = Console.ReadLine(); string info; if (clientinfo.Serial == serial && clientinfo.Stage < 4) { clientinfo.Stage++; } else { clientinfo = new BombInfo { ID = client.Handle.ToInt32(), Serial = serial, Stage = 1 }; } info = JsonConvert.SerializeObject(clientinfo, Formatting.Indented); Send(client, info + "<EOF>", false); sendDone.WaitOne(); } else { Send(client, clientinfo.ID.ToString(), false); sendDone.WaitOne(); Receive(client); receiveDone.WaitOne(); Console.WriteLine("Client: Response received: {0}", response); if (response != error) { clientinfo = JsonConvert.DeserializeObject <BombInfo>(response); if (clientinfo.Stage == 4) { clientinfo = new BombInfo { ID = -1, Serial = "PD82E7", Stage = 1 } } ; } } client.Shutdown(SocketShutdown.Both); client.Close(); response = string.Empty; connectDone.Reset(); sendDone.Reset(); receiveDone.Reset(); Console.WriteLine("Client: Socket closed."); } catch (Exception e) { Console.WriteLine("Client: " + e.ToString()); } }
public void SetBombInfo(BombInfo aBombInfo) { m_bombInfo = aBombInfo; m_bombInfo.gameObject = this.gameObject; /* string teamBombPath = ""; if (BombersPlayerController.GetPlayer(m_bombInfo.m_shooter).m_team == 1) { teamBombPath = "Bomb01"; } else { teamBombPath = "Bomb02"; } */ //GameObject graphic = (GameObject)Instantiate((GameObject)Resources.Load(teamBombPath), transform.position, transform.rotation); //graphic.transform.parent = transform; }
protected void BombCellsWithDir(int offsetRow,int offsetCol,float delayTime = 0f,int distance = 100) { int curRow = _curRow + offsetRow; int curCol = _curCol + offsetCol; int curDistance = 0; while (IsInBorder(curRow,curCol) && curDistance < distance) { BombInfo curInfo = new BombInfo(_triggerModel,delayTime *curDistance,curRow,curCol,BombCmd.Elim); _elimInfoList.Add(curInfo); curRow += offsetRow; curCol += offsetCol; curDistance +=1; } }
public HexagonElement(MatchType matchType, BombInfo bombInfo = new BombInfo()) { this.matchType = matchType; this.bombInfo = bombInfo; }
public override void setBombData(BombInfo bombInfo) { base.setBombData(bombInfo); signRadius = baseBomb.signRadius; }
protected override void CaulcElimList() { float dyeDelay = GameConfig.Instance.GetTime (TimeConf.dyeDelay); var dyeList = new List<BombInfo> (); var curLvCtrl = LevelCtrl.Current; for (int curRow = _minRow; curRow < _maxRow; curRow++) { for(int curCol = _minCol; curCol < _maxCol ; curCol++) { CellCtrl curCell = curLvCtrl[curRow,curCol]; if(curCell!= null && curCell != _triggerModel && curCell.IsEliminateable && !curCell.MatchEliminateColor(_dyeColor)) { var curInfo = new BombInfo(_triggerModel,dyeDelay,curRow,curCol,BombCmd.Dye); curInfo._formColor = _dyeColor; dyeList.Add(curInfo); } } } }
public virtual void setBombData(BombInfo bombInfo) { type = bombInfo.type; initPosition = bombInfo.initPosition.GetV3(); initAngle = bombInfo.initAngle; isLocked = bombInfo.isLocked; timeout = bombInfo.timeout; switch (type) { case Constants.BombTypes.normal: baseBomb = new BaseNormalBomb(); break; case Constants.BombTypes.shooter: baseBomb = new BaseShooterBomb(); break; case Constants.BombTypes.target: baseBomb = new BaseTargetBomb(); break; case Constants.BombTypes.wave: baseBomb = new BaseWaveBomb(); break; case Constants.BombTypes.acid: baseBomb = new BaseAcidBomb(); break; } radius = baseBomb.radius; speed = baseBomb.speed; numPoints = baseBomb.numPoints; bulletDamage = baseBomb.bulletDamage; bulletHealth = baseBomb.bulletHealth; health = baseBomb.health; currentHealth = baseBomb.currentHealth; valueInCoin = baseBomb.valueInCoin; intervalCounter = 0; if (isLocked) { locked.SetActive(true); } else { locked.SetActive(false); } if (timeout > 0) { timer.gameObject.SetActive(true); } else { timer.gameObject.SetActive(false); } if (bombInfo.movement == null || bombInfo.movement.speed <= 0) { GetComponent <BombMovement>().enabled = false; } else { GetComponent <BombMovement>().enabled = true; GetComponent <BombMovement>().SetMovementData(bombInfo.movement); } if (bombInfo.rotate == null || bombInfo.rotate.speed <= 0) { GetComponent <BombRotate>().enabled = false; } else { GetComponent <BombRotate>().enabled = true; GetComponent <BombRotate>().SetRotateData(bombInfo.rotate); } }
/*IEnumerator Counter() * { * while (true) * { * yield return new WaitUntil(() => startTimer); * DebugLog("Blah"); * timer = false; * yield return new WaitForSeconds(6); * DebugLog("Blah2"); * timer = true; * startTimer = false; * } * }*/ void StartClient(bool send) { if (!available || !active) { return; } available = false; try { // Create a TCP/IP socket. client = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); // Connect to the remote endpoint. client.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), client); connectDone.WaitOne(6000); if (!connected) { return; } if (send) { string info; if (clientInfo != null && clientInfo.Serial == Info.GetSerialNumber() && clientInfo.Stage < 4) { clientInfo.Stage++; } else { clientInfo = new BombInfo { ID = client.Handle.ToInt32(), Serial = Info.GetSerialNumber(), Stage = 1 }; } info = JsonConvert.SerializeObject(clientInfo, Formatting.Indented); currentSend = info; Send(client, info + "<EOF>"); sendDone.WaitOne(6000); } else { if (clientInfo == null) { DebugLog(true, "There was an error in the connection. Sending again may fix this issue."); ResetConnection(); return; } currentSend = string.Empty; Send(client, clientInfo.ID.ToString()); sendDone.WaitOne(6000); Receive(client); receiveDone.WaitOne(6000); DebugLog(true, "Response received: {0}", response); if (response != error) { clientInfo = JsonConvert.DeserializeObject <BombInfo>(response); if (clientInfo.Stage == 4) { Module.HandlePass(); } } } response = string.Empty; ResetConnection(); DebugLog(false, "Socket closed."); } catch (Exception e) { if (e is SocketException) { DebugLog(true, "Connection lost."); DebugLog(false, e.Message); } else if (e is NullReferenceException) { DebugLog(true, "NullReferenceException detected - it is likely the server did not respond with a proper message."); DebugLog(false, e.Message); } else { DebugLog(true, e.Message); } ResetConnection(); } }
protected override void CaulcElimList() { FindMvpCells (); if (_mvpCellList.Count > 0) { float fishDely = GameConfig.Instance.GetTime(TimeConf.fishDelay); var tarRow = _mvpCellList[0].Row; var tarCol = _mvpCellList[0].Col; var curInfo = new BombInfo(_triggerModel,fishDely,tarRow,tarCol,BombCmd.Elim); _elimInfoList.Add (curInfo); } }