public TTsk this[int x, int y] { get { TTsk tsk = new TTsk(); if (!outBound(x, y)) { ushort temp = fLaby.laby[y][x]; byte first = (byte)(temp & 0xF); if ((first > 0) && (first < 4)) { tsk.Data = (ushort)(temp >> 4); } } return(tsk); } set { if (outBound(x, y)) { return; } fLaby.laby[y][x] = (ushort)((fLaby.laby[y][x] & 0xF) | (value.Data << 4)); fLaby.PillUpdated(this, x, y); } }
public TTsk pointGetVal() { TTsk tsk = new TTsk(); pointNew = true; for (; ;) { if (tskSelector.skip.isAllSkipped()) { tsk.tskNo = 0; //not found tsk.chr = 0; return(tsk); } tsk.tskNo = (byte)tskSelector.getValNo(); if (tskSelector[tsk.tskNo].skip.isAllSkipped()) { tskSelector.skip[tsk.tskNo] = true; } else { tsk.chr = (byte)tskSelector[tsk.tskNo].getValNo(); return(tsk); } } }
public void tskGood(TTsk tsk, bool speedOk) { if (speedOk) { tskSelector[tsk.tskNo].freq[tsk.chr]--; } else { tskSelector[tsk.tskNo].freq[tsk.chr] += 0.25; } }
void clearChar(int xx, int yy) { TTsk tsk = new TTsk(); tsk.tskNo = 0; tsk.chr = 0; if (fLab.chars[xx, yy].isPill()) { fLab.chars[xx, yy] = tsk; } }
private bool chkKey(TTsk keyTsk, bool speedOk, int x, int y) { TTsk labTsk = CurrentLabyrinth.chars[x, y]; if (labTsk == keyTsk) { UIElement pill; _pillCoord.TryGetValue(new Point(x, y), out pill); _Pacman.xyList.add(new TPillPoint(x, y, pill)); taskBox.tskProvider.tskGood(keyTsk, speedOk); return(true); } return(false); }
public TTsk encodeTask(char key) { TTsk res = new TTsk(); int keyInd; for (ushort i = 1; i < tskSelector.count; i++) { if ((keyInd = tskSelector[i].charIndex(key)) >= 0) { if (keyInd >= tskSelector[i].count) { break; //New that is wrong for now } res.tskNo = (byte)i; res.chr = (byte)keyInd; break; } } return(res); }
public double this[int index] { get { return(fFreq[index]); } set { if (value < 0) { value = 0; } freqList.Remove(fFreq[index]); fFreq[index] = value; freqList.Add(value); if (parentCharFreqList != null) { TTsk tsk = new TTsk(); tsk.tskNo = (byte)tskNo; tsk.chr = (byte)index; parentCharFreqList[tsk.Data] = fFreq[index]; } } }
public GameRecord(int _tim, TTsk _tsk) { tim = _tim; tsk = _tsk; isKey = false; }
bool intProcessKey(TTsk keyTsk) { bool speedOk = true; if (lastKeyTurn > 0) { Double speed; if (lastKeyTurn == turn) { speed = lastSpeed + lastMomentSpeed; } else { speed = 1000.0 * 60 / SleepTime / (turn - lastKeyTurn); lastMomentSpeed = speed; } lastSpeed = speed; if (speed > fUserTypeSpeed) { userTypeSpeed = Config.FilterSpeedUp * speed + (1 - Config.FilterSpeedUp) * fUserTypeSpeed; userMinTypeSpeed = Config.FilterAvgSpeedUp * speed + (1 - Config.FilterAvgSpeedUp) * fUserMinTypeSpeed; } else { userTypeSpeed = Config.FilterSpeedDown * speed + (1 - Config.FilterSpeedDown) * fUserTypeSpeed; userMinTypeSpeed = Config.FilterAvgSpeedDown * speed + (1 - Config.FilterAvgSpeedDown) * fUserMinTypeSpeed; } speedOk = (speed > userMinTypeSpeed); } lastKeyTurn = turn; UInt16 x, y; if (keyTsk.tskNo < 1) { return(false); } if (_Pacman == null) { return(false); } TPillPoint xy = _Pacman.xyList.head; x = xy.x; y = xy.y; foreach (TXYDir dir in xyDirs) { dir.x = x; dir.y = y; dir.skip = false; } int dirCnt = xyDirs.Length; do { foreach (TXYDir xyDir in xyDirs) { if (xyDir.skip) { continue; } Labyrinth.translate(ref xyDir.x, ref xyDir.y, xyDir.dir); if (!Labyrinth.outBound(xyDir.x, xyDir.y)) { if (CurrentLabyrinth.laby[xyDir.y][xyDir.x] == 0) { foreach (Direction dir in Direction.directions) { if (dir.Opposite == xyDir.dir) { continue; } if (dir == xyDir.dir) { continue; } int xx = xyDir.x; int yy = xyDir.y; Labyrinth.translate(ref xx, ref yy, dir); if (chkKey(keyTsk, speedOk, xx, yy)) { return(true); } } continue; } else { if (chkKey(keyTsk, speedOk, xyDir.x, xyDir.y)) { double halfSpeed = userMinTypeSpeed / 2; Audio.PlayGoodPill(Math.Max(Math.Min((userTypeSpeed - halfSpeed) / halfSpeed, 1), 0)); return(true); } } } dirCnt--; xyDir.skip = true; } } while (dirCnt > 0); taskBox.tskProvider.tskBad(keyTsk); if (Audio != null) { Audio.PlayWrongPill(); } return(false); }
public void processKey(TTsk keyTsk) { _cfg.play.Add(new GameRecord(oturn + 1, keyTsk)); }
public void pointSet(int x, int y) { tskSelector.only.Clear(); tskSelector.skip.clear(); for (int i = 1; i < tskSelector.count; i++) { tskSelector[i].skip.clear(); } foreach (XY xy in pointDirList) { int x1 = x, y1 = y, len = 0, newTsk = 0, tskNo = 0; for (; ;) { x1 += xy.x; y1 += xy.y; if (lab.chars[x1, y1].isPill()) { TTsk ch = lab.chars[x1, y1]; newTsk = ch.tskNo; if (newTsk == 0) { break; } if (len != 0) { if (tskNo != newTsk) { break; } } else { tskNo = newTsk; } len++; } else { break; } } if (tskNo > 0) { TTskRandom task = tskSelector[tskNo]; if ((task.isAlone) || (len > task.maxLen)) { tskSelector.skip[tskNo] = true; tskSelector.only.Remove(tskNo); } else { if ((len < task.minLen) && (task.count > 4) && (!tskSelector.skip[tskNo])) { tskSelector.only.Add(tskNo); } } } } #if DEBUG for (int i = 1; i < tskSelector.count; i++) { if (!tskSelector.skip[i] && tskSelector[i].isAlone) { if (check(x - 1, y, i) || check(x - 1, y, i) || check(x - 1, y, i) || check(x - 1, y, i)) { throw new Exception("pointSet"); } } } #endif }
public void tskBad(TTsk tsk) { tskSelector[tsk.tskNo].freq[tsk.chr] += 2; }