public void SetState(TickState newState) { switch (newState) { case TickState.Hidden: base.gameObject.SetActive(value: false); break; case TickState.Off: base.gameObject.SetActive(value: true); TickSelector.SelectGameObject(0); Highlight.SetActive(value: false); break; case TickState.On: base.gameObject.SetActive(value: true); TickSelector.SelectGameObject(1); Highlight.SetActive(value: false); break; case TickState.Highlighted: base.gameObject.SetActive(value: true); TickSelector.SelectGameObject(1); Highlight.SetActive(value: true); break; } State = newState; }
private Dictionary <int, TickState> createInitialTickState(TaskGraph tasksGraph, ComputingSystem computingSystem) { var readyJobs = new List <Job>(); var readyProcessors = new List <Processor>(); foreach (var job in tasksGraph) { if (!job.Parents.Any()) { readyJobs.Add(job); } } foreach (var proc in computingSystem) { readyProcessors.Add(proc); } var ticksDesc = new Dictionary <int, TickState>(); ticksDesc[1] = new TickState { ReadyJobs = readyJobs, ReadyProcessors = readyProcessors }; return(ticksDesc); }
public void OnTriggerExit2D(Collider2D collision) { state = TickState.ExitingBall; if (tickExit != null) { tickExit(); } }
//exit node manully public void Clear() { if (state != TickState.Ready) { Exit(); state = TickState.Ready; } }
public Result Tick() { if (state == TickState.Ready) { Enter(); state = TickState.Ticking; } Result result = Excute(); if (result != Result.Running) { Exit(); state = TickState.Ready; } return(result); }
void Update() { if (_rTransform.localPosition != tickerPos) { _rTransform.localPosition = Vector3.MoveTowards(_rTransform.localPosition, tickerPos, 40 * Time.deltaTime); } if (moveTimer.IsActive) { moveTimer.AdvanceTimer(Time.deltaTime); switch (state) { case TickState.FadeIn: _text.transform.localPosition = Vector3.Lerp(tickStart, tickEnd, moveTimer.CompletionPercentage); if (moveTimer.IsFinished) { moveTimer.Reset(); state = TickState.Hang; moveTimer.SetDuration(hangTime); moveTimer.Start(); } break; case TickState.Hang: if (moveTimer.IsFinished) { moveTimer.Reset(); state = TickState.FadeOut; moveTimer.SetDuration(fadeDuration); moveTimer.Start(); } break; case TickState.FadeOut: _text.transform.localPosition = Vector3.Lerp(tickEnd, tickFling, moveTimer.CompletionPercentage); _text.color = Color.Lerp(Color.white, new Color(1, 1, 1, 0), moveTimer.CompletionPercentage); if (moveTimer.IsFinished) { GameController.scoreTicker.RemoveTick(this); Destroy(this.gameObject); } break; } } }
public TickStateTransitionTests() { _tickStateTransitionBlackboard = new TickStateTransitionBlackboard(); var tickState1 = new TickState1(new TickStateTransition(TickState2.StateName, _tickStateTransitionBlackboard)); var tickState2 = new TickState2(new TickStateTransition(TickState3.StateName, _tickStateTransitionBlackboard)); var tickState3 = new TickState3(new TickStateTransition(TickState1.StateName, _tickStateTransitionBlackboard)); var states = new TickState[] { tickState1, tickState2, tickState3 }; _stateController = new TickStateController(states); }
private void addTickState( Dictionary <int, TickState> ticksDesc, int tickNumber, List <Job> readyJobs, List <Processor> readyProcessors) { if (!ticksDesc.TryGetValue(tickNumber, out TickState newTicState)) { ticksDesc[tickNumber] = new TickState { ReadyJobs = new List <Job>(readyJobs), ReadyProcessors = new List <Processor>(readyProcessors) }; } else { newTicState.ReadyJobs.AddRange(readyJobs); newTicState.ReadyProcessors.AddRange(readyProcessors); } }
private void SetTimeout(TickState? ts, uint ticks) { if (ts.HasValue) TS = ts.Value; ResetTick(); WaitTimeout = ticks; }
private void PrepareEndGame() { GS = GameState.None; TS = TickState.None; EndGame(); }
public void OnTriggerEnter2D(Collider2D collision) { state = TickState.InsideBall; }
public void Reset() { state = TickState.Moving; }
public void OnResponse(IResponse[] ResponseChain) { switch (tickState) { case TickState.AwaitingResponses: ResponsesRecieved++; // LogStack.Log ("ResponseChain Length: " + ResponseChain.Length, LogLevel.Stack); if (ResponseChain.Length > 0) { // LogStack.Log ("Awaiting Responses, " + ResponsesRecieved + " Players ready", LogLevel.Stack); if (ResponseChain[0].player == TournamentManager._instance.P1) { P1 = ResponseChain; } else { P2 = ResponseChain; } } if (ResponsesRecieved == 2) { ResponsesRecieved = 0; tickState = TickState.PerformingResponses; OnResponse(null); } break; case TickState.ValidateResponses: // LogStack.Log ("Validate Responses | TODO", LogLevel.Stack); //AIResponseManager.Move/Attack/Spawn validate | use code //for loop of the response chain double checks everthing is good // if all good go to TickState.PerformingResponses // if a problem send fail event and go back to TickState.AwaitingResponses: tickState = TickState.PerformingResponses; break; case TickState.PerformingResponses: LogStack.Log("Performing Responses", LogLevel.Stack); if (P1 != null && P2 != null) { alternateTurns = !alternateTurns; if (alternateTurns) { StartCoroutine(PerformActions(P1.Concat(P2).ToArray())); } else { StartCoroutine(PerformActions(P2.Concat(P1).ToArray())); } } else if (P1 != null) { StartCoroutine(PerformActions(P1)); } else { StartCoroutine(PerformActions(P2)); } // stagger out perform phase based on wait times from tournament manager // step to TickState.FireTick: break; case TickState.FireTick: // LogStack.Log ("Fire Tick", LogLevel.Stack); // restart the loop // eject states for win lose conditions // ResponsesRecieved++; // if (ResponsesRecieved == 2) { // ResponsesRecieved = 0; tickState = TickState.AwaitingResponses; TournamentManager._instance.OnTick.Invoke(TournamentManager._instance.lanes.ToArray()); P1 = new IResponse[0]; P2 = new IResponse[0]; // } break; default: break; } }
IEnumerator PerformActions(IResponse[] ResponseChain) { // LogStack.Log ("--- PerformActions BEGIN", LogLevel.System); //Spawning foreach (IResponse response in ResponseChain) { if (response.responseActionType == ResponseActionType.Spawn) { // LogStack.Log ("Response: " + response.player + " | " + response.responseActionType + " in lane " + response.Lane, LogLevel.System); Spawn(response); } } yield return(new WaitForSeconds(TournamentManager._instance.laneReadyWait)); //Move foreach (IResponse response in ResponseChain) { if (response.creature.CreatureType == Spawnable.Bunny && response.responseActionType == ResponseActionType.Move) { // LogStack.Log ("Response: " + response.player + " | " + response.responseActionType + " in lane " + response.Lane, LogLevel.System); if (!response.creature.isDead) { if (response.laneNode.activeCreature == null) { response.creature.Move(response.laneNode); } else { LaneNode nodeBack = response.laneNode.laneManager.PreviousNode(response.laneNode, response.creature.Owner); response.creature.Move(nodeBack); response.creature.Owner.AIResponse.RefundToken(); response.creature.Owner.AIResponse.RefundToken(response.laneNode.laneManager.GetNodeDistance(nodeBack, response.laneNode)); } } else { response.creature.Owner.AIResponse.RefundToken(response.laneNode.laneManager.GetNodeDistance(response.creature.ActiveLaneNode, response.laneNode)); } } else if (response.creature.CreatureType == Spawnable.Unicorn && response.responseActionType == ResponseActionType.Attack) { yield return(new WaitForSeconds(TournamentManager._instance.moveWait)); // LogStack.Log ("Response: " + response.player + " | " + response.responseActionType + " in lane " + response.Lane, LogLevel.System); response.creature.Attack(); LaneNode nextNode = response.laneNode.laneManager.GetNextLaneNode(response.laneNode, response.creature.RightFacing, 1, true); if (response.creature.LaneProgress + 1 >= response.creature.ActiveLaneNode.laneManager.allNodes.Count && nextNode.activeCreature == null) //One node before end { if (!response.creature.isDead) { response.creature.Move(nextNode); } else { response.creature.Owner.AIResponse.RefundToken(); } } } } yield return(new WaitForSeconds(TournamentManager._instance.moveWait)); //Attack foreach (IResponse response in ResponseChain) { if (response.creature.CreatureType == Spawnable.Bunny && response.responseActionType == ResponseActionType.Attack) { // LogStack.Log ("Response: " + response.player + " | " + response.responseActionType + " in lane " + response.Lane, LogLevel.System); response.creature.Attack(); LaneNode nextNode = response.laneNode.laneManager.GetNextLaneNode(response.laneNode, response.creature.RightFacing, 1, true); if (response.creature.LaneProgress + 1 >= response.creature.ActiveLaneNode.laneManager.allNodes.Count && nextNode.activeCreature == null) //One node before end { if (!response.creature.isDead) { if (nextNode.activeCreature == null) { response.creature.Move(nextNode); } else { LaneNode nodeBack = nextNode.laneManager.PreviousNode(nextNode, response.creature.Owner); response.creature.Move(nodeBack); response.creature.Owner.AIResponse.RefundToken(); response.creature.Owner.AIResponse.RefundToken(nextNode.laneManager.GetNodeDistance(nodeBack, nextNode)); } } else { response.creature.Owner.AIResponse.RefundToken(response.laneNode.laneManager.GetNodeDistance(response.creature.ActiveLaneNode, nextNode)); } } } else if (response.creature.CreatureType == Spawnable.Unicorn && response.responseActionType == ResponseActionType.Move) { yield return(new WaitForSeconds(TournamentManager._instance.attackWait)); // LogStack.Log ("Response: " + response.player + " | " + response.responseActionType + " in lane " + response.Lane, LogLevel.System); if (!response.creature.isDead) { response.creature.Move(response.laneNode); } else { response.creature.Owner.AIResponse.RefundToken(); } } } yield return(new WaitForSeconds(TournamentManager._instance.attackWait)); tickState = TickState.FireTick; OnResponse(null); // LogStack.Log ("--- PerformActions END", LogLevel.System); }
public void StartAnim() { state = TickState.FadeIn; moveTimer.SetDuration(moveDuration); moveTimer.Start(); }
public static Tick Tick() { return(TickState.Get().Bind( n => TickState.Put(n + 1).BindIgnoringLeft( TickState.Return(n)))); }