void OnEnable() { tutorialMode = true; msgBanner = GameObject.Find("MsgBanner"); msg = msgBanner.transform.Find("Msg").gameObject.GetComponent <Text>(); note = msgBanner.transform.Find("Note").gameObject; panel = msgBanner.transform.Find("Panel").gameObject; GameObject gameManager = GameObject.Find("GameManager"); setGame = gameManager.GetComponent <SetGame>(); scoreKeeper = gameManager.GetComponent <ScoreKeeper>(); GameObject instructions = GameObject.Find("Instructions"); instrucCtrl = instructions.GetComponent <InstructionControl>(); GameObject human = GameObject.FindGameObjectWithTag("Human"); leaderHexCtrl = human.GetComponent <HexToHexControl>(); if (role == "Human") { msg.text = "Welcome to the <b>Leader Tutorial</b>! Complete all steps to get started playing the game!"; } else if (role == "Agent") { msg.text = "Welcome to the <b>Follower Tutorial</b>! Complete all steps to get started playing the game!"; } }
void OnEnable() { startUIControl = FindObjectOfType <StartUIControl>(); setUpUIControl = FindObjectOfType <SetUpUIControl>(); instructionControl = FindObjectOfType <InstructionControl>(); playUI = FindObjectOfType <PlayUI>(); turnController = FindObjectOfType <TurnController>(); }
/* * Configure UI elements for turns, get externalHandlers for characters, */ public void SetUpTurns() { turnsLeft = initialTurns; //extraTurnsLeft = extraTurns; gameNotOver = true; instructionControl = FindObjectOfType <InstructionControl>(); timeKeeper = FindObjectOfType <TimeKeeper>(); var them = GameObject.FindGameObjectWithTag(character == "Human"?"Agent":"Human"); if (them) { theirHandler = them.GetComponent <ExternalActionHandler>(); } var me = GameObject.FindGameObjectWithTag(character); if (me) { myHandler = me.GetComponent <ExternalActionHandler>(); } if (character == "Human") { movesRemaining = leadersMovesPerTurn; myTurn = true; moveDisplay.text = "Moves Left: " + leadersMovesPerTurn + " Moves Left in Turn"; // Initially the end-turn button should be disabled so the leader must // put in a command during their turn. endTurnButton.interactable = false; #if UNITY_WEBGL if (!TutorialGuide.tutorialMode) { backgroundImage.material.SetColor("_Color", gameGreen); backgroundImage.material.SetColor("_Color2", gameGreen); } #endif } else //character=="Agent" { movesRemaining = followersMovesPerTurn; myTurn = false; moveDisplay.text = "Moves Left: Waiting for partner!"; if (!TutorialGuide.tutorialMode) { backgroundImage.material.SetColor("_Color", gamePink); backgroundImage.material.SetColor("_Color2", gamePink); } } // (turnsLeft+1)/2 to show half the num turns left correctly w/ int division totalTurnsDisplay.text = "Turns Left: " + (turnsLeft + 1) / 2; if (TutorialGuide.tutorialMode) { theirHandler.GiveTurn(); GetTurn(); } // Fix movement for tutorial role. }
void OnEnable() { GrabMoveScripts(); agentCBS = FindObjectOfType <ConditionalBools>(); webSocketManager = FindObjectOfType <WebSocketManager>(); instructionControl = FindObjectOfType <InstructionControl>(); turnController = FindObjectOfType <TurnController>(); ConditionalBools.OnGBoolMetEvent += codeboolMet; //initialize the list objects to store commands and set currInstrIdx to 0 instrBuffer = new List <string>(); currInstrIdx = 0; }
private void initCodeWindow() { CodeSection.Children.Clear(); List <DecodedInstruction> code = chip8.decodedRom(); for (int i = 0; i < code.Count; i++) { InstructionControl x = new InstructionControl(code[i].getAddrStringFormat() + ": " + code[i].getOpcodeStringFormat(), code[i].MnemonicInstuc, code[i].Description, (ushort)(Chip8.ROM_BASE_ADDR + code[i].AddrOfInstruc)); x.brkPtHandler = DelegateBrkPtMethod; CodeSection.Children.Add(x); } }
private void breakPtList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (breakPtList.SelectedItem != null) { //MessageBox.Show(breakPtList.SelectedItem.ToString()); String textVal = ((ListBoxItem)breakPtList.SelectedItem).Content.ToString().Substring(8); ushort selectedVal = (ushort)Convert.ToInt32(textVal, 16); //select instruction in codeview for (int i = 0; i < CodeSection.Children.Count; i++) { InstructionControl code = (InstructionControl)CodeSection.Children[i]; if (code.Addr == selectedVal) { code.BringIntoView(); } } } }
private void AssignmentVariable_SelectedIndexChanged(object sender, EventArgs e) { SelectedVariable = (Variable)AssignmentVariable.SelectedItem; InstructionControl = new InstructionControl(ScopeVariables, SelectedVariable) { Dock = DockStyle.Fill }; InstructionPanel.Controls.Clear(); InstructionPanel.Controls.Add(InstructionControl); Assignment.Instruction = InstructionControl.Instruction; if (SelectedVariable.IsArray) { Rows.Items.Clear(); Columns.Items.Clear(); if (SelectedVariable.ArrayType == "1D") { Rows.Visible = true; for (int i = 0; i < SelectedVariable.Row; i++) { Rows.Items.Add(i); } if (SelectedVariable.Row == 0) { Rows.Items.Add(0); } foreach (var variable in ScopeVariables) { if (!variable.IsArray && variable.Type == Enums.Type.Int) { Rows.Items.Add(variable); } } Columns.Visible = false; } if (SelectedVariable.ArrayType == "2D") { Rows.Visible = true; for (int i = 0; i < SelectedVariable.Row; i++) { Rows.Items.Add(i); } if (SelectedVariable.Row == 0) { Rows.Items.Add(0); } Columns.Visible = true; for (int i = 0; i < SelectedVariable.Column; i++) { Columns.Items.Add(i); } if (SelectedVariable.Column == 0) { Columns.Items.Add(0); } foreach (var variable in ScopeVariables) { if (!variable.IsArray && variable.Type == Enums.Type.Int) { Rows.Items.Add(variable); Columns.Items.Add(variable); } } } } else { Rows.Items.Clear(); Columns.Items.Clear(); Rows.Visible = false; Columns.Visible = false; } }
private void updateDebugger(bool breakPointFlag) { //load Vreg values into interface V0InputBox.Text = "0x" + (chip8.VRegs[0].ToString("x2")).ToUpper(); V1InputBox.Text = "0x" + (chip8.VRegs[1].ToString("x2")).ToUpper(); V2InputBox.Text = "0x" + (chip8.VRegs[2].ToString("x2")).ToUpper(); V3InputBox.Text = "0x" + (chip8.VRegs[3].ToString("x2")).ToUpper(); V4InputBox.Text = "0x" + (chip8.VRegs[4].ToString("x2")).ToUpper(); V5InputBox.Text = "0x" + (chip8.VRegs[5].ToString("x2")).ToUpper(); V6InputBox.Text = "0x" + (chip8.VRegs[6].ToString("x2")).ToUpper(); V7InputBox.Text = "0x" + (chip8.VRegs[7].ToString("x2")).ToUpper(); V8InputBox.Text = "0x" + (chip8.VRegs[8].ToString("x2")).ToUpper(); V9InputBox.Text = "0x" + (chip8.VRegs[9].ToString("x2")).ToUpper(); VAInputBox.Text = "0x" + (chip8.VRegs[0xA].ToString("x2")).ToUpper(); VBInputBox.Text = "0x" + (chip8.VRegs[0xB].ToString("x2")).ToUpper(); VCInputBox.Text = "0x" + (chip8.VRegs[0xC].ToString("x2")).ToUpper(); VDInputBox.Text = "0x" + (chip8.VRegs[0xD].ToString("x2")).ToUpper(); VEInputBox.Text = "0x" + (chip8.VRegs[0xE].ToString("x2")).ToUpper(); VFInputBox.Text = "0x" + (chip8.VRegs[0xF].ToString("x2")).ToUpper(); //load specialized registers IndexInputBox.Text = "0x" + (chip8.Ireg1.ToString("x2")).ToUpper(); pcInputBox.Text = "0x" + (chip8.Pc.ToString("x2")).ToUpper(); DelayTimerInputBox.Text = "0x" + (chip8.DelayTimer.ToString("x2")).ToUpper(); SoundTimerInputBox.Text = "0x" + (chip8.SoundTimer.ToString("x2")).ToUpper(); //select instruction in codeview for (int i = 0; i < CodeSection.Children.Count; i++) { InstructionControl code = (InstructionControl)CodeSection.Children[i]; if (code.Addr == chip8.Pc) { if (currSelectedCode > -1) { InstructionControl previousInstruc = (InstructionControl)CodeSection.Children[currSelectedCode]; previousInstruc.selectLine(false); } code.selectLine(true); code.BringIntoView(); currSelectedCode = i; if (breakPointFlag) { //code.Background = Brushes.Red; breakPointTrigger = true; } } } //load stack byte[] stack = chip8.Stack; string stackOutput = ""; if (stack != null) { for (int j = 0; j < stack.Length; j++) { if (stack[j] != 0) { stackOutput = stackOutput + "0x" + ((Chip8.STACK_BASE_ADDR - 1) - j).ToString("x2").ToUpper() + ": 0x" + stack[j].ToString("x2").ToUpper(); } else { stackOutput = stackOutput + "0x" + ((Chip8.STACK_BASE_ADDR - 1) - j).ToString("x2").ToUpper() + ": 0x00"; } if (j != (stack.Length - 1)) { stackOutput = stackOutput + "\n"; } } //stackOutput = stackOutput.Substring(0, (stackOutput.Length - 1)); stackBox.Text = stackOutput; } //updateHexEditor loadHexEditor(); }
/// <summary> /// Processes the request in queue /// start, seed /// restart,seed /// /// start information: See GetMapInfo in InformationGetter Script to view all the types and information sent /// <bodytocontrol>,<move> /// status human /// status agent /// /// image overhead: sends a byte array of the image taken from the overhead camera /// image human: sends a byte array of the image taken for the human camera /// image agent: sends a byte array of the image taken for the agent camera /// </summary> /// <param name="msg"></param> private IEnumerator ProcessMsgRequest(string msg) { msg = msg.Trim(); //TODO make it wait until the processing flag is false Debug.Log("Message: " + msg); switch (msg) { case "grammer": InstructionControl instructionControl = FindObjectOfType <InstructionControl>(); var command = myCommands.Dequeue(); instructionControl.DisplayInstruction(command); yield return(null); socketStarter.CerealSendMsg("123"); break; case "state": var stateJson = myCommands.Dequeue(); var setState = startup.SetState(stateJson); if (!setState) { socketStarter.CerealSendMsg("Failed - game not started"); } socketStarter.CerealSendMsg(""); break; case "goaldist": var goalJson = myCommands.Dequeue(); propPlacement.SetGoalDist(goalJson); socketStarter.CerealSendMsg(""); break; case "trajdist": var trajJson = myCommands.Dequeue(); propPlacement.SetTrajectoryDist(trajJson); socketStarter.CerealSendMsg(""); break; case "obsdist": var obsJson = myCommands.Dequeue(); propPlacement.SetObstacleDist(obsJson); socketStarter.CerealSendMsg(""); break; case "avoiddist": var avoidJson = myCommands.Dequeue(); propPlacement.SetAvoidDist(avoidJson); socketStarter.CerealSendMsg(""); break; case "newcards": var cardsJson = myCommands.Dequeue(); propPlacement.AddCards(JsonUtility.FromJson <CardLists>(cardsJson)); socketStarter.CerealSendMsg(""); break; case "start": // dequeue get seed number; var splitM = myCommands.Dequeue().Split(','); // splitM is in the format "seed/numcards" var seed = 0; var parsed = int.TryParse(splitM[0].Trim(), out seed); var numCards = 0; var numCardsParsed = int.TryParse(splitM[1].Trim(), out numCards); // Now get the number of cards if (!parsed || !numCardsParsed) { socketStarter.CerealSendMsg("Failed - expected integer for map seed start"); } else { var result = startup.StandaloneStartWithSeed(seed, numCards); if (result) { } else { socketStarter.CerealSendMsg("Failed - game already started"); } //send start information - need to wait for the proplacement event } //set the map seed // UI start map break; case "restart": //Resources.UnloadUnusedAssets(); string sss = SceneManager.GetActiveScene().name; SceneManager.LoadScene("Game"); break; case "info": yield return(null); var info = infoGetter.GetStateDelta(); socketStarter.CerealSendMsg(info); break; case "score": ScoreKeeper scoreKeeper = FindObjectOfType <ScoreKeeper>(); int tmpScore = scoreKeeper.score; socketStarter.CerealSendMsg(tmpScore.ToString()); break; case "finishcommand": if (commandCommunication == null) { commandCommunication = FindObjectOfType <CommandCommunication>(); } commandCommunication.ReplayFinishCommand(); socketStarter.CerealSendMsg(""); break; case "turn": turnController.GiveTurn("Switched From Python"); socketStarter.CerealSendMsg(""); break; case "agent": Debug.Log("Agent is moving"); splitM = myCommands.Dequeue().Split(','); var movement = splitM[0].Trim(); var ret = MovementHandler(agentHandler, movement); info = infoGetter.GetStateDelta(); socketStarter.CerealSendMsg(info); break; case "human": Debug.Log("Human is moving"); splitM = myCommands.Dequeue().Split(','); movement = splitM[0].Trim(); ret = MovementHandler(humanHandler, movement); info = infoGetter.GetStateDelta(); socketStarter.CerealSendMsg(info); break; case "image overhead": pic = infoGetter.GetScreenShotImageView("overhead"); socketStarter.CerealSendMsg(pic); break; case "image human": waitingForActionCompletion = true; StartCoroutine(infoGetter.GetPOVImg("human")); break; case "image agent": waitingForActionCompletion = true; StartCoroutine(infoGetter.GetPOVImg("agent")); break; case "status agent": socketStarter.CerealSendMsg(infoGetter.GetAgentMoveInfo("Agent")); break; case "status human": socketStarter.CerealSendMsg(infoGetter.GetAgentMoveInfo("Human")); break; case "quit": case "exit": socketStarter.CloseConnection(); Application.Quit(); break; default: socketStarter.CerealSendMsg(""); break; } yield return(null); isProcessingInstruction = false; yield return(null); yield break; }