void Start() { sharedVariables = GameObject.FindGameObjectWithTag("Variables"); if (sharedVariables == null) { Instantiate(sharedVariablesPre, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)); sharedVariables = GameObject.FindGameObjectWithTag("Variables"); sharedVariablesScript = sharedVariables.GetComponent<SharedVariables>(); NOFTvalue.text = NOFTslider.value.ToString(); NOFRvalue.text = NOFRslider.value.ToString(); Randomvalue.text = Randomslider.value.ToString(); if (Seedslider.value == 1) Seedvalue.text = "None"; else Seedvalue.text = (Seedslider.value - 1f).ToString(); sharedVariablesScript.numOfRows = (int)NOFRslider.value; sharedVariablesScript.numOfTrees = (int)NOFTslider.value; sharedVariablesScript.seed = (int)Seedslider.value - 1; sharedVariablesScript.randomValue = (int)Randomslider.value; } else { sharedVariablesScript = sharedVariables.GetComponent<SharedVariables>(); NOFTvalue.text = sharedVariablesScript.numOfTrees.ToString(); NOFRvalue.text = sharedVariablesScript.numOfRows.ToString(); if (sharedVariablesScript.seed == 0) Seedvalue.text = "None"; else Seedvalue.text = (sharedVariablesScript.seed).ToString(); NOFRslider.value = sharedVariablesScript.numOfRows; NOFTslider.value = sharedVariablesScript.numOfTrees; Seedslider.value = sharedVariablesScript.seed + 1; Randomslider.value = sharedVariablesScript.randomValue; } }
public override void OnInspectorGUI() { var originalText = ((RinityText)target).originalText; var style = new GUIStyle(GUI.skin.FindStyle("HelpBox")); if (string.IsNullOrEmpty(originalText)) { originalText = ((RinityText)target).GetComponent <Text>().text; } var keys = SharedVariables.GetBoundKeys(originalText); style.richText = true; foreach (var key in keys) { originalText = originalText.Replace(key, "<b><color=blue>" + key + "</color></b>"); } EditorGUILayout.Space(); EditorGUILayout.LabelField(originalText, style); fold = EditorGUILayout.Foldout(fold, "TargetVariable(s)"); EditorGUI.indentLevel++; if (fold) { foreach (var key in keys) { EditorGUILayout.LabelField(key); } } EditorGUI.indentLevel--; }
public void DestroyMe() { SharedVariables sH = FindObjectOfType <SharedVariables>(); if (sH.gameOver) { return; } bombAlerter.text = ""; #region if it was a bomb do this if (isBomb) { sH.currentBombs = null; isBomb = false; } #endregion #region Check for whether it will be bomb or not if (sH.Score - sH.lastScoreBombCreated >= mapProperties.ScoreToCreateBomb) { sH.lastScoreBombCreated = sH.Score; sH.currentBombs = this; isBomb = true; bombRemainingTurn = mapProperties.BombExplosionTime; GetComponent <SpriteRenderer>().sprite = mapProperties.bombSprite; } else { GetComponent <SpriteRenderer>().sprite = defaultSprite; } #endregion Explode("explosion", explosionParticle); SpriteRenderer renderer = gameObject.GetComponent <SpriteRenderer>(); renderer.enabled = false; sV.currentLayerOrder--; renderer.sortingOrder = sV.currentLayerOrder; int selectedColorIndex = Random.Range(0, mapProperties.colorCount); renderer.color = mapProperties.colors[selectedColorIndex]; bombAlerter.enabled = false; color = renderer.color; isSelected = false; currentGrid.assignedCell = null; sV.cellQueue.Add(this, topGrid); markedForDestruction = false; sH.Score += 5; }
protected override void OnSetup() { toggle = GetComponent <Toggle>(); // SET toggle.onValueChanged.AddListener((isOn) => { SharedVariables.Set <bool>(targetVariableName, isOn); }); }
protected override void OnSetup() { slider = GetComponent <Slider>(); // SET slider.onValueChanged.AddListener((value) => { SharedVariables.SetWithSender <float>(targetVariableName, value, this); }); }
void OnDisable() { var keys = SharedVariables.GetBoundKeys(originalText); foreach (var key in keys) { PubSub.UnsubscribeNotifyChange(key, handlers[key]); } handlers.Clear(); }
void Awake() { sharedObject = GameObject.FindGameObjectsWithTag("SharedObject")[0] as GameObject; v = sharedObject.GetComponent <SharedVariables> (); byte[] data = v.imageData; int w = v.width; int h = v.height; gameLevel = v.level; loadImage(data, w, h); }
private void Awake() { SpriteRenderer renderer = GetComponent <SpriteRenderer>(); defaultSprite = renderer.sprite; renderer.sortingOrder = -10; borderObject.GetComponent <SpriteRenderer>().enabled = isSelected; bombAlerter = transform.Find("Canvas/Counter").GetComponent <Text>(); targetPos = currentGrid.transform.position; gM = FindObjectOfType <GridManager>(); mapProperties = FindObjectOfType <MapDesignerProperties>(); sV = FindObjectOfType <SharedVariables>(); topGrid = GetTopGrid(currentGrid); }
protected override void OnSetup() { input = GetComponent <InputField>(); // SET UnityEvent <string> targetEvent = input.onValueChanged; if (publishOnSubmit) { targetEvent = input.onEndEdit; } targetEvent.AddListener((text) => { SharedVariables.Set <string>(targetVariableName, text); }); }
void UpdateInfo(ARTrackedImage trackedImage) { // Disable the visual plane if it is not being tracked if (trackedImage.trackingState != TrackingState.None) { SharedVariables clientShared = null; SharedVariables serverShared = null; foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Respawn")) { SharedVariables sharedVariables = obj.GetComponent <SharedVariables>(); if (sharedVariables.isLocalPlayer) { if (sharedVariables.isServer) { serverShared = sharedVariables; } if (!sharedVariables.isServer) { clientShared = sharedVariables; } } else { if (sharedVariables.isServer) { clientShared = sharedVariables; } if (!sharedVariables.isServer) { serverShared = sharedVariables; } } } //UnityEngine.Debug.Log("Server scale : " + sharedVariables.getScale().x); //trackedImage.transform.localScale = new Vector3(clientShared.getScale().x, clientShared.getScale().y, clientShared.getScale().z); trackedImage.transform.localScale = new Vector3(serverShared.getScale().x, serverShared.getScale().y, serverShared.getScale().z); trackedImage.transform.rotation = serverShared.getRotation(); //trackedImage.transform.rotation = clientShared.getRotation(); } }
void OnEnable() { var keys = SharedVariables.GetBoundKeys(originalText); text.text = SharedVariables.Bind(originalText); foreach (var key in keys) { Action <IPubSubMessage> handler = (_message) => { var message = (NotifyChangeMessage)_message; text.text = SharedVariables.Bind(originalText); }; handlers[key] = handler; PubSub.SubscribeNotifyChange(key, handler); } }
public void UpdateTemplate(string templateString) { originalText = templateString; var keys = SharedVariables.GetBoundKeys(originalText); text.text = SharedVariables.Bind(originalText); foreach (var key in keys) { Action <IPubSubMessage> handler = (_message) => { var message = (NotifyChangeMessage)_message; text.text = SharedVariables.Bind(originalText); }; AddHandler(key, handler); } }
// When the script starts, get image data from "sharedObject" void Awake() { audioControll = GameObject.Find("AudioController").GetComponent <AudioControll> (); sharedObject = GameObject.FindGameObjectsWithTag("SharedObject")[0] as GameObject; v = sharedObject.GetComponent <SharedVariables> (); byte[] data = v.imageData; int w = v.width; int h = v.height; gameLevel = v.level; puzzleSize = gameLevel * gameLevel; withTips = v.withTips; if (data.Length == 0 || w == 0 || h == 0) { errorBox.SetActive(true); } else { loadImage(data, w, h); } shuffle(puzzleSize); if (gameLevel == 2) { GameSpace_2x2.SetActive(true); } else if (gameLevel == 3) { GameSpace_3x3.SetActive(true); } else if (gameLevel == 4) { GameSpace_4x4.SetActive(true); } StartCoroutine(StartToRemember()); }
/// <summary> /// Prevent plugin from running multiple times for the same context /// </summary> public bool IsDuplicatePluginExecution() { // Delete message can't be called twice so can ignore if (Event.MessageName == "Delete") { return(false); } var key = $"{PluginTypeName}|{MessageName}|{PipelineStage.ToString()}|{PrimaryEntityId}|{Mode}"; // Check if key exists in shared variables if (this.GetSharedVariable <bool>(key) == true) { return(true); } // Add key to shared variables SharedVariables.Add(key, true); return(false); }
private void Update() { //UnityEngine.Debug.Log(transform.localScale); //UnityEngine.Debug.Log(savedScale); SharedVariables clientShared = null; SharedVariables serverShared = null; foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Respawn")) { SharedVariables sharedVariables = obj.GetComponent <SharedVariables>(); if (sharedVariables.isLocalPlayer) { if (sharedVariables.isServer) { serverShared = sharedVariables; } if (!sharedVariables.isServer) { clientShared = sharedVariables; } } else { if (sharedVariables.isServer) { clientShared = sharedVariables; } if (!sharedVariables.isServer) { serverShared = sharedVariables; } } } if (clientShared != null && serverShared != null) { if (transform.localScale.x != savedScale.x || transform.rotation.y != savedRotation.y) { if (transform.localScale.x != savedScale.x) { clientShared.CmdUpdateScale(transform.localScale); //serverShared.SetScale(transform.localScale); } else { // transform.localScale = clientShared.getScale(); transform.localScale = serverShared.getScale(); } savedScale = transform.localScale; if (transform.rotation.y != savedRotation.y) { clientShared.CmdUpdateRotation(transform.rotation); //serverShared.SetRotation(transform.rotation); } else { //transform.rotation = clientShared.getRotation(); transform.rotation = serverShared.getRotation(); } savedRotation = transform.rotation; } else { transform.localScale = new Vector3(serverShared.getScale().x * 1.2f, serverShared.getScale().y * 1.2f, serverShared.getScale().z * 1.2f); //transform.localScale = serverShared.getScale(); savedScale = transform.localScale; transform.rotation = serverShared.getRotation(); //transform.rotation = serverShared.getRotation(); savedRotation = transform.rotation; } } }
// Update is called once per frame void Update() { SharedVariables clientShared = null; SharedVariables serverShared = null; foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Respawn")) { SharedVariables sharedVariables = obj.GetComponent <SharedVariables>(); if (sharedVariables.isLocalPlayer) { if (sharedVariables.isServer) { serverShared = sharedVariables; } if (!sharedVariables.isServer) { clientShared = sharedVariables; } } else { if (sharedVariables.isServer) { clientShared = sharedVariables; } if (!sharedVariables.isServer) { serverShared = sharedVariables; } } } if (Input.touchCount == 1) { Touch touch = Input.GetTouch(0); switch (touch.phase) { //When a touch has first been detected, change the message and record the starting position case TouchPhase.Began: startPos = touch.position; break; case TouchPhase.Moved: // If we have moved we want to rotate SharedVariables sharedVariables = GameObject.FindWithTag("Respawn").GetComponent <SharedVariables>(); Quaternion rotation = Quaternion.Euler(0f, -touch.deltaPosition.x * rotateSpeedModifier, 0f); Quaternion newRotation = serverShared.getRotation() * rotation; //Quaternion newRotation = clientShared.getRotation() * rotation; UnityEngine.Debug.Log("mobile rotation update " + newRotation.y); //clientShared.CmdUpdateRotation(newRotation); serverShared.SetRotation(newRotation); break; case TouchPhase.Ended: // If when we ended the finger hadn't moved, it's a tap if (touch.position == startPos) { Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit raycastHit; if (Physics.Raycast(raycast, out raycastHit)) { if (raycastHit.collider != null) { UnityEngine.Debug.Log("Tapped " + raycastHit.transform.gameObject.name); } } } break; } } else if (Input.touchCount == 2) { // Store both of the touches on screen. Touch touchZero = Input.GetTouch(0); Touch touchOne = Input.GetTouch(1); // Find the position in the previous frame of each touch. Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition; // Find the magnitude of the vector (the distance) between the touches in each frame. float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude; float touchDeltaMag = (touchZero.position - touchOne.position).magnitude; // Find the difference in the distances between each frame. float deltaMagnitudeDiff = (prevTouchDeltaMag - touchDeltaMag) * -0.0001f; foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Respawn")) { if (obj.GetComponent <SharedVariables>().isServer) //if (!obj.GetComponent<SharedVariables>().isServer) { SharedVariables sharedVariables = obj.GetComponent <SharedVariables>(); Vector3 savedScale = serverShared.getScale(); //Vector3 savedScale = clientShared.getScale(); var newX = Mathf.Clamp(savedScale.x + deltaMagnitudeDiff, 0.001f, 10); var newY = Mathf.Clamp(savedScale.y + deltaMagnitudeDiff, 0.001f, 10); var newZ = Mathf.Clamp(savedScale.z + deltaMagnitudeDiff, 0.001f, 10); Vector3 newScale = new Vector3(newX, newY, newZ); serverShared.SetScale(newScale); //clientShared.CmdUpdateScale(newScale); } } } else { } }
public void TypeCheck() { foreach (var proc in program.Procedures) { if (!QKeyValue.FindBoolAttribute(proc.Attributes, "yields")) { continue; } int createdAtLayerNum; // must be initialized by the following code, otherwise it is an error int availableUptoLayerNum = int.MaxValue; List <int> attrs = FindLayers(proc.Attributes); if (attrs.Count == 1) { createdAtLayerNum = attrs[0]; } else if (attrs.Count == 2) { createdAtLayerNum = attrs[0]; availableUptoLayerNum = attrs[1]; } else { Error(proc, "Incorrect number of layers"); continue; } foreach (Ensures e in proc.Ensures) { MoverType moverType = GetMoverType(e); if (moverType == MoverType.Top) { continue; } CodeExpr codeExpr = e.Condition as CodeExpr; if (codeExpr == null) { Error(e, "An atomic action must be a CodeExpr"); continue; } if (procToActionInfo.ContainsKey(proc)) { Error(proc, "A procedure can have at most one atomic action"); continue; } if (availableUptoLayerNum <= createdAtLayerNum) { Error(proc, "Creation layer number must be less than the available upto layer number"); continue; } minLayerNum = int.MaxValue; maxLayerNum = -1; canAccessSharedVars = true; enclosingProc = proc; enclosingImpl = null; base.VisitEnsures(e); canAccessSharedVars = false; if (maxLayerNum > createdAtLayerNum) { Error(e, "A variable being accessed is introduced after this action is created"); } else if (availableUptoLayerNum > minLayerNum) { Error(e, "A variable being accessed is hidden before this action becomes unavailable"); } else { procToActionInfo[proc] = new AtomicActionInfo(proc, e, moverType, createdAtLayerNum, availableUptoLayerNum); } } if (errorCount > 0) { continue; } if (!procToActionInfo.ContainsKey(proc)) { if (availableUptoLayerNum < createdAtLayerNum) { Error(proc, "Creation layer number must be no more than the available upto layer number"); continue; } else { procToActionInfo[proc] = new ActionInfo(proc, createdAtLayerNum, availableUptoLayerNum); } } } if (errorCount > 0) { return; } foreach (var impl in program.Implementations) { if (!procToActionInfo.ContainsKey(impl.Proc)) { continue; } procToActionInfo[impl.Proc].hasImplementation = true; } foreach (var proc in procToActionInfo.Keys) { ActionInfo actionInfo = procToActionInfo[proc]; if (actionInfo.isExtern && actionInfo.hasImplementation) { Error(proc, "Extern procedure cannot have an implementation"); continue; } if (actionInfo.isExtern || actionInfo.hasImplementation) { continue; } if (leastUnimplementedLayerNum == int.MaxValue) { leastUnimplementedLayerNum = actionInfo.createdAtLayerNum; } else if (leastUnimplementedLayerNum != actionInfo.createdAtLayerNum) { Error(proc, "All unimplemented atomic actions must be created at the same layer"); } } foreach (var g in this.globalVarToSharedVarInfo.Keys) { var info = globalVarToSharedVarInfo[g]; if (!this.AllCreatedLayerNums.Contains(info.introLayerNum)) { Error(g, "Variable must be introduced with creation of some atomic action"); } if (info.hideLayerNum != int.MaxValue && !this.AllCreatedLayerNums.Contains(info.hideLayerNum)) { Error(g, "Variable must be hidden with creation of some atomic action"); } } if (errorCount > 0) { return; } this.VisitProgram(program); foreach (Procedure proc in program.Procedures) { if (procToActionInfo.ContainsKey(proc)) { continue; } foreach (var ie in proc.Modifies) { if (!SharedVariables.Contains(ie.Decl)) { continue; } Error(proc, "A ghost procedure must not modify a global variable with layer annotation"); } } if (errorCount > 0) { return; } YieldTypeChecker.PerformYieldSafeCheck(this); new LayerEraser().VisitProgram(program); }
//FB SDK END void Start() { // Handle Image data returned from Plugin PhotoPlugin.getInstance().delegatedImage = imageHandle; if (withChoice == true) { photoIsSelected = true; levelIsSelected = true; sharedObject = GameObject.FindGameObjectsWithTag("SharedObject")[0] as GameObject; v = sharedObject.GetComponent <SharedVariables> (); byte[] data = v.imageData; int w = v.width; int h = v.height; if (data.Length == 0 || w == 0 || h == 0) { SceneManager.LoadSceneAsync("GP_Menu", LoadSceneMode.Single); } else { loadImage(data, w, h); } Button easyButton = GameObject.Find("Easy Button").GetComponent <Button> (); ColorBlock easyColors = easyButton.colors; Button normalButton = GameObject.Find("Normal Button").GetComponent <Button> (); ColorBlock normalColors = normalButton.colors; Button hardButton = GameObject.Find("Hard Button").GetComponent <Button> (); ColorBlock hardColors = hardButton.colors; Color32 levelSelect; if (GameName == "GP") { levelSelect = new Color32(171, 210, 255, 255); } else if (GameName == "JP") { levelSelect = new Color32(223, 255, 193, 255); } else { levelSelect = new Color32(255, 255, 255, 255); } if (v.level == EASY) { easyColors.normalColor = levelSelect; easyButton.colors = easyColors; level = EASY; } else if (v.level == NORMAL) { normalColors.normalColor = levelSelect; normalButton.colors = normalColors; level = NORMAL; } else if (v.level == HARD) { hardColors.normalColor = levelSelect; hardButton.colors = hardColors; level = HARD; } Button camera = GameObject.Find("Camera Button").GetComponent <Button> (); Button gallery = GameObject.Find("Gallery Button").GetComponent <Button> (); Color32 Select; if (GameName == "GP") { Select = new Color32(223, 255, 193, 255); } else if (GameName == "JP") { Select = new Color32(255, 220, 180, 255); } else { Select = new Color32(255, 255, 255, 255); } if (v.imageFrom.Equals("camera")) { imageFrom = CAMERA; camera.GetComponent <Image> ().color = Select; } else if (v.imageFrom.Equals("gallery")) { imageFrom = GALLERY; gallery.GetComponent <Image> ().color = Select; } if (GameName == "GP") { tipsToggle.isOn = v.withTips; } } }
void Start() { sharedVariables = GameObject.FindGameObjectWithTag("Variables"); Firsttreeposition = GameObject.Find("First Closest Tree").GetComponent<Text>(); Secondtreeposition = GameObject.Find("Second Closest Tree").GetComponent<Text>(); GPSposition = GameObject.Find("Position Data").GetComponent<Text>(); IMUrotation = GameObject.Find("Rotation Data").GetComponent<Text>(); Firsttreeposition.text = "0"; Secondtreeposition.text = "0"; GPSposition.text = "0"; IMUrotation.text = "0"; if (sharedVariables == null) { xOfMap = 4f; zOfMap = 4f; numberOfTrees = 20; } else { sharedVariablesScript = sharedVariables.GetComponent<SharedVariables>(); numberOfTrees = sharedVariablesScript.numOfTrees; seed = sharedVariablesScript.seed; } xOfMap = (numberOfTrees/sharedVariablesScript.numOfRows) + 6; zOfMap = (sharedVariablesScript.numOfRows) + 6; Random.seed = seed; inProcessOfTurning = false; stopped = false; rotating = false; direction = 1; GPSUpdate = 0; LidarUpdate = 0; sizeOfTree = new Vector3(2*radiusTree, heightTree, 2*radiusTree); sizeOfMap = new Vector3(xOfMap,1,zOfMap); OrientationOfMap = Quaternion.identity; Tree.transform.localScale = sizeOfTree; Map.transform.localScale = sizeOfMap; AForest = new GameObject[numberOfTrees]; treeLocalPositions = new Vector3[numberOfTrees]; nextSpot = currentPosition; SpawnForest(); }
private void Awake() { DontDestroyOnLoad(this.gameObject); _instance = this; }
// Update is called once per frame private void Update() { SharedVariables clientShared = null; SharedVariables serverShared = null; foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Respawn")) { SharedVariables sharedVariables = obj.GetComponent <SharedVariables>(); if (sharedVariables.isLocalPlayer) { if (sharedVariables.isServer) { serverShared = sharedVariables; } if (!sharedVariables.isServer) { clientShared = sharedVariables; } } else { if (sharedVariables.isServer) { clientShared = sharedVariables; } if (!sharedVariables.isServer) { serverShared = sharedVariables; } } } if (isServer) { if (isLocalPlayer) { // server object on server if (oldScale != clientShared.getScale()) { scale = clientShared.getScale(); oldScale = scale; } if (oldRotation != clientShared.getRotation()) { rotation = clientShared.getRotation(); oldRotation = rotation; Debug.Log("Server object on server rotation: " + rotation); } } else { // client object on server if (oldScale != clientShared.getScale()) { scale = clientShared.getScale(); oldScale = scale; } if (oldRotation != clientShared.getRotation()) { rotation = clientShared.getRotation(); oldRotation = rotation; Debug.Log("Server object on server rotation: " + rotation); } } } else { if (isLocalPlayer) { // client object on client if (oldScale != serverShared.getScale()) { scale = serverShared.getScale(); oldScale = scale; } if (oldRotation != serverShared.getRotation()) { rotation = serverShared.getRotation(); oldRotation = rotation; Debug.Log("Server object on server rotation: " + rotation); } } else { // server object on client if (oldScale != serverShared.getScale()) { scale = serverShared.getScale(); oldScale = scale; } if (oldRotation != serverShared.getRotation()) { rotation = serverShared.getRotation(); oldRotation = rotation; Debug.Log("Server object on server rotation: " + rotation); } } } }