public SC2APIProtocol.Action BuildSupply(Unit cc) { if (!coolDownCommand.IsDelayed("BuildSupply")) { coolDownCommand.Add(new CoolDownCommandData() { key = "BuildSupply", finishStep = gameLoop + 10 }); SC2APIProtocol.Action answer = CreateAction(cc, ABILITY_ID.BUILD_SUPPLYDEPOT); List <Point2D> poses = FindPlaceables((int)cc.Pos.X, (int)cc.Pos.Y, 10, UNIT_TYPEID.TERRAN_SUPPLYDEPOT, true); if (poses.Count > 0) { ScoreDatas scores = new ScoreDatas(); foreach (Point2D p in poses) { float dist = cc.Pos.Dist(p.X, p.Y); scores.Add(new ScoreData { data = p, score = dist }); } scores.Sort(); scores.Reverse(); //Point2D pos = FindPlaceable((int)cc.Pos.X, (int)cc.Pos.Y, 10,UNIT_TYPEID.TERRAN_SUPPLYDEPOT,true); Point2D pos = (Point2D)scores[0].data; if (pos != null) { logDebug("BuildSupply at " + pos.ToString()); answer.ActionRaw.UnitCommand.TargetWorldSpacePos = pos; return(answer); } } } return(null); }
private void LoadScoreFile() { ScoreDatas data = null; using (FileStream SourceStream = File.Open(_scoreFilePath, FileMode.OpenOrCreate)) { if (new FileInfo(_scoreFilePath).Length != 0) { data = JsonSerializer.Deserialize <ScoreDatas>(SourceStream); } } for (int i = 0; i < _scores.Length; ++i) { if (data != null && data.ScoreData.Length > i) { _scores[i] = new ScoreData(data.ScoreData[i]); } else { _scores[i] = new ScoreData("Scrub Lord", 0); } } LoadUIText(-1); }
private void SaveScoreFile() { using (FileStream SourceStream = File.Open(_scoreFilePath, FileMode.Open)) { ScoreDatas data = new ScoreDatas(_scores); JsonSerializer.Serialize(SourceStream, data); } }
public void FollowScoreOf(IPlatformer2DUserControl control, HPScript hpScript) { CurrentScores.Add(new PlayerScoreTracker { CurrentScore = 0, Player = control.m_PlayerData }); var data = new ScoreData() { HpScript = hpScript, Platformer2DUserControl = control }; data.HpScript.Dead += HpScript_Dead; ScoreDatas.Add(data); }
void RegisterEntries(ScoreDatas scores) { for (var i = 0; i < scores.results.Count; i++) { var data = scores.results[i]; var entryObj = Instantiate(entryPrefab, entries.transform); var entry = entryObj.GetComponent <RankingEntry>(); entry.SetRecord(i + 1, data); if (data.objectId == slave.MyObjectId) { entry.ChangeTextColor(); } } }
private void HpScript_Dead(object sender, EventArgs e) { var hpScriptReceived = (HPScript)sender; var checkInList = ScoreDatas.SingleOrDefault(c => c.HpScript.GetInstanceID() == hpScriptReceived.GetInstanceID()); if (checkInList != null) { ScoreDatas.Remove(checkInList); } if (_isAnounceWinnerRunning) { StopCoroutine(_anounceWinner); _isAnounceWinnerRunning = false; } _anounceWinner = AnounceWinner(); StartCoroutine(_anounceWinner); }
public IEnumerator GetScoreList(int num, UnityAction <ScoreDatas> callback) { Debug.Log("Get Data"); NCMBDataStoreParamSet paramSet = new NCMBDataStoreParamSet(); paramSet.Limit = num; paramSet.SortColumn = "landingTime"; IEnumerator coroutine = ncmbRestController.Call(NCMBRestController.RequestType.GET, "classes/" + DATASTORE_CLASSNAME, paramSet); yield return(StartCoroutine(coroutine)); string jsonStr = (string)coroutine.Current; //取得したjsonをScoreDatasとして展開// ScoreDatas scores = JsonUtility.FromJson <ScoreDatas>(jsonStr); if (scores.results.Count == 0) { Debug.Log("no data"); } callback(scores); }
private IEnumerator AnounceWinner() { if (ScoreDatas.Count <= 1) { yield return(new WaitForSeconds(_delayToCheckIfDraw)); //Check if we have a single player left if (ScoreDatas.Count == 1) { //Clear and fire event var possibleWinner = ScoreDatas.Single(); ScoreDatas.Clear(); OnPlayerScored(possibleWinner.GetEventArgs()); } else { //Nobody in the round - it is a draw OnPlayerScored(new PlayerScoreEventArgs() { IsThereAWinner = false, }); } } }