public Game() { this.sideOnePoints = PointState.Love; this.sideTwoPoints = PointState.Love; this.state = GameState.PriorToDeuce; }
public void Locate(PointState what, out int px, out int py) { px = py = -1; for (int x = 0; x < 30; x++) { for (int y = 0; y < 30; y++) { if (BoardState[x, y] == what) { px = x; py = y; } } } }
/// <summary> /// Compute the point states given two manifolds. The states pertain to the transition from manifold1 /// to manifold2. So state1 is either persist or remove while state2 is either add or persist. /// </summary> public static void GetPointStates(PointState[/*b2_maxManifoldPoints*/] state1, PointState[/*b2_maxManifoldPoints*/] state2, Manifold manifold1, Manifold manifold2) { for (int i = 0; i < Common.Settings.MaxManifoldPoints; ++i) { state1[i] = PointState.NullState; state2[i] = PointState.NullState; } // Detect persists and removes. for (int i = 0; i < manifold1.PointCount; ++i) { ContactID id = manifold1.Points[i].ID; state1[i] = PointState.RemoveState; for (int j = 0; j < manifold2.PointCount; ++j) { if (manifold2.Points[j].ID.Key == id.Key) { state1[i] = PointState.PersistState; break; } } } // Detect persists and adds. for (int i = 0; i < manifold2.PointCount; ++i) { ContactID id = manifold2.Points[i].ID; state2[i] = PointState.AddState; for (int j = 0; j < manifold1.PointCount; ++j) { if (manifold1.Points[j].ID.Key == id.Key) { state2[i] = PointState.PersistState; break; } } } }
/// <summary> /// 根据状态值判断模拟量是否报警 /// </summary> /// <param name="state"></param> /// <returns></returns> private static bool IsAlarmState(PointState state) { var ret = false; switch (state) { case PointState.LowerLimitEarlyWarning: //注意:分站断线,模拟量不属于报警,但是显示时需要显示报警色 case PointState.LowerLimitResume: case PointState.LowerLimitSwitchingOff: case PointState.LowerLimitWarning: case PointState.UpperLimitEarlyWarning: case PointState.UpperLimitResume: case PointState.UpperLimitSwitchingOff: case PointState.UpperLimitWarning: case PointState.OFF: ret = true; break; } return(ret); }
private string TranslateScore(PointState pointState) { switch (pointState) { case PointState.Love: return("love"); case PointState.Fifteen: return("fifteen"); case PointState.Thirty: return("thirty"); case PointState.Forty: return("forty"); default: return(String.Empty); } }
private string TranslateScore(PointState pointState) { switch (pointState) { case PointState.Love: return(nameof(PointState.Love)); case PointState.Fifteen: return(nameof(PointState.Fifteen)); case PointState.Thirty: return(nameof(PointState.Thirty)); case PointState.Fourty: return(nameof(PointState.Fourty)); default: return(String.Empty); } }
public GameLogic(int max_hp, int gameTime) { gameTickTimer = new Timer(1000); gameTickTimer.Elapsed += Timer_Elapsed; bleDataLayer = new BluetoothDataLayer(); beaconFilter = new BeaconFilter(bleDataLayer); players = new Dictionary <CommandColors, int>(); players.TryAdd(CommandColors.RED, 0); players.TryAdd(CommandColors.GREEN, 0); players.TryAdd(CommandColors.BLUE, 0); players.TryAdd(CommandColors.YELLOW, 0); winPoints.TryAdd(CommandColors.RED, 0); winPoints.TryAdd(CommandColors.GREEN, 0); winPoints.TryAdd(CommandColors.BLUE, 0); winPoints.TryAdd(CommandColors.YELLOW, 0); pointState = PointState.NEUTRAL; Max_HP = max_hp; HP = Max_HP; currentOwner = CommandColors.NOBODY; elapsedTime = gameTime; gameTimeInterval = gameTime; }
private void HandleAnalogAlarm(float value, ref PointState pointState) { var upperLimit = 9999; if (UpperLimitEarlyWarning != upperLimit && value >= UpperLimitEarlyWarning) { pointState = PointState.UpperLimitEarlyWarning; } if (UpperLimitResume != upperLimit && value >= UpperLimitResume) { pointState = PointState.UpperLimitResume; } if (UpperLimitWarning != upperLimit && value >= UpperLimitWarning) { pointState = PointState.UpperLimitWarning; } if (UpperLimitSwitchingOff != upperLimit && value >= UpperLimitSwitchingOff) { pointState = PointState.UpperLimitSwitchingOff; } var lowLimit = -9999; if (LowerLimitEarlyWarning != lowLimit && value <= LowerLimitEarlyWarning) { pointState = PointState.LowerLimitEarlyWarning; } if (LowerLimitResume != lowLimit && value <= LowerLimitResume) { pointState = PointState.LowerLimitResume; } if (LowerLimitWarning != lowLimit && value <= LowerLimitWarning) { pointState = PointState.LowerLimitWarning; } if (LowerLimitSwitchingOff != lowLimit && value <= LowerLimitSwitchingOff) { pointState = PointState.LowerLimitSwitchingOff; } }
internal void Update(DateTime now, List <SensorRealDataInfo> sensorRealDataInfos) { var sensorRealData = sensorRealDataInfos.FirstOrDefault(p => p.EquipCodes.Exists(q => q == EquipCode)); if (sensorRealData.IsAnalogOk) { _analogOffCount = 0; PointState valueState = PointState.OK; HandleAnalogAlarm(sensorRealData.Value, ref valueState); RealDataModel.Update(now, sensorRealData.Value.ToString("f2"), valueState); _analogRunModel.Update(RealDataModel); _analogRunModels.Add(_analogRunModel); AnalogStatisticModel.UpdateAnalogStatistic(ref _analogStatisticModel, _analogStatisticModels, RealDataModel, this); AnalogAlarmModel.UpdateAnalogAlarm(ref _analogAlarmModel, _analogAlarmModels, RealDataModel, this, IsAlarmState); Alarm_TodayModel.UpdateAlarmToday(ref _alarmTodayModel, _alarmTodayModels, RealDataModel, this, IsAlarmState); DeviceFaultRunModel.UpdateDeviceFaultRun(ref _deviceFaultRunModel, _deviceFaultRunModels, RealDataModel, this, IsAlarmState); } else { Update(now); } }
//绘制点 public void AddPoint() { if (fp.SquareState == FocusState.Found) { switch (sm.MStatus) { case MeasureStatus.Complete: case MeasureStatus.Adding: //添加端点 lRender = Instantiate(prelRender, linesGenerator.transform); //刚开始时应添加两个端点 from = fp.hitPoint; AddLinePoint(from); AddLinePoint(from); sm.MStatus = MeasureStatus.Line_Drawing; break; case MeasureStatus.Line_Drawing: Vector3 _lay = (points[pointCount - 2] + points[pointCount - 1]) / 2; GameObject _g_hint = Instantiate(hint_Prefeb, _lay, hint_Prefeb.transform.rotation, lRender.transform); _g_hint.transform.LookAt(fp.hitPoint); _g_hint.GetComponentInChildren <TextMesh>().text = sm.displayLength; AddLinePoint(fp.hitPoint); break; } if (DotState == PointState.Adsorpting) { points[pointCount - 1] = from; lRender.SetPositions(points.ToArray()); lRender.GetComponent <LineRenderer>().material = m_Line; ComputeArea(); DotState = PointState.finding; sm.MStatus = MeasureStatus.Complete; lRender.transform.Find("TextParent").gameObject.SetActive(true); points.Clear(); pointCount = 0; } } }
private IDictionary <(int X, int Y), PointState> GetPoints() { var points = new Dictionary <(int X, int Y), PointState>(); foreach (var wire in _input.Select((x, i) => new { Index = i, Segments = x })) { var position = (X : 0, Y : 0); var steps = 1; foreach (var segment in wire.Segments) { var distance = Int32.Parse(segment.AsSpan(1)); for (int i = 0; i < distance; i++, steps++) { position = segment[0] switch { 'U' => (position.X, position.Y + 1), 'D' => (position.X, position.Y - 1), 'R' => (position.X + 1, position.Y), 'L' => (position.X - 1, position.Y), _ => throw new NotSupportedException(), }; if (!points.ContainsKey(position)) { points[position] = new PointState(_input.Length); } var state = points[position]; state.Wires |= 1 << wire.Index; state.Steps[wire.Index] ??= steps; } } } return(points); }
public Point(Button Btn, Action <Point> btnCallBack, Vector2Int position) { this.btn = Btn; state = PointState.Nothing; this.position = position; Btn.OnClick = () => { if (State == PointState.Nothing) { if (Trun == Turn.black) { State = PointState.ShowBlack; } else { State = PointState.ShowWhite; } if (btnCallBack != null) { btnCallBack(this); } } }; }
// Parses the passed data buffer, and returns the state of a point(word, bit) on the block public static bool GetPointState(int pointId, BlockState blockState) { PointState ps = blockState.Points.First(x => x.PointID == pointId); return(ps.State); }
private void WriteGameState(PointState[,] curState) { using (TextWriter writer = File.CreateText("game.state")) { for (int x = 0; x < 30; x++) { for (int y = 0; y < 30; y++) { writer.WriteLine("{0} {1} {2}", x, y, curState[x, y].ToString()); } } writer.Close(); } }
public void SwapTurn() { currentPlayerColor = currentPlayerColor == firstPlayerColor ? secondPlayerColor : firstPlayerColor; }
public int CalculateVictory(List <PointState>[] board, int lastMove) { var height = board[lastMove].Count - 1; var state = board[lastMove].Last(); // Horisontal PointState l3 = (lastMove > 2 && board[lastMove - 3].Count > height) ? board[lastMove - 3].ElementAt(height) : PointState.Empty; PointState l2 = (lastMove > 1 && board[lastMove - 2].Count > height) ? board[lastMove - 2].ElementAt(height) : PointState.Empty; PointState l1 = (lastMove > 0 && board[lastMove - 1].Count > height) ? board[lastMove - 1].ElementAt(height) : PointState.Empty; PointState r3 = (lastMove <4 && board[lastMove + 3].Count> height) ? board[lastMove + 3].ElementAt(height) : PointState.Empty; PointState r2 = (lastMove <5 && board[lastMove + 2].Count> height) ? board[lastMove + 2].ElementAt(height) : PointState.Empty; PointState r1 = (lastMove <6 && board[lastMove + 1].Count> height) ? board[lastMove + 1].ElementAt(height) : PointState.Empty; if (l3 == state && l2 == state && l1 == state) { return(1); } if (l2 == state && l1 == state && r1 == state) { return(1); } if (l1 == state && r1 == state && r2 == state) { return(1); } if (r1 == state && r2 == state && r3 == state) { return(1); } // Vertical if (height > 2) { PointState d3 = board[lastMove].ElementAt(height - 3); PointState d2 = board[lastMove].ElementAt(height - 2); PointState d1 = board[lastMove].ElementAt(height - 1); if (d3 == state && d2 == state && d1 == state) { return(1); } } // Left diagonal PointState ld3 = (lastMove > 2 && height > 2 && board[lastMove - 3].Count > (height - 3)) ? board[lastMove - 3].ElementAt(height - 3) : PointState.Empty; PointState ld2 = (lastMove > 1 && height > 1 && board[lastMove - 2].Count > (height - 2)) ? board[lastMove - 2].ElementAt(height - 2) : PointState.Empty; PointState ld1 = (lastMove > 0 && height > 0 && board[lastMove - 1].Count > (height - 1)) ? board[lastMove - 1].ElementAt(height - 1) : PointState.Empty; PointState rd3 = (lastMove <4 && board[lastMove + 3].Count> (height + 3)) ? board[lastMove + 3].ElementAt(height + 3) : PointState.Empty; PointState rd2 = (lastMove <5 && board[lastMove + 2].Count> (height + 2)) ? board[lastMove + 2].ElementAt(height + 2) : PointState.Empty; PointState rd1 = (lastMove <6 && board[lastMove + 1].Count> (height + 1)) ? board[lastMove + 1].ElementAt(height + 1) : PointState.Empty; if (ld3 == state && ld2 == state && ld1 == state) { return(1); } if (ld2 == state && ld1 == state && rd1 == state) { return(1); } if (ld1 == state && rd1 == state && rd2 == state) { return(1); } if (rd1 == state && rd2 == state && rd3 == state) { return(1); } // Right diagonal PointState dl3 = (lastMove > 2 && (board[lastMove - 3].Count > (height + 3))) ? board[lastMove - 3].ElementAt(height + 3) : PointState.Empty; PointState dl2 = (lastMove > 1 && (board[lastMove - 2].Count > (height + 2))) ? board[lastMove - 2].ElementAt(height + 2) : PointState.Empty; PointState dl1 = (lastMove > 0 && (board[lastMove - 1].Count > (height + 1))) ? board[lastMove - 1].ElementAt(height + 1) : PointState.Empty; PointState dr3 = (lastMove < 4 && height > 2 && (board[lastMove + 3].Count > (height - 3))) ? board[lastMove + 3].ElementAt(height - 3) : PointState.Empty; PointState dr2 = (lastMove < 5 && height > 1 && (board[lastMove + 2].Count > (height - 2))) ? board[lastMove + 2].ElementAt(height - 2) : PointState.Empty; PointState dr1 = (lastMove < 6 && height > 0 && (board[lastMove + 1].Count > (height - 1))) ? board[lastMove + 1].ElementAt(height - 1) : PointState.Empty; if (dl3 == state && dl2 == state && dl1 == state) { return(1); } if (dl2 == state && dl1 == state && dr1 == state) { return(1); } if (dl1 == state && dr1 == state && dr2 == state) { return(1); } if (dr1 == state && dr2 == state && dr3 == state) { return(1); } return(0); }
public Point(PointState state) { this.State = state; }
private string TranslateScore(PointState pointState) { switch(pointState) { case PointState.Love: return "love"; case PointState.Fifteen: return "fifteen"; case PointState.Thirty: return "thirty"; case PointState.Forty: return "forty"; default: return String.Empty; } }
public override void PreSolve(Contact contact, Manifold oldManifold) { Manifold manifold = contact.Manifold; if (manifold.PointCount == 0) return; Fixture fixtureA = contact.FixtureA; Fixture fixtureB = contact.FixtureB; PointState[] state1 = new PointState[Box2DSettings.b2_maxManifoldPoints], state2 = new PointState[Box2DSettings.b2_maxManifoldPoints]; Manifold.GetPointStates(ref state1, ref state2, ref oldManifold, ref manifold); WorldManifold worldManifold = contact.WorldManifold; for (int i = 0; i < manifold.PointCount && m_pointCount < ContactPoint.k_maxContactPoints; ++i) { m_points[m_pointCount].fixtureA = fixtureA; m_points[m_pointCount].fixtureB = fixtureB; m_points[m_pointCount].position = worldManifold.Points[i]; m_points[m_pointCount].normal = worldManifold.Normal; m_points[m_pointCount].state = state2[i]; ++m_pointCount; } }
private void UpdateCurrentMapState(PointState[,] newState) { for (int x = 0; x < 30; x++) { if (newState[x, 0] == PointState.YourWall) { for (int xi = 0; xi < 30; xi++) { newState[xi, 0] = PointState.YourWall; } break; } } for (int x = 0; x < 30; x++) { if (newState[x, 29] == PointState.YourWall) { for (int xi = 0; xi < 30; xi++) { newState[xi, 29] = PointState.YourWall; } break; } } for (int x = 0; x < 30; x++) { for (int y = 0; y < 30; y++) { switch (newState[x, y]) { case PointState.You: map[x, y] = (currentPlayer == 0) ? PointState.Player1 : PointState.Player2; break; case PointState.YourWall: map[x, y] = (currentPlayer == 0) ? PointState.Player1Wall : PointState.Player2Wall; break; case PointState.Opponent: map[x, y] = (currentPlayer == 0) ? PointState.Player2 : PointState.Player1; break; case PointState.OpponentWall: map[x, y] = (currentPlayer == 0) ? PointState.Player2Wall : PointState.Player1Wall; break; default: map[x, y] = PointState.Clear; break; } } } }
private PointState[,] ReadGameState() { int x, y; PointState state; PointState[,] newState = new PointState[30, 30]; string[] lines = File.ReadAllLines("game.state", Encoding.UTF8); foreach (string line in lines) { string[] tokens = line.Split(' '); if (tokens.Length != 3) { continue; } if (int.TryParse(tokens[0], out x) == false) { continue; } if (int.TryParse(tokens[1], out y) == false) { continue; } if (Enum.TryParse<PointState>(tokens[2], out state) == false ) { continue; } newState[x, y] = state; } return newState; }
/// Compute the point states given two manifolds. The states pertain to the transition from manifold1 /// to manifold2. So state1 is either persist or remove while state2 is either add or persist. public static void GetPointStates(PointState[/*Settings._maxManifoldPoints*/] state1, PointState[/*Settings._maxManifoldPoints*/] state2, Manifold manifold1, Manifold manifold2) { throw new NotImplementedException(); //for (int i = 0; i < Settings._maxManifoldPoints; ++i) //{ // state1[i] = _nullState; // state2[i] = _nullState; //} //// Detect persists and removes. //for (int i = 0; i < manifold1.pointCount; ++i) //{ // ContactID id = manifold1.points[i].id; // state1[i] = _removeState; // for (int j = 0; j < manifold2.pointCount; ++j) // { // if (manifold2.points[j].id.key == id.key) // { // state1[i] = _persistState; // break; // } // } //} //// Detect persists and adds. //for (int i = 0; i < manifold2.pointCount; ++i) //{ // ContactID id = manifold2.points[i].id; // state2[i] = _addState; // for (int j = 0; j < manifold1.pointCount; ++j) // { // if (manifold1.points[j].id.key == id.key) // { // state2[i] = _persistState; // break; // } // } //} }
void FixedUpdate() { var infoArgs = new ZMPlayerInfoEventArgs(_playerInfo); // Score checks. if (IsAbleToScore()) { if (_pointState != PointState.GAINING) { _pointState = PointState.GAINING; Notifier.SendEventNotification(CanScoreEvent, infoArgs); } } else if (_pointState != PointState.NEUTRAL) { _pointState = PointState.NEUTRAL; Notifier.SendEventNotification(OnStopScore, infoArgs); } // state handling if (_pointState == PointState.GAINING) { foreach (ZMSoul soul in _drainingSouls) { if (soul.GetComponent <ZMPedestalController>().IsDiabled()) { continue; } if ((soul.GetZen() - SCORE_RATE) > 0) { AddToScore(SCORE_RATE); soul.AddZen(-SCORE_RATE); soul.SendMessage("SetPulsingOn"); } else if (soul.GetZen() > 0) { AddToScore(soul.GetZen()); soul.SetZen(0); soul.SendMessage("SetPulsingOff"); } } } else if (_pointState == PointState.LOSING) { Notifier.SendEventNotification(CanDrainEvent, infoArgs); } // player score checks if (_totalScore <= 0 && _goalState != GoalState.MIN) { _goalState = GoalState.MIN; Notifier.SendEventNotification(OnReachMinScore, infoArgs); } if (_totalScore >= MAX_SCORE && !IsMaxed()) { _goalState = GoalState.MAX; } // Player score state checks if (_goalState == GoalState.MAX) { _goalState = GoalState.MAXED; // Assumes total score clamped to max score. if (_totalScore == MAX_SCORE) { MatchStateManager.EndMatch(); } Notifier.SendEventNotification(OnReachMaxScore, infoArgs); } }
public void HandleBallBounce(Vector2?bounceCoordinates) { switch (_pointState) { case PointState.FirstServe: case PointState.SecondServe: if (_ballCollidedWithCourt && courtSectionMapper.ServiceIsIn(bounceCoordinates.GetValueOrDefault())) { // Service is in _pointState = PointState.ReceiverTurn; } else { // Service is out if (_pointState == PointState.FirstServe) { _isServiceFault = true; _pointState = PointState.WaitingSecondServe; ResetPoint(PointState.SecondServe); _replayManager.ResetRecording(); } else { //Double fault _isServiceFault = true; _pointState = PointState.WaitingFirstServe; _scoreManager.WinPoint(_scoreManager.GetReceivingPlayerId()); ResetPoint(PointState.FirstServe); _replayManager.ResetRecording(); } } break; case PointState.ReceiverTurn: if (_ballCollidedWithReceiverRacket) { _pointState = PointState.ReceiverHit; } else { // Collide was anywhere else, receiver didn't reach the ball before second bounce _pointState = PointState.WaitingFirstServe; var pointWinner = _scoreManager.GetServingPlayerId(); _scoreManager.WinPoint(pointWinner); _replayManager.SetCameraPosition(pointWinner); ResetPoint(PointState.FirstServe); } break; case PointState.ReceiverHit: if (_ballCollidedWithServerRacket) { _pointState = PointState.ServerHit; } else if (_ballCollidedWithCourt && courtSectionMapper.BallIsIn(bounceCoordinates.GetValueOrDefault(), CourtTarget.Server)) { _pointState = PointState.ServerTurn; } else { // Receiver hit was out _pointState = PointState.WaitingFirstServe; var pointWinner = _scoreManager.GetServingPlayerId(); _scoreManager.WinPoint(pointWinner); _replayManager.SetCameraPosition(pointWinner); ResetPoint(PointState.FirstServe); } break; case PointState.ServerTurn: if (_ballCollidedWithServerRacket) { _pointState = PointState.ServerHit; } else { // Collide was anywhere else, server didn't reach the ball before second bounce _pointState = PointState.WaitingFirstServe; var pointWinner = _scoreManager.GetReceivingPlayerId(); _scoreManager.WinPoint(pointWinner); _replayManager.SetCameraPosition(pointWinner); ResetPoint(PointState.FirstServe); } break; case PointState.ServerHit: if (_ballCollidedWithReceiverRacket) { _pointState = PointState.ReceiverHit; } else if (courtSectionMapper.BallIsIn(bounceCoordinates.GetValueOrDefault(), CourtTarget.Receiver)) { _pointState = PointState.ReceiverTurn; } else { // Server hit was out _pointState = PointState.WaitingFirstServe; var pointWinner = _scoreManager.GetReceivingPlayerId(); _scoreManager.WinPoint(pointWinner); _replayManager.SetCameraPosition(pointWinner); ResetPoint(PointState.FirstServe); } break; case PointState.WaitingFirstServe: case PointState.WaitingSecondServe: break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Compute the point states given two manifolds. The states pertain to the transition from /// manifold1 to manifold2. So state1 is either persist or remove while state2 is either add or /// persist. /// </summary> /// <param name="state1"></param> /// <param name="state2"></param> /// <param name="manifold1"></param> /// <param name="manifold2"></param> public static void GetPointStates(PointState[] state1, PointState[] state2, Manifold manifold1, Manifold manifold2) { for (int i = 0; i < Settings.MAX_MANIFOLD_POINTS; i++) { state1[i] = PointState.NullState; state2[i] = PointState.NullState; } // Detect persists and removes. for (int i = 0; i < manifold1.PointCount; i++) { ContactID id = manifold1.Points[i].Id; state1[i] = PointState.RemoveState; for (int j = 0; j < manifold2.PointCount; j++) { if (manifold2.Points[j].Id.IsEqual(id)) { state1[i] = PointState.PersistState; break; } } } // Detect persists and adds for (int i = 0; i < manifold2.PointCount; i++) { ContactID id = manifold2.Points[i].Id; state2[i] = PointState.AddState; for (int j = 0; j < manifold1.PointCount; j++) { if (manifold1.Points[j].Id.IsEqual(id)) { state2[i] = PointState.PersistState; break; } } } }
public static string GetAlarmStateName(PointState state) { var alarmStateName = string.Empty; switch (state) { case PointState.UnKnow: break; case PointState.Init: break; case PointState.OFF: alarmStateName = "模拟量断线"; break; case PointState.ServiceOff: break; case PointState.Unused: break; case PointState.OverflowOFF: break; case PointState.UnderflowOFF: break; case PointState.SubStationOFF: alarmStateName = "分站断线"; break; case PointState.AC: break; case PointState.DC: break; case PointState.BitError: break; case PointState.NetworkInterruption: break; case PointState.OK: break; case PointState.UpperLimitSwitchingOff: alarmStateName = "模拟量上限断电"; break; case PointState.UpperLimitWarning: alarmStateName = "模拟量上限报警"; break; case PointState.UpperLimitResume: alarmStateName = "模拟量上限恢复"; break; case PointState.UpperLimitEarlyWarning: alarmStateName = "模拟量上限预警"; break; case PointState.LowerLimitSwitchingOff: alarmStateName = "模拟量下限断电"; break; case PointState.LowerLimitWarning: alarmStateName = "模拟量下限报警"; break; case PointState.LowerLimitResume: alarmStateName = "模拟量下限恢复"; break; case PointState.LowerLimitEarlyWarning: alarmStateName = "模拟量下限预警"; break; case PointState.State0: break; case PointState.State1: break; case PointState.State2: break; default: alarmStateName = "报警"; break; } return(alarmStateName); }
public static void GetPointStates(ref PointState[] state1, ref PointState[] state2, ref Manifold manifold1, ref Manifold manifold2) { for (int i = 0; i < Box2DSettings.b2_maxManifoldPoints; ++i) { state1[i] = PointState.Null; state2[i] = PointState.Null; } // Detect persists and removes. for (int i = 0; i < manifold1.PointCount; ++i) { ContactID id = manifold1[i].ID; state1[i] = PointState.Remove; for (int j = 0; j < manifold2.PointCount; ++j) { if (manifold2[j].ID.Key == id.Key) { state1[i] = PointState.Persist; break; } } } // Detect persists and adds. for (int i = 0; i < manifold2.PointCount; ++i) { ContactID id = manifold2[i].ID; state2[i] = PointState.Add; for (int j = 0; j < manifold1.PointCount; ++j) { if (manifold1[j].ID.Key == id.Key) { state2[i] = PointState.Persist; break; } } } }
public virtual void PreSolve(Contact contact, Manifold oldManifold) { Manifold manifold = contact.GetManifold(); if (manifold.points.Count() == 0) { return; } Fixture fixtureA = contact.FixtureA; Fixture fixtureB = contact.FixtureB; PointState[] state1 = new PointState[Settings._maxManifoldPoints]; PointState[] state2 = new PointState[Settings._maxManifoldPoints]; Collision.GetPointStates(state1, state2, oldManifold, manifold); WorldManifold worldManifold; contact.GetWorldManifold(out worldManifold); for (int i = 0; i < manifold.points.Count() && m_pointCount < Program.k_maxContactPoints; ++i) { ContactPoint cp = m_points[m_pointCount]; cp.fixtureA = fixtureA; cp.fixtureB = fixtureB; cp.position = worldManifold.points[i]; cp.normal = worldManifold.normal; cp.state = state2[i]; cp.normalImpulse = manifold.points[i].normalImpulse; cp.tangentImpulse = manifold.points[i].tangentImpulse; ++m_pointCount; } }
/// <summary> /// Compute the point states given two manifolds. The states pertain to the transition from /// manifold1 to manifold2. So state1 is either persist or remove while state2 is either add or /// persist. /// </summary> /// <param name="state1"></param> /// <param name="state2"></param> /// <param name="manifold1"></param> /// <param name="manifold2"></param> public static void getPointStates(PointState[] state1, PointState[] state2, Manifold manifold1, Manifold manifold2) { for (int i = 0; i < Settings.maxManifoldPoints; i++) { state1[i] = PointState.NULL_STATE; state2[i] = PointState.NULL_STATE; } // Detect persists and removes. for (int i = 0; i < manifold1.pointCount; i++) { ContactID id = manifold1.points[i].id; state1[i] = PointState.REMOVE_STATE; for (int j = 0; j < manifold2.pointCount; j++) { if (manifold2.points[j].id.isEqual(id)) { state1[i] = PointState.PERSIST_STATE; break; } } } // Detect persists and adds for (int i = 0; i < manifold2.pointCount; i++) { ContactID id = manifold2.points[i].id; state2[i] = PointState.ADD_STATE; for (int j = 0; j < manifold1.pointCount; j++) { if (manifold1.points[j].id.isEqual(id)) { state2[i] = PointState.PERSIST_STATE; break; } } } }
public void RemovePick() { pickable = default; baseTower = default; state = PointState.noThing; }
private void SetPointState(Side side, PointState state) { if (side == Side.One) { sideOnePoints = state; } else { sideTwoPoints = state; } }
private void Locate(PointState[,] state, PointState what, out int px, out int py) { px = py = -1; for (int x = 0; x < 30; x++) { for (int y = 0; y < 30; y++) { if (state[x, y] == what) { px = x; py = y; } } } }
private void AdvanceState(Side side) { if (StillPlaying()) { if (HasEnteredDeuce()) { this.state = GameState.Deuce; if (GetPointState(side) == PointState.Advantage) { this.state = DetermineWinner(side); return; } if((sideOnePoints == PointState.Deuce && sideTwoPoints == PointState.Deuce) || (sideOnePoints == PointState.Forty && sideTwoPoints == PointState.Forty)) { SetPointState(side, PointState.Advantage); return; } sideOnePoints = PointState.Deuce; sideTwoPoints = PointState.Deuce; return; } RollPoints(side); if (((int)GetPointState(side)) > 4) { this.state = DetermineWinner(side); } } }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { int _redPlayers = 0; int _greenPlayers = 0; int _bluePlayers = 0; int _yellowPlayers = 0; bool commandIsChanged = false; elapsedTime--; if (elapsedTime == 0) { StopGame(); } List <Beacon> beacons = beaconFilter.GetActiveBeeacons(); foreach (var b in beacons) { switch (b.beaconType) { case Beacon.BeaconType.ARTIFACT: // Need think about it break; case Beacon.BeaconType.COMMAND_BLUE: _bluePlayers++; break; case Beacon.BeaconType.COMMAND_RED: _redPlayers++; break; case Beacon.BeaconType.COMMAND_YELLOW: _yellowPlayers++; break; case Beacon.BeaconType.COMMAND_GREEN: _greenPlayers++; break; } } players[CommandColors.BLUE] = _bluePlayers; players[CommandColors.GREEN] = _greenPlayers; players[CommandColors.RED] = _redPlayers; players[CommandColors.YELLOW] = _yellowPlayers; if (players.Max().Value != players.Min().Value) { if (players.Max().Key != CommandInAttcak) { commandIsChanged = true; } CommandInAttcak = players.Max().Key; } else { CommandInAttcak = CommandColors.NOBODY; } if (CommandInAttcak != currentOwner) { ; } switch (pointState) { case PointState.NEUTRAL: { if (CommandInAttcak != CommandColors.NOBODY) { pointState = PointState.ATTACKED; } break; } case PointState.ATTACKED: { winPoints[currentOwner]++; HP--; if (HP == 0) { currentOwner = CommandInAttcak; pointState = PointState.IS_OWNED; HP = Max_HP; } break; } case PointState.IS_OWNED: winPoints[currentOwner]++; if (commandIsChanged) { pointState = PointState.ATTACKED; } break; default: break; } }
// Callbacks for derived classes. public override void PreSolve(Contact contact, Manifold oldManifold) { Manifold manifold = contact.GetManifold(); if (manifold.PointCount == 0) { return; } Fixture fixtureA = contact.GetFixtureA(); Fixture fixtureB = contact.GetFixtureB(); PointState[] state1 = new PointState[Box2DX.Common.Settings.MaxManifoldPoints]; PointState[] state2 = new PointState[Box2DX.Common.Settings.MaxManifoldPoints]; Collision.GetPointStates(state1, state2, oldManifold, manifold); WorldManifold worldManifold; contact.GetWorldManifold(out worldManifold); for (int i = 0; i < manifold.PointCount && _pointCount < k_maxContactPoints; ++i) { ContactPoint cp = _points[_pointCount]; cp.fixtureA = fixtureA; cp.fixtureB = fixtureB; cp.position = worldManifold.Points[i]; cp.normal = worldManifold.Normal; cp.state = state2[i]; _points[_pointCount] = cp; ++_pointCount; } }
private void DrawPoint( Graphics g, Rectangle r, Color backColor, PointState state) { var cr = r; // build point graphics path using (var backPen = new Pen(BackColor, 1)) { using (var gp = new GraphicsPath()) { if (state != PointState.None) { gp.AddLine(r.Left, r.Top, r.Right, r.Top); gp.AddLine(r.Right, r.Top, r.Right, r.Bottom - c_MarkWidth / 2 - 2); gp.AddLine(r.Right, r.Bottom - c_MarkWidth / 2 - 2, r.Left + r.Width / 2 - 1, r.Bottom); gp.AddLine(r.Left + r.Width / 2, r.Bottom, r.Left, r.Bottom - c_MarkWidth / 2 - 2); gp.AddLine(r.Left, r.Bottom - c_MarkWidth / 2 - 2, r.Left, r.Top); } else { gp.AddLine(r.Left, r.Top, r.Right, r.Top); gp.AddLine(r.Right, r.Top + 1, r.Right - 1, r.Bottom - c_MarkWidth / 2); gp.AddLine(r.Right, r.Bottom - c_MarkWidth / 2, r.Left + r.Width / 2, r.Bottom); gp.AddLine(r.Left + r.Width / 2 - 1, r.Bottom, r.Left, r.Bottom - c_MarkWidth / 2); gp.AddLine(r.Left, r.Bottom - c_MarkWidth / 2, r.Left, r.Top + 1); } gp.CloseFigure(); if (state != PointState.None) { Color c1, c2; if ((state & PointState.Highlighted) != 0) { c1 = c_HighlightedItemBorderColor1; c2 = c_HighlightedItemBorderColor2; } else { c1 = c_SelectedItemBorderColor1; c2 = c_SelectedItemBorderColor2; } g.DrawLine(backPen, r.Left, r.Top, r.Left + 1, r.Top); g.DrawLine(backPen, r.Right - 2, r.Top, r.Right - 1, r.Top); using (var p = new Pen(c2, 1)) { g.DrawLine(p, r.Left + 1, r.Top, r.Right - 2, r.Top); g.DrawLine(p, r.Right - 1, r.Y + 1, r.Right - 1, r.Bottom - c_MarkWidth / 2 - 2); g.DrawLine(p, r.Right - 1, r.Bottom - c_MarkWidth / 2 - 2, r.Left + r.Width / 2 - 1, r.Bottom); g.DrawLine(p, r.Left + r.Width / 2, r.Bottom, r.Left, r.Bottom - c_MarkWidth / 2 - 2); g.DrawLine(p, r.Left, r.Bottom - c_MarkWidth / 2 - 2, r.Left, r.Top + 1); } r.Inflate(-1, -1); using (var p = new Pen(c1, 1)) { g.DrawLine(p, r.Left, r.Top, r.Right - 1, r.Top); g.DrawLine(p, r.Right - 1, r.Y + 1, r.Right - 1, r.Bottom - c_MarkWidth / 2 - 1); g.DrawLine(p, r.Left + r.Width / 2, r.Bottom - 1, r.Right - 1, r.Bottom - c_MarkWidth / 2 - 1); g.DrawLine(p, r.Left, r.Bottom - c_MarkWidth / 2 - 1, r.Left + r.Width / 2 - 1, r.Bottom - 1); g.DrawLine(p, r.Left, r.Top + 1, r.Left, r.Bottom - c_MarkWidth / 2 - 1); } r.Inflate(-1, -1); } using (var p = new Pen(c_ItemBorderColor, 1)) { g.DrawLine(p, r.Left, r.Top, r.Right - 1, r.Top); g.DrawLine(p, r.Right - 1, r.Top + 1, r.Right - 1, r.Bottom - c_MarkWidth / 2); g.DrawLine(p, r.Right - 1, r.Bottom - c_MarkWidth / 2, r.Left + r.Width / 2, r.Bottom - 1); using (var p2 = new Pen(c_ItemBorderColor2, 1)) g.DrawLine(p2, r.Left + r.Width / 2 - 1, r.Bottom - 1, r.Left, r.Bottom - c_MarkWidth / 2); g.DrawLine(p, r.Left, r.Bottom - c_MarkWidth / 2, r.Left, r.Top + 1); } r.Inflate(-1, -1); g.DrawRectangle(backPen, r.Left, r.Top, r.Right - 1 - r.Left, r.Bottom - c_MarkWidth / 2 - r.Top); for (int i = 0; i < c_MarkWidth / 2 - 1; i++) { int y = r.Bottom - c_MarkWidth / 2 + i + 1; g.DrawLine(backPen, r.Left + i, y, r.Right - i - 1, y); } r.Inflate(-1, -1); using (var b = new SolidBrush(backColor)) { g.FillRectangle(b, r.Left, r.Top, r.Width, r.Height - c_MarkWidth / 2 + 1); } using (var rgn = new Region(gp)) g.ExcludeClip(rgn); } } }
public void SetPickable(Pickable pickable) { state = PointState.hadThing; this.pickable = pickable; }
private PointState[,] GenerateCurrentMapState() { PointState[,] mapState = new PointState[30, 30]; for (int x = 0; x < 30; x++) { for (int y = 0; y < 30; y++) { switch(map[x,y]) { case PointState.Player1: mapState[x, y] = (currentPlayer == 0) ? PointState.You : PointState.Opponent; break; case PointState.Player1Wall: mapState[x, y] = (currentPlayer == 0) ? PointState.YourWall : PointState.OpponentWall; break; case PointState.Player2: mapState[x, y] = (currentPlayer == 1) ? PointState.You : PointState.Opponent; break; case PointState.Player2Wall: mapState[x, y] = (currentPlayer == 1) ? PointState.YourWall : PointState.OpponentWall; break; default: mapState[x, y] = PointState.Clear; break; } } } return mapState; }