public void CheckBuffs() { Debug.Log("Check board"); ResetBuffs(); for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (points[i, j]) { if (points[i, j].token) { if (points[i, j].token.GetComponent <TokenScript>().tokenObject.buff) { TokenScript tokenScript = points[i, j].token.GetComponent <TokenScript>(); if (tokenScript.tokenObject.meleeAttackBuff.Length > 0) { GiveMeleeBuff(i, j, GetRotatedValues(tokenScript.tokenObject.meleeAttackBuff, tokenScript.rotation), tokenScript.tokenObject.fraction); } if (tokenScript.tokenObject.rangeAttackBuff.Length > 0) { GiveRangeBuff(i, j, GetRotatedValues(tokenScript.tokenObject.rangeAttackBuff, tokenScript.rotation), tokenScript.tokenObject.fraction); } if (tokenScript.tokenObject.initiationBuff.Length > 0) { GiveInitiationBuff(i, j, GetRotatedValues(tokenScript.tokenObject.initiationBuff, tokenScript.rotation), tokenScript.tokenObject.fraction); } } } } } } }
/** * @brief Begin function declaration * @param sdTypes = script-defined types * @param methName = name of the method being declared, eg, "Verify(array,list,string)" * @param retType = its return value type * @param argTypes[] = its argument types * @param objFileWriter = file to write its object code to * * After calling this function, the following functions should be called: * this.BegMethod (); * this.<as required> (); * this.EndMethod (); * * The design of this object is such that many constructors may be called, * but once a BegMethod() is called for one of the objects, no method may * called for any of the other objects until EndMethod() is called (or it * would break up the object stream for that method). But we need to have * many constructors possible so we get function headers at the beginning * of the object file in case there are forward references to the functions. */ public ScriptObjWriter(TokenScript tokenScript, string methName, Type retType, Type[] argTypes, string[] argNames, BinaryWriter objFileWriter) { this._methName = methName; this.retType = retType; this.argTypes = argTypes; this.objFileWriter = objFileWriter; // Build list that translates system-defined types to script defined types. foreach (TokenDeclSDType sdt in tokenScript.sdSrcTypesValues) { Type sys = sdt.GetSysType(); if (sys != null) { sdTypesRev[sys] = sdt.longName.val; } } // This tells the reader to call 'new DynamicMethod()' to create // the function header. Then any forward reference calls to this // method will have a MethodInfo struct to call. objFileWriter.Write((byte)ScriptObjWriterCode.DclMethod); objFileWriter.Write(methName); objFileWriter.Write(GetStrFromType(retType)); int nArgs = argTypes.Length; objFileWriter.Write(nArgs); for (int i = 0; i < nArgs; i++) { objFileWriter.Write(GetStrFromType(argTypes[i])); objFileWriter.Write(argNames[i]); } }
public ScriptManager(string varFilePath, TabPage tabPage, WatchVariableFlowLayoutPanel watchVariablePanel) : base(varFilePath, watchVariablePanel) { SplitContainer splitContainer = tabPage.Controls["splitContainerScript"] as SplitContainer; SplitContainer splitContainerLeft = splitContainer.Panel1.Controls["splitContainerScriptLeft"] as SplitContainer; _checkBoxScriptRunContinuously = splitContainerLeft.Panel1.Controls["checkBoxScriptRunContinuously"] as CheckBox; _buttonScriptRunOnce = splitContainerLeft.Panel1.Controls["buttonScriptRunOnce"] as Button; _buttonScriptInstructions = splitContainerLeft.Panel1.Controls["buttonScriptInstructions"] as Button; _buttonScriptExamples = splitContainerLeft.Panel1.Controls["buttonScriptExamples"] as Button; SplitContainer splitContainerLeft2 = splitContainerLeft.Panel2.Controls["splitContainerScriptLeft2"] as SplitContainer; _richTextBoxScript = splitContainerLeft2.Panel1.Controls["richTextBoxScript"] as RichTextBoxEx; _richTextBoxConsole = splitContainerLeft2.Panel2.Controls["richTextBoxConsole"] as RichTextBoxEx; _consoleStrings = new List <string>(); _script = new TokenScript(_consoleStrings); _checkBoxScriptRunContinuously.Click += (sender, e) => { _richTextBoxScript.ReadOnly = _checkBoxScriptRunContinuously.Checked; }; _buttonScriptRunOnce.Click += (sender, e) => { RunScript(); }; _buttonScriptInstructions.Click += (sender, e) => { InfoForm.ShowValue( string.Join("\r\n", _instructions), "Instructions", "Instructions"); }; _buttonScriptExamples.ContextMenuStrip = new ContextMenuStrip(); for (int i = 0; i < _exampleNames.Count; i++) { ToolStripMenuItem item = new ToolStripMenuItem(_exampleNames[i]); string text = string.Join("\r\n", _exampleLines[i]); item.Click += (sender, e) => _richTextBoxScript.Text = text; _buttonScriptExamples.ContextMenuStrip.Items.Add(item); } _buttonScriptExamples.Click += (sender, e) => _buttonScriptExamples.ContextMenuStrip.Show(Cursor.Position); ToolStripMenuItem itemClearConsole = new ToolStripMenuItem("Clear Console"); itemClearConsole.Click += (sender, e) => { _consoleStrings.Clear(); _richTextBoxConsole.Clear(); }; _richTextBoxConsole.ContextMenuStrip = new ContextMenuStrip(); _richTextBoxConsole.ContextMenuStrip.Items.Add(itemClearConsole); }
void createToken(Vector3 position, Colours tokenColour, int index) { TokenObject = Instantiate(Instance.TokenToSpawn); TokenObject.transform.SetParent(Instance.transform, false); TokenObject.transform.position = position; TokenScript = TokenObject.GetComponent <TokenScript>(); Renderer rend = TokenObject.GetComponent <Renderer>(); SetColour(tokenColour, rend); TokenScript.setid(index); TokenScript.setColour(tokenColour); }
public void TokenPickup(TokenScript token) { Score += 1; SpawnToken (token.transform.parent); var s = Instantiate (token.Pickup) as Transform; s.position = token.transform.position; Destroy (s.gameObject, 1); Destroy (token.gameObject); foreach (var g in Geysers) { if (Random.Range (0, 100) < Score) { g.Enable (); } else { g.Disable (); } } _timer = TimeLimit; }
public void Battle() { Debug.Log("Battle started"); CheckBuffs(); int init = GetHighestInitiation(); for (int a = init; a >= 0; a--) { for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (points[i, j]) { if (points[i, j].token) { if (points[i, j].token.GetComponent <TokenScript>().initiation == a) { TokenScript tokenScript = points[i, j].token.GetComponent <TokenScript>(); if (tokenScript.tokenObject.attackMelee.Length > 0) { AttackMelee(i, j, GetRotatedValues(tokenScript.tokenObject.attackMelee, tokenScript.rotation), tokenScript.meleeBuff, tokenScript.tokenObject.fraction); } if (tokenScript.tokenObject.attackRange.Length > 0) { AttackRange(i, j, GetRotatedValues(tokenScript.tokenObject.attackRange, tokenScript.rotation), tokenScript.meleeBuff, tokenScript.tokenObject.fraction); } if (tokenScript.tokenObject.attackGauss.Length > 0) { AttackGauss(i, j, GetRotatedValues(tokenScript.tokenObject.attackGauss, tokenScript.rotation), tokenScript.meleeBuff, tokenScript.tokenObject.fraction); } } } } } } DestroyTokens(); CheckBuffs(); } }
/** * @brief Compile a script to produce a ScriptObjCode object * @returns object code pointer or null if compile error * also can throw compile error exception */ public ScriptObjCode Compile() { Stream objFileStream = null; StreamWriter asmFileWriter = null; string sourceHash = null; TextWriter saveSource = null; string objFileName = GetScriptFileName(m_ScriptObjCodeKey + ".yobj"); string tmpFileName = GetScriptFileName(m_ScriptObjCodeKey + ".ytmp"); // If we already have an object file, don't bother compiling. if (!m_ForceRecomp && File.Exists(objFileName)) { objFileStream = File.OpenRead(objFileName); } else { // If source file empty, try to read from asset server. if (EmptySource(m_SourceCode)) { m_SourceCode = FetchSource(m_CameFrom); } // Maybe write script source to a file for debugging. if (m_Engine.m_ScriptDebugSaveSource) { string lslFileName = GetScriptFileName(m_ScriptObjCodeKey + ".lsl"); // m_log.Debug ("[YEngine]: MMRScriptCompileSaveSource: saving to " + lslFileName); saveSource = File.CreateText(lslFileName); } // Parse source string into tokens. TokenBegin tokenBegin; try { tokenBegin = TokenBegin.Construct(m_CameFrom, saveSource, ErrorHandler, m_SourceCode, out sourceHash); } finally { if (saveSource != null) { saveSource.Close(); } } if (tokenBegin == null) { m_log.Debug("[YEngine]: parsing errors on " + m_ScriptObjCodeKey); return(null); } // Create object file one way or another. try { // Create abstract syntax tree from raw tokens. TokenScript tokenScript = ScriptReduce.Reduce(tokenBegin); if (tokenScript == null) { m_log.Warn("[YEngine]: reduction errors on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); PrintCompilerErrors(); return(null); } // Compile abstract syntax tree to write object file. using (BinaryWriter objFileWriter = new BinaryWriter(File.Create(tmpFileName))) { bool ok = ScriptCodeGen.CodeGen(tokenScript, objFileWriter, sourceHash); if (!ok) { m_log.Warn("[YEngine]: compile error on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); PrintCompilerErrors(); return(null); } } // File has been completely written. // If there is an old one laying around, delete it now. // Then re-open the new file for reading from the beginning. if (File.Exists(objFileName)) { File.Replace(tmpFileName, objFileName, null); } else { File.Move(tmpFileName, objFileName); } objFileStream = File.OpenRead(objFileName); } finally { // In case something went wrong writing temp file, delete it. File.Delete(tmpFileName); } // Since we just wrote the .xmrobj file, maybe save disassembly. if (m_Engine.m_ScriptDebugSaveIL) { string asmFileName = GetScriptFileName(m_ScriptObjCodeKey + ".yasm"); // m_log.Debug ("[YEngine]: MMRScriptCompileSaveILGen: saving to " + asmFileName); asmFileWriter = File.CreateText(asmFileName); } } // Read object file to create ScriptObjCode object. // Maybe also write disassembly to a file for debugging. BinaryReader objFileReader = new BinaryReader(objFileStream); ScriptObjCode scriptObjCode = null; try { scriptObjCode = new ScriptObjCode(objFileReader, asmFileWriter, null); } finally { objFileReader.Close(); if (asmFileWriter != null) { asmFileWriter.Flush(); asmFileWriter.Close(); } } return(scriptObjCode); }
// Use this for initialization void Start() { ts = GameObject.Find("spinner").GetComponent <TokenScript>(); }
/** * @brief Compile a script to produce a ScriptObjCode object * @returns object code pointer or null if compile error * also can throw compile error exception */ public ScriptObjCode Compile() { bool oldObjFile = false; Stream objFileStream = null; StreamWriter asmFileWriter = null; string envar = null; string sourceHash = null; TextWriter saveSource = null; string asmFileName = GetScriptFileName(m_ScriptObjCodeKey + ".xmrasm"); string lslFileName = GetScriptFileName(m_ScriptObjCodeKey + ".lsl"); string objFileName = GetScriptFileName(m_ScriptObjCodeKey + ".xmrobj"); string tmpFileName = GetScriptFileName(m_ScriptObjCodeKey + ".xmrtmp"); /* * If we already have an object file, don't bother compiling. */ if (!m_ForceRecomp && File.Exists(objFileName)) { objFileStream = File.OpenRead(objFileName); oldObjFile = true; } else { /* * If source file empty, try to read from asset server. */ if (EmptySource(m_SourceCode)) { m_SourceCode = FetchSource(m_CameFrom); } /* * Maybe write script source to a file for debugging. */ envar = Environment.GetEnvironmentVariable("MMRScriptCompileSaveSource"); if ((envar != null) && ((envar[0] & 1) != 0)) { m_log.Debug("[XMREngine]: MMRScriptCompileSaveSource: saving to " + lslFileName); saveSource = File.CreateText(lslFileName); } /* * Parse source string into tokens. */ TokenBegin tokenBegin; try { tokenBegin = TokenBegin.Construct(m_CameFrom, saveSource, ErrorHandler, m_SourceCode, out sourceHash); } finally { if (saveSource != null) { saveSource.Close(); } } if (tokenBegin == null) { m_log.Debug("[XMREngine]: parsing errors on " + m_ScriptObjCodeKey); return(null); } /* * Create object file one way or another. */ try { objFileStream = File.Create(tmpFileName); /* * Create abstract syntax tree from raw tokens. */ TokenScript tokenScript = ScriptReduce.Reduce(tokenBegin); if (tokenScript == null) { m_log.Warn("[XMREngine]: reduction errors on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); PrintCompilerErrors(); return(null); } /* * Compile abstract syntax tree to write object file. */ BinaryWriter objFileWriter = new BinaryWriter(objFileStream); bool ok = ScriptCodeGen.CodeGen(tokenScript, objFileWriter, sourceHash); if (!ok) { m_log.Warn("[XMREngine]: compile error on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); PrintCompilerErrors(); objFileStream.Close(); return(null); } objFileStream.Close(); /* * File has been completely written. * If there is an old one laying around, delete it now. * Then re-open the new file for reading from the beginning. */ if (File.Exists(objFileName)) { File.Replace(tmpFileName, objFileName, null); } else { File.Move(tmpFileName, objFileName); } objFileStream = File.OpenRead(objFileName); } finally { /* * In case something went wrong writing temp file, delete it. */ try { File.Delete(tmpFileName); } catch { } } /* * Since we just wrote the .xmrobj file, maybe save disassembly. */ envar = Environment.GetEnvironmentVariable("MMRScriptCompileSaveILGen"); if ((envar != null) && ((envar[0] & 1) != 0)) { m_log.Debug("[XMREngine]: MMRScriptCompileSaveILGen: saving to " + asmFileName); asmFileWriter = File.CreateText(asmFileName); } } /* * Read object file to create ScriptObjCode object. * Maybe also write disassembly to a file for debugging. */ BinaryReader objFileReader = new BinaryReader(objFileStream); ScriptObjCode scriptObjCode = null; try { scriptObjCode = new ScriptObjCode(objFileReader, asmFileWriter, null); if (scriptObjCode != null) { scriptObjCode.fileDateUtc = File.GetLastWriteTimeUtc(objFileName); } } finally { objFileReader.Close(); if (asmFileWriter != null) { asmFileWriter.Flush(); asmFileWriter.Close(); } } /* * Maybe an old object file has reached its expiration date. */ if (oldObjFile && (scriptObjCode != null) && scriptObjCode.IsExpired()) { m_log.Debug("[XMREngine]: expiration reached on " + m_ScriptObjCodeKey + ", reloading"); m_ForceRecomp = true; scriptObjCode = Compile(); } return(scriptObjCode); }
void Update() { if (openDoor == false) { if (Input.GetKeyDown(KeyCode.J)) { tokenSelect = true; arrowSelect = arrowPosition; } if ((Input.GetKeyDown(KeyCode.D)) & (transform.position.x < 2.2)) { transform.position = new Vector3(transform.position.x + 1.1f, transform.position.y, transform.position.z); arrowPosition++; if (tokenSelect) { //creo un clon de la ficha a amover tokenAux = Instantiate(tokenPosition [arrowSelect]); tokenAux.transform.position = tokenPosition [arrowSelect].transform.position; //intercambio las pocisiones de las fichas tokenPosition [arrowSelect].transform.position = tokenPosition [arrowPosition].transform.position; tokenPosition [arrowPosition].transform.position = tokenAux.transform.position; tokenAux2 = tokenPosition [arrowSelect]; //intercambio las pocisiones en el vector tokenPosition [arrowSelect] = tokenPosition [arrowPosition]; tokenPosition [arrowPosition] = tokenAux2; tokenSelect = false; Destroy(tokenAux); } } if ((Input.GetKeyDown(KeyCode.A)) & (transform.position.x > -2.2)) { transform.position = new Vector3(transform.position.x - 1.1f, transform.position.y, transform.position.z); arrowPosition--; if (tokenSelect) { //creo un clon de la ficha a amover tokenAux = Instantiate(tokenPosition [arrowSelect]); tokenAux.transform.position = tokenPosition [arrowSelect].transform.position; //intercambio las pocisiones de las fichas tokenPosition [arrowSelect].transform.position = tokenPosition [arrowPosition].transform.position; tokenPosition [arrowPosition].transform.position = tokenAux.transform.position; tokenAux2 = tokenPosition [arrowSelect]; //intercambio las pocisiones en el vector tokenPosition [arrowSelect] = tokenPosition [arrowPosition]; tokenPosition [arrowPosition] = tokenAux2; tokenSelect = false; Destroy(tokenAux); } } for (int i = 0; i <= 4; i++) { TokenScript script = tokenPosition [i].GetComponent <TokenScript> (); if (!script.checkCorrectPosition) { //print("break"); break; } if (i == 4) { camPuzzle.GetComponent <Camera> ().enabled = false; camMain.GetComponent <Camera> ().enabled = true; DontDestroyOnLoad(this.gameObject); openDoor = true; Time.timeScale = 1.00f; SceneManager.UnloadSceneAsync("Generator"); } } } }
public ScriptTab() { InitializeComponent(); _script = new TokenScript(); }