public void CurrentFrameTest2() { var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { FrameID = 0 }; unitInfo.SetUnitFrame(unitFrame); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }
public void ComparisonTest3() { var frame1 = new UnitFrame(); var frame2 = new UnitFrame(); Assert.IsTrue(frame1.Equals(frame2)); Assert.IsTrue(frame1.CompareTo(frame2) == 0); }
public void CurrentFrameTest4() { var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { FrameID = -1 }; unitInfo.SetUnitFrame(unitFrame); Assert.IsNull(unitInfo.CurrentFrame); }
public void ComparisonTest5() { var frame1 = new UnitFrame(); var frame2 = new UnitFrame { FrameID = 1 }; Assert.IsFalse(frame1.Equals(frame2)); Assert.IsTrue(frame1.CompareTo(frame2) < 0); }
public void ComparisonTest12() { var frame1 = new UnitFrame { FrameDuration = TimeSpan.FromMinutes(2) }; var frame2 = new UnitFrame { FrameDuration = TimeSpan.FromMinutes(1) }; Assert.IsFalse(frame1.Equals(frame2)); Assert.IsTrue(frame1.CompareTo(frame2) > 0); }
public void ComparisonTest13() { var frame1 = new UnitFrame(); Assert.IsFalse(frame1.Equals(null)); Assert.IsTrue(frame1.CompareTo(null) > 0); }
void Update() { UnitFrame?.Move(this); if (false && UnitFrame.NextMove?.MoveType == MoveType.Add) { Position FinalDestination = UnitFrame.NextMove.Positions[UnitFrame.NextMove.Positions.Count - 1]; HexCell targetCell = UnitFrame.HexGrid.GroundCells[FinalDestination]; Vector3 unitPos3 = targetCell.Cell.transform.localPosition; unitPos3.y += UnitFrame.HexGrid.hexCellHeight + AboveGround; transform.position = Vector3.MoveTowards(transform.position, unitPos3, 1); } else if (UnitFrame.NextMove?.MoveType == MoveType.Move || UnitFrame.NextMove?.MoveType == MoveType.Add) { Position FinalDestination = UnitFrame.NextMove.Positions[UnitFrame.NextMove.Positions.Count - 1]; HexCell targetCell = UnitFrame.HexGrid.GroundCells[FinalDestination]; Vector3 unitPos3 = targetCell.Cell.transform.localPosition; unitPos3.y += UnitFrame.HexGrid.hexCellHeight + AboveGround; if (UnitFrame.NextMove.Positions.Count > 0) { float speed = 1.75f / UnitFrame.HexGrid.GameSpeed; float step = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, unitPos3, step); UpdateDirection(unitPos3); } else { transform.position = Vector3.MoveTowards(transform.position, unitPos3, 1); } } }
public void Initialize() { slider = transform.GetComponent <Slider>(); lastValue = int.MinValue; UnitFrame = gameObject.transform.GetComponentInParent <UnitFrame>(); ValueChanged += OnValueChanged; }
public void UnitInfo_CurrentFrame_Test3() { // Arrange var unitInfo = new UnitInfo(); var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 0 } }; var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 1 } }; var unitFrame5 = new UnitFrame { FrameID = 5 }; var logLine5 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame5 }; unitInfo.LogLines = new List <LogLine>(new[] { logLine0, logLine1, logLine5 }); // Act & Assert Assert.AreSame(unitFrame5, unitInfo.CurrentFrame); }
public void ComparisonTest2() { var frame1 = new UnitFrame(); var frame2 = new object(); // calls Object.Equals() override Assert.AreNotEqual(frame1, frame2); }
void CreateUnit(Move move) { UnitFrame unit = new UnitFrame(); unit.HexGrid = this; unit.NextMove = move; unit.playerId = move.PlayerId; unit.MoveUpdateStats = move.Stats; unit.UnitId = move.UnitId; if (move.Stats.EngineLevel == 0) { // Cannot move to targetpos unit.currentPos = move.Positions[move.Positions.Count - 1]; } else { // Move to targetpos unit.currentPos = move.Positions[0]; } unit.Assemble(); Units.Add(move.UnitId, unit); /* * Text label = Instantiate<Text>(cellLabelPrefab); * label.rectTransform.SetParent(gridCanvas.transform, false); * label.rectTransform.anchoredPosition = new Vector2(unitPos3.x, unitPos3.z); * label.text = "\r\n" + move.UnitId;*/ }
public void HashCodeTest2() { var frame = new UnitFrame { FrameID = 89, TimeOfFrame = TimeSpan.FromHours(5), FrameDuration = TimeSpan.FromMinutes(4) }; Assert.AreEqual(1742409840, frame.GetHashCode()); }
public void ComparisonTest14() { var frame1 = new UnitFrame(); var frame2 = new UnitFrame(); Assert.IsTrue(frame1 == frame2); Assert.IsFalse(frame1 != frame2); Assert.IsFalse(frame1 < frame2); Assert.IsFalse(frame1 > frame2); }
public static void SetUnitFrame(this UnitInfo unitInfo, UnitFrame unitFrame) { var logLines = unitInfo.LogLines ?? new List <LogLine>(); logLines.Add(new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }); unitInfo.LogLines = logLines; }
public void ComparisonTest17() { var frame1 = new UnitFrame(); Assert.IsFalse(frame1 == null); Assert.IsTrue(frame1 != null); Assert.IsFalse(frame1 < null); Assert.IsTrue(frame1 > null); }
public void ComparisonTest18() { var frame1 = new UnitFrame(); Assert.IsFalse(null == frame1); Assert.IsTrue(null != frame1); Assert.IsTrue(null < frame1); Assert.IsFalse(null > frame1); }
public void UnitInfo_CurrentFrame_Test2() { // Arrange var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { FrameID = 0 }; var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }; unitInfo.LogLines = new List<LogLine>(new[] { logLine }); // Act & Assert Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }
internal virtual object GetLineData(LogLine logLine) { switch (logLine.LineType) { case LogLineType.WorkUnitProject: Match projectIdMatch; if ((projectIdMatch = ProjectIDRegex.Match(logLine.LineRaw)).Success) { return(projectIdMatch); } return(new LogLineError(String.Format("Failed to parse Project (R/C/G) values from '{0}'", logLine.LineRaw))); case LogLineType.WorkUnitCoreVersion: Match coreVersionMatch; if ((coreVersionMatch = CoreVersionRegex.Match(logLine.LineRaw)).Success) { float value; if (Single.TryParse(coreVersionMatch.Result("${CoreVer}").Trim(), NumberStyles.Number, CultureInfo.InvariantCulture, out value)) { return(value); } return(new LogLineError(String.Format("Failed to parse Core Version value from '{0}'", logLine.LineRaw))); } // return null here because a derived parser may also parse these lines // if we were to return LogLineError the line would be marked as an error // line and we don't want that (see LogLineParserLegacy). return(null); case LogLineType.WorkUnitFrame: UnitFrame frame = GetUnitFrame(logLine); if (frame != null) { return(frame); } frame = GetGpuUnitFrame(logLine); if (frame != null) { return(frame); } return(new LogLineError(String.Format("Failed to parse Frame Data from '{0}'", logLine.LineRaw))); case LogLineType.WorkUnitCoreShutdown: Match coreShutdownMatch; if ((coreShutdownMatch = CoreShutdownRegex.Match(logLine.LineRaw)).Success) { // remove any carriage returns from fahclient log lines - 12/30/11 string unitResultValue = coreShutdownMatch.Result("${UnitResult}").Replace("\r", String.Empty); return(unitResultValue.ToWorkUnitResult()); } return(new LogLineError(String.Format("Failed to parse Work Unit Result value from '{0}'", logLine.LineRaw))); } return(null); }
public void ComparisonTest6() { var frame1 = new UnitFrame { FrameID = 1, TimeOfFrame = TimeSpan.FromMinutes(5), FrameDuration = TimeSpan.FromMinutes(5) }; var frame2 = new UnitFrame { FrameID = 1, TimeOfFrame = TimeSpan.FromMinutes(5), FrameDuration = TimeSpan.FromMinutes(5) }; Assert.IsTrue(frame1.Equals(frame2)); Assert.IsTrue(frame1.CompareTo(frame2) == 0); }
public void UnitInfo_CurrentFrame_Test3() { // Arrange var unitInfo = new UnitInfo(); var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 0 } }; var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 1 } }; var unitFrame5 = new UnitFrame { FrameID = 5 }; var logLine5 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame5 }; unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1, logLine5 }); // Act & Assert Assert.AreSame(unitFrame5, unitInfo.CurrentFrame); }
public void ComparisonTest9() { var frame1 = new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(1) }; var frame2 = new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(2) }; Assert.IsFalse(frame1.Equals(frame2)); Assert.IsTrue(frame1.CompareTo(frame2) < 0); }
public TeamFrame(List<Unit> units) { this.units = units; frame = new MovieClip ("Flash GUI/game_gui.swf:team_frame"); foreach(Unit unit in units){ UnitFrame unit_frame = new UnitFrame(unit); unitFrames.Add(unit_frame); } PopulateFrame(); }
// Update is called once per frame void Update() { UnitFrame?.Move(this); if (UnitFrame?.NextMove?.MoveType == MoveType.Upgrade) { if (UnitFrame.NextMove?.MoveType == MoveType.Upgrade && UnitFrame.NextMove?.Stats != null) { UnitFrame.MoveUpdateStats = UnitFrame.NextMove.Stats; UnitFrame.Assemble(); } if (particleSource == null) { Position from = UnitFrame.NextMove.Positions[0]; HexCell sourceCell = UnitFrame.HexGrid.GroundCells[from]; particleSource = UnitFrame.HexGrid.MakeParticleSource("ExtractSource"); particleSource.transform.SetParent(sourceCell.Cell.transform, false); } Position to = UnitFrame.NextMove.Positions[UnitFrame.NextMove.Positions.Count - 1]; HexCell targetCell = UnitFrame.HexGrid.GroundCells[to]; ParticleSystemForceField particleTarget = UnitFrame.HexGrid.MakeParticleTarget(); particleTarget.transform.SetParent(targetCell.Cell.transform, false); Vector3 unitPos3 = particleTarget.transform.position; unitPos3.y += 0.1f; particleTarget.transform.position = unitPos3; particleSource.externalForces.SetInfluence(0, particleTarget); HexGrid.Destroy(particleTarget, 2.5f); particleSource.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); var main = particleSource.main; main.duration = particleSource.main.duration * UnitFrame.HexGrid.GameSpeed; //particleSource.main.duration = particleSource.main.duration * UnitFrame.HexGrid.GameSpeed; particleSource.Play(); ParticleSystem particleDust = UnitFrame.HexGrid.MakeParticleSource("Build"); particleDust.transform.SetParent(targetCell.Cell.transform, false); particleDust.transform.position = particleTarget.transform.position; particleDust.Play(); HexGrid.Destroy(particleDust, 2.5f); UnitFrame.NextMove = null; } }
// Use this for initialization void Start() { Calculate(); hp = maxHP; if (GetComponent <PlayerCharacter>() != null) { isPlayer = true; } else { unitFrame = GetComponentInChildren <UnitFrame>(); } }
public void UnitInfo_CurrentFrame_Test2() { // Arrange var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { FrameID = 0 }; var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }; unitInfo.LogLines = new List <LogLine>(new[] { logLine }); // Act & Assert Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }
internal static UnitFrame ParseWorkUnitFrame(LogLine logLine) { UnitFrame frame = GetUnitFrame(logLine); if (frame != null) { return(frame); } frame = GetGpuUnitFrame(logLine); if (frame != null) { return(frame); } return(null); }
private void StorageList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (StorageList.SelectedIndex >= 0) { if (_unitTestPage == null) { _unitTestPage = new UnitTest(); _unitTestPage.SetUnitToTest((ITestingUnit)StorageList.SelectedItem); UnitFrame.Navigate(_unitTestPage); } else { _unitTestPage.SetUnitToTest((ITestingUnit)StorageList.SelectedItem); } } }
public void UnitInfo_SetUnitFrameDataFromLogLines_Test3() { // this tests GetDelta() rollover functionality // Arrange var unitInfo = new UnitInfo(); var unitFrame0 = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0, TimeOfFrame = new TimeSpan(23, 55, 0), FrameDuration = new TimeSpan(0, 0, 0) }; var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame0 }; // Act unitInfo.LogLines = new List <LogLine>(new[] { logLine0 }); // Assert 0 - no duration - first frame Assert.AreEqual(new TimeSpan(0, 0, 0), unitInfo.CurrentFrame.FrameDuration); var unitFrame1 = new UnitFrame { RawFramesComplete = 1000, RawFramesTotal = 100000, FrameID = 1, TimeOfFrame = new TimeSpan(0, 5, 0), FrameDuration = new TimeSpan(0, 0, 0) }; var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame1 }; // Act unitInfo.LogLines = new List <LogLine>(new[] { logLine0, logLine1 }); // Assert 1 - now we get a frame duration Assert.AreEqual(new TimeSpan(0, 10, 0), unitInfo.CurrentFrame.FrameDuration); }
private static UnitFrame GetGpuUnitFrame(LogLine logLine) { Debug.Assert(logLine != null); Match framesCompletedGpu = FahLogRegex.Common.FramesCompletedGpuRegex.Match(logLine.LineRaw); if (framesCompletedGpu.Success) { var frame = new UnitFrame(); frame.RawFramesComplete = Int32.Parse(framesCompletedGpu.Result("${Percent}")); frame.RawFramesTotal = 100; //Instance.CurrentProtein.Frames // I get this from the project data but what's the point. 100% is 100%. frame.TimeOfFrame = ParseTimeStamp(logLine); frame.FrameID = frame.RawFramesComplete; return(frame); } return(null); }
public void UnitInfo_SetUnitFrameDataFromLogLines_Test1() { // Arrange var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0 }; var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }; // Act unitInfo.LogLines = new List <LogLine>(new[] { logLine }); // Assert Assert.AreEqual(0, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(1, unitInfo.UnitFrames.Count); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }
private bool UpdateFrames(UnitInfo unit, int startingFrame, int endingFrame, ProteinBenchmark benchmark) { bool result = false; for (int i = startingFrame; i <= endingFrame; i++) { UnitFrame frame = unit.GetUnitFrame(i); if (frame != null) { if (benchmark.SetFrameTime(frame.FrameDuration)) { result = true; } } else { Logger.DebugFormat("({0}) FrameID '{1}' not found for Project {2}", unit.OwningSlotName, i, unit.ProjectID); } } return(result); }
public void UnitInfo_SetUnitFrameDataFromLogLines_Test2() { // Arrange var unitInfo = new UnitInfo(); var unitFrame0 = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0 }; var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame0 }; // Act unitInfo.LogLines = new List<LogLine>(new[] { logLine0 }); // Assert 0 Assert.AreEqual(0, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(1, unitInfo.UnitFrames.Count); Assert.AreSame(unitFrame0, unitInfo.CurrentFrame); // no duration - first frame Assert.AreEqual(new TimeSpan(0, 0, 0), unitInfo.CurrentFrame.FrameDuration); var unitFrame1 = new UnitFrame { RawFramesComplete = 1000, RawFramesTotal = 100000, FrameID = 1, TimeOfFrame = new TimeSpan(0, 5, 0) }; var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame1 }; // Act unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1 }); // Assert 1 Assert.AreEqual(1000, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(2, unitInfo.UnitFrames.Count); Assert.AreSame(unitFrame1, unitInfo.CurrentFrame); Assert.AreEqual(new TimeSpan(0, 5, 0), unitInfo.CurrentFrame.FrameDuration); var unitFrame2 = new UnitFrame { RawFramesComplete = 2000, RawFramesTotal = 100000, FrameID = 2, TimeOfFrame = new TimeSpan(0, 10, 0) }; var logLine2 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame2 }; // Act unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1, logLine2 }); // Assert 2 Assert.AreEqual(2000, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(3, unitInfo.UnitFrames.Count); Assert.AreSame(unitFrame2, unitInfo.CurrentFrame); Assert.AreEqual(new TimeSpan(0, 5, 0), unitInfo.CurrentFrame.FrameDuration); }
public void SetCurrentFrameTest2() { var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0, TimeOfFrame = new TimeSpan(0, 0, 0), FrameDuration = new TimeSpan(0, 0, 0) }; unitInfo.SetUnitFrame(unitFrame); Assert.AreEqual(0, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(1, unitInfo.FrameCount); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); // no duration - first frame Assert.AreEqual(new TimeSpan(0, 0, 0), unitInfo.CurrentFrame.FrameDuration); unitFrame = new UnitFrame { RawFramesComplete = 1000, RawFramesTotal = 100000, FrameID = 1, TimeOfFrame = new TimeSpan(0, 5, 0), FrameDuration = new TimeSpan(0, 0, 0) }; unitInfo.SetUnitFrame(unitFrame); Assert.AreEqual(1000, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(2, unitInfo.FrameCount); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); // still no duration - unitInfo.FramesObserved must be > 1 Assert.AreEqual(new TimeSpan(0, 0, 0), unitInfo.CurrentFrame.FrameDuration); unitFrame = new UnitFrame { RawFramesComplete = 2000, RawFramesTotal = 100000, FrameID = 2, TimeOfFrame = new TimeSpan(0, 10, 0), FrameDuration = new TimeSpan(0, 0, 0) }; // set observed count unitInfo.FramesObserved = 2; unitInfo.SetUnitFrame(unitFrame); Assert.AreEqual(2000, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(3, unitInfo.FrameCount); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); // now we get a frame duration Assert.AreEqual(new TimeSpan(0, 5, 0), unitInfo.CurrentFrame.FrameDuration); }
public static void SetUnitFrame(this UnitInfo unitInfo, UnitFrame unitFrame) { var logLines = unitInfo.LogLines ?? new List<LogLine>(); logLines.Add(new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }); unitInfo.LogLines = logLines; }
private static UnitFrame GetGpuUnitFrame(LogLine logLine) { Debug.Assert(logLine != null); Match framesCompletedGpu = FahLogRegex.Common.FramesCompletedGpuRegex.Match(logLine.LineRaw); if (framesCompletedGpu.Success) { var frame = new UnitFrame(); frame.RawFramesComplete = Int32.Parse(framesCompletedGpu.Result("${Percent}")); frame.RawFramesTotal = 100; //Instance.CurrentProtein.Frames // I get this from the project data but what's the point. 100% is 100%. frame.TimeOfFrame = ParseTimeStamp(logLine); frame.FrameID = frame.RawFramesComplete; return frame; } return null; }
public void UnitInfo_SetUnitFrameDataFromLogLines_Test3() { // this tests GetDelta() rollover functionality // Arrange var unitInfo = new UnitInfo(); var unitFrame0 = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0, TimeOfFrame = new TimeSpan(23, 55, 0), FrameDuration = new TimeSpan(0, 0, 0) }; var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame0 }; // Act unitInfo.LogLines = new List<LogLine>(new[] { logLine0 }); // Assert 0 - no duration - first frame Assert.AreEqual(new TimeSpan(0, 0, 0), unitInfo.CurrentFrame.FrameDuration); var unitFrame1 = new UnitFrame { RawFramesComplete = 1000, RawFramesTotal = 100000, FrameID = 1, TimeOfFrame = new TimeSpan(0, 5, 0), FrameDuration = new TimeSpan(0, 0, 0) }; var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame1 }; // Act unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1 }); // Assert 1 - now we get a frame duration Assert.AreEqual(new TimeSpan(0, 10, 0), unitInfo.CurrentFrame.FrameDuration); }
void invoke() { if (WaitForTurn.WaitOne(10)) { List <Position> newUpdatedPositions = new List <Position>(); foreach (Position pos in MapInfo.Pheromones.Keys) { MapPheromone mapPheromone = MapInfo.Pheromones[pos]; HexCell hexCell = GroundCells[pos]; hexCell.Update(mapPheromone); newUpdatedPositions.Add(pos); updatedPositions.Remove(pos); } foreach (Position pos in updatedPositions) { HexCell hexCell = GroundCells[pos]; hexCell.Update(null); } updatedPositions = newUpdatedPositions; // foreach (MapPlayerInfo mapPlayerInfo in MapInfo.PlayerInfo.Values) { } foreach (UnitFrame unitFrame in Units.Values) { //if (unitFrame.FinalDestination != null) { unitFrame.JumpToTarget(unitFrame.FinalDestination); //unitFrame.FinalDestination = null; } unitFrame.NextMove = null; } foreach (Move move in newMoves) { if (move.MoveType == MoveType.Add) { if (Units.ContainsKey(move.UnitId)) { // Happend in player view } else { CreateUnit(move); } } else if (move.MoveType == MoveType.UpdateStats) { if (Units.ContainsKey(move.UnitId)) { UnitFrame unit = Units[move.UnitId]; unit.UpdateStats(move.Stats); } else { // Happend in player view } } else if (move.MoveType == MoveType.Move || move.MoveType == MoveType.Extract || move.MoveType == MoveType.Fire) { UnitFrame unit = Units[move.UnitId]; unit.NextMove = move; } else if (move.MoveType == MoveType.Hit) { UnitFrame unit = Units[move.UnitId]; unit.NextMove = move; } else if (move.MoveType == MoveType.Upgrade) { UnitFrame unit = Units[move.OtherUnitId]; unit.NextMove = move; } else if (move.MoveType == MoveType.UpdateGround) { HexCell hexCell = GroundCells[move.Positions[0]]; hexCell.NextMove = move; hexCell.UpdateGround(); } else if (move.MoveType == MoveType.Delete) { Debug.Log("Delete Unit " + move.UnitId); UnitFrame unit = Units[move.UnitId]; unit.NextMove = null; unit.Delete(); Units.Remove(move.UnitId); } } newMoves.Clear(); WaitForDraw.Set(); } }
public void HashCodeTest1() { var frame = new UnitFrame(); Assert.AreEqual(0, frame.GetHashCode()); }
private static UnitFrame GetUnitFrame(LogLine logLine) { Debug.Assert(logLine != null); Match framesCompleted = FahLogRegex.Common.FramesCompletedRegex.Match(logLine.LineRaw); if (framesCompleted.Success) { var frame = new UnitFrame(); int result; if (Int32.TryParse(framesCompleted.Result("${Completed}"), out result)) { frame.RawFramesComplete = result; } else { return null; } if (Int32.TryParse(framesCompleted.Result("${Total}"), out result)) { frame.RawFramesTotal = result; } else { return null; } string percentString = framesCompleted.Result("${Percent}"); Match mPercent1 = FahLogRegex.Common.Percent1Regex.Match(percentString); Match mPercent2 = FahLogRegex.Common.Percent2Regex.Match(percentString); int framePercent; if (mPercent1.Success) { framePercent = Int32.Parse(mPercent1.Result("${Percent}")); } else if (mPercent2.Success) { framePercent = Int32.Parse(mPercent2.Result("${Percent}")); } // Try to parse a percentage from in between the parentheses (for older single core clients like v5.02) - Issue 36 else if (!Int32.TryParse(percentString, out framePercent)) { return null; } // Validate the steps are in tolerance with the detected frame percent - Issue 98 double calculatedPercent = ((double)frame.RawFramesComplete / frame.RawFramesTotal) * 100; // ex. [00:19:40] Completed 82499 out of 250000 steps (33%) - Would Validate // [00:19:40] Completed 82750 out of 250000 steps (33%) - Would Validate // 10% frame step tolerance. In the example the completed must be within 250 steps. if (Math.Abs(calculatedPercent - framePercent) <= 0.1) { frame.TimeOfFrame = ParseTimeStamp(logLine); frame.FrameID = framePercent; return frame; } /*** ProtoMol Only */ // Issue 191 - New ProtoMol Projects don't report frame progress on the precent boundry. if (Math.Abs(calculatedPercent - (framePercent + 1)) <= 0.1) { frame.TimeOfFrame = ParseTimeStamp(logLine); frame.FrameID = framePercent + 1; return frame; } /*******************/ return null; } return null; }
public void SetCurrentFrameTest1() { var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0, TimeOfFrame = new TimeSpan(0, 0, 0), FrameDuration = new TimeSpan(0, 0, 0) }; unitInfo.SetUnitFrame(unitFrame); Assert.AreEqual(0, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(1, unitInfo.FrameCount); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); unitInfo.SetUnitFrame(unitFrame); // still only 1 frame Assert.AreEqual(1, unitInfo.FrameCount); }
public void SetCurrentFrameTest3() { // this tests GetDelta() rollover functionality var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0, TimeOfFrame = new TimeSpan(23, 55, 0), FrameDuration = new TimeSpan(0, 0, 0) }; unitInfo.SetUnitFrame(unitFrame); // no duration - first frame Assert.AreEqual(new TimeSpan(0, 0, 0), unitInfo.CurrentFrame.FrameDuration); unitFrame = new UnitFrame { RawFramesComplete = 1000, RawFramesTotal = 100000, FrameID = 1, TimeOfFrame = new TimeSpan(0, 5, 0), FrameDuration = new TimeSpan(0, 0, 0) }; // set observed count unitInfo.FramesObserved = 2; unitInfo.SetUnitFrame(unitFrame); // now we get a frame duration Assert.AreEqual(new TimeSpan(0, 10, 0), unitInfo.CurrentFrame.FrameDuration); }
public void UnitInfo_SetUnitFrameDataFromLogLines_Test1() { // Arrange var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0 }; var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }; // Act unitInfo.LogLines = new List<LogLine>(new[] { logLine }); // Assert Assert.AreEqual(0, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(1, unitInfo.UnitFrames.Count); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }
private static UnitFrame GetUnitFrame(LogLine logLine) { Debug.Assert(logLine != null); Match framesCompleted = FahLogRegex.Common.FramesCompletedRegex.Match(logLine.LineRaw); if (framesCompleted.Success) { var frame = new UnitFrame(); int result; if (Int32.TryParse(framesCompleted.Result("${Completed}"), out result)) { frame.RawFramesComplete = result; } else { return(null); } if (Int32.TryParse(framesCompleted.Result("${Total}"), out result)) { frame.RawFramesTotal = result; } else { return(null); } string percentString = framesCompleted.Result("${Percent}"); Match mPercent1 = FahLogRegex.Common.Percent1Regex.Match(percentString); Match mPercent2 = FahLogRegex.Common.Percent2Regex.Match(percentString); int framePercent; if (mPercent1.Success) { framePercent = Int32.Parse(mPercent1.Result("${Percent}")); } else if (mPercent2.Success) { framePercent = Int32.Parse(mPercent2.Result("${Percent}")); } // Try to parse a percentage from in between the parentheses (for older single core clients like v5.02) - Issue 36 else if (!Int32.TryParse(percentString, out framePercent)) { return(null); } // Validate the steps are in tolerance with the detected frame percent - Issue 98 double calculatedPercent = ((double)frame.RawFramesComplete / frame.RawFramesTotal) * 100; // ex. [00:19:40] Completed 82499 out of 250000 steps (33%) - Would Validate // [00:19:40] Completed 82750 out of 250000 steps (33%) - Would Validate // 10% frame step tolerance. In the example the completed must be within 250 steps. if (Math.Abs(calculatedPercent - framePercent) <= 0.1) { frame.TimeOfFrame = ParseTimeStamp(logLine); frame.FrameID = framePercent; return(frame); } /*** ProtoMol Only */ // Issue 191 - New ProtoMol Projects don't report frame progress on the precent boundry. if (Math.Abs(calculatedPercent - (framePercent + 1)) <= 0.1) { frame.TimeOfFrame = ParseTimeStamp(logLine); frame.FrameID = framePercent + 1; return(frame); } /*******************/ return(null); } return(null); }
internal void Update(MapPheromone mapPheromone) { if (mapPheromone == null) { if (markerEnergy != null) { markerEnergy.transform.position = Cell.transform.position; } if (markerToHome != null) { markerToHome.transform.position = Cell.transform.position; } if (markerToMineral != null) { markerToMineral.transform.position = Cell.transform.position; } if (markerToEnemy != null) { markerToEnemy.transform.position = Cell.transform.position; } } else { if (markerEnergy == null) { if (markerPrefab == null) { markerPrefab = Resources.Load <GameObject>("Prefabs/Terrain/Marker"); } markerEnergy = HexGrid.Instantiate(markerPrefab, Cell.transform, false); markerEnergy.name = Cell.name + "-Energy"; markerToHome = HexGrid.Instantiate(markerPrefab, Cell.transform, false); markerToHome.name = Cell.name + "-Home"; MeshRenderer meshRenderer = markerToHome.GetComponent <MeshRenderer>(); meshRenderer.material.color = new Color(0, 0, 0.6f); markerToMineral = HexGrid.Instantiate(markerPrefab, Cell.transform, false); markerToMineral.name = Cell.name + "-Mineral"; meshRenderer = markerToMineral.GetComponent <MeshRenderer>(); meshRenderer.material.color = new Color(0, 0.4f, 0); markerToEnemy = HexGrid.Instantiate(markerPrefab, Cell.transform, false); markerToEnemy.name = Cell.name + "-Mineral"; meshRenderer = markerToEnemy.GetComponent <MeshRenderer>(); meshRenderer.material.color = new Color(0.4f, 0, 0); } if (mapPheromone.IntensityToHome > 0) { Vector3 position = Cell.transform.position; position.y += 0.054f + (0.2f * mapPheromone.IntensityToHome); position.x += 0.1f; markerToHome.transform.position = position; } else { Vector3 position = Cell.transform.position; position.y -= 1; position.x += 0.1f; markerToHome.transform.position = position; } if (mapPheromone.IntensityToMineral > 0) { Vector3 position = Cell.transform.position; position.y += 0.054f + (0.2f * mapPheromone.IntensityToMineral); position.x += 0.2f; markerToMineral.transform.position = position; } else { Vector3 position = Cell.transform.position; position.y -= 1; position.x += 0.2f; markerToMineral.transform.position = position; } if (mapPheromone.IntensityToEnemy > 0) { Vector3 position = Cell.transform.position; position.y += 0.054f + (0.2f * mapPheromone.IntensityToEnemy); position.x += 0.3f; markerToEnemy.transform.position = position; } else { Vector3 position = Cell.transform.position; position.y -= 1; position.x += 0.3f; markerToEnemy.transform.position = position; } float highestEnergy = -1; int highestPlayerId = 0; foreach (MapPheromoneItem mapPheromoneItem in mapPheromone.PheromoneItems) { if (mapPheromoneItem.PheromoneType == Engine.Ants.PheromoneType.Energy) { if (mapPheromoneItem.Intensity >= highestEnergy) { highestEnergy = mapPheromoneItem.Intensity; highestPlayerId = mapPheromoneItem.PlayerId; } } } //highestEnergy = 0; if (highestEnergy > 0) { Vector3 position = Cell.transform.position; position.y += 0.054f + (0.2f * highestEnergy); markerEnergy.transform.position = position; UnitFrame.SetPlayerColor(highestPlayerId, markerEnergy); } else { Vector3 position = Cell.transform.position; position.y -= 1; markerEnergy.transform.position = position; } } }
private static List<UnitInfo> CreateTestList() { var list = new List<UnitInfo>(); for (int i = 0; i < 10; i++) { var unitInfo = new UnitInfo(); unitInfo.OwningClientName = "TestOwner"; unitInfo.OwningClientPath = "TestPath"; unitInfo.UnitRetrievalTime = new DateTime((2000 + i), 1, 1, 0, 0, 0); unitInfo.FoldingID = "TestID"; unitInfo.Team = 32; unitInfo.SlotType = SlotType.CPU; unitInfo.DownloadTime = new DateTime(2000, 2, 2, 0, 0, 0); unitInfo.DueTime = new DateTime(2000, 3, 3, 0, 0, 0); unitInfo.UnitStartTimeStamp = TimeSpan.FromHours(i + 1); unitInfo.FinishedTime = new DateTime(2000, 4, 4, 0, 0, 0); unitInfo.CoreVersion = 2.10f; unitInfo.ProjectID = 2669; unitInfo.ProjectRun = 1; unitInfo.ProjectClone = 2; unitInfo.ProjectGen = 3; unitInfo.ProteinName = "Protein"; unitInfo.ProteinTag = "ProteinTag"; unitInfo.UnitResult = WorkUnitResult.CoreOutdated; // values set by SetUnitFrame() below //unitInfo.RawFramesComplete = 7500; //unitInfo.RawFramesTotal = 250000; unitInfo.FramesObserved = 4; for (int j = 0; j < unitInfo.FramesObserved; j++) { var unitFrame = new UnitFrame { RawFramesComplete = 2500 * j, RawFramesTotal = 250000, FrameID = j, TimeOfFrame = TimeSpan.FromMinutes((j + 1) * (j + 1.5)) }; unitInfo.SetUnitFrame(unitFrame); } list.Add(unitInfo); } for (int i = 10; i < 20; i++) { var unitInfo = new UnitInfo(); unitInfo.OwningClientName = "TestOwner2"; unitInfo.OwningClientPath = "TestPath2"; unitInfo.OwningSlotId = i - 10; unitInfo.UnitRetrievalTime = new DateTime((2000 + i), 1, 1, 0, 0, 0); unitInfo.FoldingID = "TestID"; unitInfo.Team = 32; unitInfo.SlotType = SlotType.CPU; unitInfo.DownloadTime = new DateTime(2000, 2, 2, 0, 0, 0); unitInfo.DueTime = new DateTime(2000, 3, 3, 0, 0, 0); unitInfo.UnitStartTimeStamp = TimeSpan.FromHours(i + 1); unitInfo.FinishedTime = new DateTime(2000, 4, 4, 0, 0, 0); unitInfo.CoreVersion = 2.27f; unitInfo.ProjectID = 6903; unitInfo.ProjectRun = 1; unitInfo.ProjectClone = 2; unitInfo.ProjectGen = 3; unitInfo.ProteinName = "Protein"; unitInfo.ProteinTag = "ProteinTag"; unitInfo.UnitResult = WorkUnitResult.CoreOutdated; // values set by SetUnitFrame() below //unitInfo.RawFramesComplete = 7500; //unitInfo.RawFramesTotal = 250000; unitInfo.FramesObserved = 4; for (int j = 0; j < unitInfo.FramesObserved; j++) { var unitFrame = new UnitFrame { RawFramesComplete = 2500 * j, RawFramesTotal = 250000, FrameID = j, TimeOfFrame = TimeSpan.FromMinutes((j + 2) * (j + 0.75)) }; unitInfo.SetUnitFrame(unitFrame); } list.Add(unitInfo); } return list; }