void Start() { m_gameController = GameObject.FindObjectOfType <GameController>().GetComponent <GameController>(); m_touchController = GameObject.FindObjectOfType <TouchController>().GetComponent <TouchController>(); if (m_dragDistanceSlider != null) { m_dragDistanceSlider.value = 50; m_dragDistanceSlider.minValue = 50; m_dragDistanceSlider.maxValue = 150; } if (m_swipeDistanceSlider != null) { m_swipeDistanceSlider.value = 50; m_swipeDistanceSlider.minValue = 20; m_swipeDistanceSlider.maxValue = 250; } if (m_dragSpeedSlider != null) { m_dragSpeedSlider.value = 0.15f; m_dragSpeedSlider.minValue = 0.05f; m_dragSpeedSlider.maxValue = 0.5f; } if (m_toggleDiagnostic != null && m_touchController != null) { m_touchController.m_useDiagnostic = m_toggleDiagnostic.isOn; } }
/// <summary> /// Initialize all documents /// </summary> public async void Init(int width, int height) { //Initialize controllers documentController = new DocumentController(this); cardController = new CardController(this); sortingBoxController = new SortingBoxController(this); touchController = new TouchController(this); gestureController = new GestureController(this); listenerController = new GestureListenerController(this); baseLayerController = new BaseLayerController(this); cardLayerController = new CardLayerController(this); sortingBoxLayerController = new SortingBoxLayerController(this); menuLayerController = new MenuLayerController(this); //Initialize layers touchController.Init(); gestureController.Init(); listenerController.Init(); baseLayerController.Init(width, height); Coordination.Baselayer = baseLayerController.BaseLayer;//Set the base layer to the coordination helper cardLayerController.Init(width, height); sortingBoxLayerController.Init(width, height); menuLayerController.Init(width, height); //Load the documents, cards and add them to the card layer Document[] docs = await documentController.Init(FilePath.NewsArticle);//Load the document Card[] cards = await cardController.Init(docs); CardLayerController.LoadCards(cards); //Load the sorting box and add them to the sorting box layer sortingBoxController.Init(); SortingBoxLayerController.LoadBoxes(sortingBoxController.GetAllSortingBoxes()); //Start the gesture detection thread gestureController.StartGestureDetection(); }
public void TouchAction(TouchController.TouchActionType t) { bool airJump = rb.velocity.z > 0; switch (t) { case TouchController.TouchActionType.left: Debug.Log ("ta left"); rb.velocity = new Vector3(-1, 2, 1)*jump_speed; break; case TouchController.TouchActionType.right: Debug.Log ("ta right"); rb.velocity = new Vector3(1, 2, 1)*jump_speed; break; case TouchController.TouchActionType.leftright: Debug.Log ("ta leftright"); rb.velocity = new Vector3(0, 2, 1)*jump_speed; break; } if (airJump) { rb.velocity = rb.velocity + new Vector3(0f,1f,0f)*jump_speed; } }
void Start() { touchController = FindObjectOfType <TouchController>().GetComponent <TouchController>(); gameManager = FindObjectOfType <GameManager>().GetComponent <GameManager>(); panelManager = FindObjectOfType <PanelManager>().GetComponent <PanelManager>(); InitializePanel(); }
void Update() { if (TouchController.IsPushedQuitKey()) { Application.Quit(); } }
/// <summary> /// Rotates the camera a given amount given by a movement in a 2D space /// </summary> /// <param name="rotateAmount">Amount to rotate camera on x and y axis</param> private void RotateCamera(Vector2 rotateAmount) { if (target != null) { //Check if we have a reasonable iputy to change camera pos if (Mathf.Abs(rotateAmount.x + rotateAmount.y) > 1) { transform.RotateAround(target.transform.position, new Vector3(0f, rotateAmount.x, 0f), rotationSpeed * fingerMovementSensitivity * Time.deltaTime); } //Caculate tartget pos for desired y pos if we aren't touching the screen Vector3 cameraBallDifference = Vector3.zero; //If the screen has been touched then allow the camera to move to the touched location //else settle at a given y postion if (TouchController.ScreenTouched()) { cameraBallDifference = (transform.position - target.transform.position).normalized; } else { cameraBallDifference = (new Vector3(transform.position.x, cameraYset, transform.position.z) - new Vector3(target.transform.position.x, 0f, target.transform.position.z)).normalized; } //Work out the postion that the camera should be at desiredPostion = cameraBallDifference * radius + target.transform.position; //Calculate the camera speed based on our current distance from the camera so that we have a smooth camera, //then move the camera float cameraSpeed = Time.deltaTime * (radiusSpeed + (Vector3.Distance(transform.position, target.transform.position) * radiusSpeed)); transform.position = Vector3.MoveTowards(transform.position, desiredPostion, cameraSpeed); transform.rotation = SmoothLookAt(transform, target.transform); } }
// Use this for initialization void Awake() { anim = GetComponentInChildren <Animator> (); source = GetComponent <AudioSource> (); training = GetComponent <Training>(); controller = GetComponent <TouchController>(); }
/// <summary> /// Updates the local matrix. /// If <see cref="UseTRS"/> is true, <see cref="LocalMatrix"/> will be updated from <see cref="Position"/>, <see cref="Rotation"/> and <see cref="Scale"/>. /// </summary> public void UpdateLocalMatrix() { // do we need to update with a VR hand? if (TrackVRHand != VirtualReality.TouchControllerHand.None && VRDeviceSystem.VRActive) { TouchController vrController = VRDeviceSystem.GetSystem.GetController(TrackVRHand); if (vrController != null && vrController.State != DeviceState.Invalid) { Position = vrController.Position; Rotation = vrController.Rotation; if (TrackVRHand == TouchControllerHand.Left) { LastLeftHandTracked = this; } else { LastRightHandTracked = this; } } } if (UseTRS) { Matrix.Transformation(ref Scale, ref Rotation, ref Position, out LocalMatrix); } }
// Token: 0x060008CD RID: 2253 RVA: 0x00038F74 File Offset: 0x00037374 public override void DrawGUI() { if (this.disableGui || this.joy.GetAlpha() * this.animAlpha.cur < 0.001f) { return; } GUI.color = Color.white; bool flag = this.Pressed(); Color cur = this.animHatColor.cur; Color cur2 = this.animBaseColor.cur; Texture2D texture2D = (!flag) ? this.releasedHatImg : this.pressedHatImg; Texture2D texture2D2 = (!flag) ? this.releasedBaseImg : this.pressedBaseImg; GUI.depth = this.joy.guiDepth + this.guiDepth + ((!this.Pressed()) ? 0 : this.joy.guiPressedOfs); if (texture2D2 != null) { GUI.color = TouchController.ScaleAlpha(cur2, this.joy.GetAlpha() * this.animAlpha.cur); GUI.DrawTexture(this.GetBaseDisplayRect(true), texture2D2); } if (texture2D != null) { GUI.color = TouchController.ScaleAlpha(cur, this.joy.GetAlpha() * this.animAlpha.cur); GUI.DrawTexture(this.GetHatDisplayRect(true), texture2D); } }
// Start is called before the first frame update void Start() { rjoystick = joystickdestro.GetComponent <Image>(); player = GameObject.FindGameObjectWithTag("Player"); touch = player.GetComponent <TouchController>(); checker.OnSkillCheckDone.AddListener(checkDone); }
void Start() { m_gameController = FindObjectOfType <GameController>(); m_touchController = FindObjectOfType <TouchController>(); if (m_dragDistanceSlider != null) { m_dragDistanceSlider.value = 100; m_dragDistanceSlider.minValue = 50; m_dragDistanceSlider.maxValue = 150; } if (m_swipeDistanceSlider != null) { m_swipeDistanceSlider.value = 50; m_swipeDistanceSlider.minValue = 20; m_swipeDistanceSlider.maxValue = 250; } if (m_dragSpeedSlider != null) { m_dragSpeedSlider.value = 0.15f; m_dragSpeedSlider.minValue = 0.05f; m_dragSpeedSlider.maxValue = 0.5f; } }
void Start() { animator = this.GetComponent <Animator>(); speed = Random.RandomRange(3f, 4f); touch = GameObject.FindGameObjectWithTag("Player").GetComponent <TouchController>(); }
private void Start() { tInput = GameManager.Instance.TouchController; // Get MatchController currentPosition = SetValidCurrentPosition(transform.position); currentSpace = GetCurrentSpace(); }
public void onTouchEnded(TouchController con) { if (!m_active) { return; } //限制用户不能把小图块移出屏幕 Vector3 diff = m_active.transform.position; diff.x = Mathf.Min(diff.x, 0); diff.y = Mathf.Min(diff.y, 0); m_active.SetPosition(m_active.GetPosition() - (Vector2)diff); diff = m_active.transform.position; diff.x = Mathf.Max(diff.x - Screen.width, 0); diff.y = Mathf.Max(diff.y - Screen.height, 0); m_active.SetPosition(m_active.GetPosition() - (Vector2)diff); //如果用户把小图块移动到正确位置附近,就产生一个吸附效果 diff = m_active.GetPosition() - m_active.perfectPos; //print(diff); if (Mathf.Abs(diff.x) < 10 && Mathf.Abs(diff.y) < 10) { m_active.SetPosition(m_active.perfectPos); } m_active = null; }
void Start() { rigidBody = GetComponent <Rigidbody>(); GameObject mathControllerObject = GameObject.FindWithTag("MathController"); GameObject touchControllerObject = GameObject.FindWithTag("TouchController"); GameObject quizControllerObject = GameObject.FindWithTag("QuizController"); if (mathControllerObject != null) { mathController = mathControllerObject.GetComponent <MathController>(); } if (mathControllerObject == null) { Debug.Log("Cannot find 'MathController' script"); } if (touchControllerObject != null) { touchController = touchControllerObject.GetComponent <TouchController>(); } if (touchControllerObject == null) { Debug.Log("Cannot find 'TouchController' script"); } if (quizControllerObject != null) { quizController = quizControllerObject.GetComponent <QuizController>(); } if (quizControllerObject == null) { Debug.Log("Cannot find 'QuizController' script"); } StartCoroutine(BallCalculating()); }
private void Awake() { if (!Instance) { Instance = this; // DontDestroyOnLoad (this); } else { Destroy(this); } mainCamera = Camera.main; Raycaster = mainCamera.GetComponent <Physics2DRaycaster> (); spells = FindObjectOfType <Spells> (); field = FindObjectOfType <Field> (); buildingManager = FindObjectOfType <BuildingManager> (); attackManager = FindObjectOfType <AttackManager> (); castManager = FindObjectOfType <CastManager> (); enemyController = FindObjectOfType <EnemyController> (); touchController = FindObjectOfType <TouchController>(); wizard = FindObjectOfType <Wizard> (); xpPoints = wizard.GetComponent <XPpoints> (); GameController = FindObjectOfType <GameController> (); uIManager = FindObjectOfType <UIManager> (); firePoints = FindObjectOfType <FirePoints> (); }
// FIXME: 選択肢に対応していない // TODO: 選択肢に対応できる仕組みを作る void Update() { if (TouchController.IsTouchBegan()) { _manager.Next(); } }
public void Initialize() { Debug.Log("UISettings Initialize"); deltaSwitch = Screen.width / 8f; MusicValue.SetValue(SoundController.runtime.MusicVolume); EffectValue.SetValue(SoundController.runtime.EffectVolume); LocalizeValue.SetValue((int)LocalizationHelper.runtime.Localization); MusicValue.OnStateChanged += (value) => { Debug.Log("SoundController.runtime.MusicVolume " + SoundController.runtime.MusicVolume); SoundController.runtime.MusicVolume = value; }; EffectValue.OnStateChanged += (value) => { SoundController.runtime.EffectVolume = value; Debug.Log("SoundController.runtime.EffectVolume " + SoundController.runtime.EffectVolume); }; LocalizeValue.OnStateChanged += (value) => { LocalizationHelper.runtime.Localization = (LocalizationHelper.LocalizationType)value; }; TouchController = Camera.main.GetComponent <TouchController>(); TouchController.TouchDownClicked += TouchBeganHandler; TouchController.TouchMoved += TouchMovedHandler; TouchController.TouchUpClicked += TouchEndedHandler; }
void ClearGimmick() { if (_isHit) { // 画面をタッチした時 if (TouchController.IsTouchBegan()) { // カメラからタッチ位置へのレイを生成 Ray ray_ = Camera.main.ScreenPointToRay(TouchController.GetTouchScreenPosition()); RaycastHit hit_ = new RaycastHit(); // レイが当たったオブジェクトのコライダーを取得 if (Physics.Raycast(ray_, out hit_)) { if (hit_.collider.gameObject.tag.Equals(ObjectTag.gimmick)) { // クリアフラグをtrueにする if (!_isClear) { _isClear = true; } } } } } }
void Start() { InventoryController = GameObject.Find("---InventoryController"); TouchController = GameObject.Find("---TouchController").GetComponent <TouchController>(); AllMachines = GameObject.Find("---ClothInMachineController").GetComponent <AllMachines>(); FinalCameraController = GameObject.Find("Main Camera").GetComponent <FinalCameraController>(); SubwayMovement = GameObject.Find("---StationController").GetComponent <SubwayMovement>(); LostAndFound = GameObject.Find("Lost&Found_basket").GetComponent <LostAndFound>(); SpriteLoader = GameObject.Find("---SpriteLoader").GetComponent <SpriteLoader>(); AdsController = GameObject.Find("---AdsController").GetComponent <AdsController>(); InventorySlotMgt = GameObject.Find("---InventoryController").GetComponent <InventorySlotMgt>(); //AudioManager = GameObject.Find("---AudioManager").GetComponent<AudioManager>(); LevelManager = FinalCameraController.LevelManager; startPos = transform.position; // selfButton.onClick.AddListener(AddClothToInventory); //currentSprite = GetComponent<SpriteRenderer>().sprite; myImage = GetComponent <Image>(); startSprite = GetComponent <Image>().sprite; if (!FinalCameraController.isTutorial) { returnConfirmButton.gameObject.SetActive(false); } }
// Use this for initialization void Start() { thisCamera = this.GetComponent <Camera>(); lastFreeCameraOrtho = thisCamera.orthographicSize; lastFreeCameraPosition = this.transform.position; TC = TouchController.Instance; }
// TIPS: リザルト表示 IEnumerator Result() { _state = State.Result; var p1score = _device.player1.scoreBoard.count; var p2score = _device.player2.scoreBoard.count; _finish.ActivateImage(p1score, p2score); _menu.group.alpha = 1f; _menu.start.image.color = Color.white * 0f; _menu.hint.image.color = Color.white * 0f; _menu.back.interactable = true; RaycastHit hit; while (true) { if (TouchController.IsTouchBegan()) { var isHit = TouchController.IsRaycastHitWithLayer(out hit, _refereeMask); if (isHit) { break; } } _device.ModelUpdate(); yield return(null); } OnBackToMenu(); }
// Start is called before the first frame update void Start() { InventoryController = GameObject.Find("---InventoryController"); TouchController = GameObject.Find("---TouchController").GetComponent <TouchController>(); AllMachines = GameObject.Find("---ClothInMachineController").GetComponent <AllMachines>(); FinalCameraController = GameObject.Find("Main Camera").GetComponent <FinalCameraController>(); CalculateInventory = InventoryController.GetComponent <CalculateInventory>(); startPos = transform.position; inventoryButtonList = new List <Button>(); // selfButton.onClick.AddListener(AddClothToInventory); //currentSprite = GetComponent<SpriteRenderer>().sprite; myImage = GetComponent <Image>(); startSprite = GetComponent <Image>().sprite; selfButton = GetComponent <Button>(); for (var i = 0; i < CalculateInventory.inventory.Count; i++) { inventoryButtonList.Add(CalculateInventory.inventory[i].GetComponent <Button>()); } }
// Start is called before the first frame update void Start() { // Инициализировать необходимые компоненты цветного круга ColorCircle = transform.GetChild(0) as RectTransform; // Инициализировать необходимые компоненты маркера PickerTransform = ColorCircle.GetChild(0) as RectTransform; Picker = PickerTransform.GetComponent <Image>(); // Создать регулировку яркости Brightness = new SliderControl(transform, "BrightnessSlider"); // Создать регулировку насыщенности Saturation = new SliderControl(transform, "SaturationSlider"); SelectedColor = transform.Find("SelectedColor").GetComponent <Image>(); // Инициализировать радиусы цветного круга и маркера CircleRadius = 0.5f * ColorCircle.sizeDelta.x; PickerRadius = 0.5f * PickerTransform.sizeDelta.x; // Кватернион поворота на 120 градусов по часовой стрелке вокруг оси Z Quaternion rotateQuaternion = Quaternion.Euler(0, 0, -120); // Инициализировать массив с координатами точек R, G и B RGBpoints[0] = new Vector2(0, CircleRadius); for (int p = 1; p < RGBpoints.Length; p++) { RGBpoints[p] = rotateQuaternion * RGBpoints[p - 1]; } // Создать массив под угловые расстояния заданной точки до точек R, G и B Angles = new float[RGBpoints.Length]; // Обновить текущий цвет маркера Picker.color = CalcColor(PickerTransform.anchoredPosition); // Обновить текущий цвет регулировки насыщенности Saturation.Color = Color.Lerp(Color.white, Picker.color, Saturation.Slider.value); // Обновить текущий цвет регулировки яркости Brightness.Color = SelectedColor.color = Color.Lerp(Color.black, Saturation.Color, Brightness.Slider.value); // При изменении насыщенности - обновлять цвет Saturation.Slider.onValueChanged.AddListener((float value) => { Saturation.Color = Color.Lerp(Color.white, Picker.color, Saturation.Slider.value); Brightness.Color = SelectedColor.color = Color.Lerp(Color.black, Saturation.Color, Brightness.Slider.value); }); // При изменении яркости - обновлять цвет Brightness.Slider.onValueChanged.AddListener((float value) => { Brightness.Color = SelectedColor.color = Color.Lerp(Color.black, Saturation.Color, Brightness.Slider.value); }); // Зарегистрироваться в TouchController-е, чтобы отслеживать перемещения пальцев или мыши по экрану TouchController.RegListener(this); }
private void Awake() { rectTransform = GetComponent <RectTransform>(); dummy = GetComponentInChildren <UnityEngine.UI.Image>(true); touchControl = GetComponentInChildren <TouchController>(true); OutlinePrefab = Instantiate(OutlinePrefab); OutlinePrefab.SetActive(false); }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); lifebar = GameObject.Find("lifebar"); touch = player.GetComponent <TouchController>(); slider = lifebar.GetComponent <Slider>(); audioSource = this.GetComponent <AudioSource>(); }
void Awake() { Instance = this; controller = GameObject.FindGameObjectWithTag("Player").GetComponentsInChildren <Controller>(); StrafeArea = Screen.width / 3; }
// Use this for initialization void Start() { reference = GameObject.FindGameObjectsWithTag("TOUCHCONTROLLER"); touchController = reference[0].GetComponent<TouchController>(); originalRotation = this.transform.rotation; fingerList = new List<Vector2>(); }
private void Start() { imagem.sprite = card.imagem; nomeText.text = card.nome; descricaoText.text = card.descricao; anim = GetComponent <Animator>(); controller = GameObject.FindGameObjectWithTag("Controller").GetComponent <TouchController>(); }
// Use this for initialization void Start() { if (tc != null) { Debug.LogError("TouchController exist!"); } tc = this; }
void Start() { _hudImages = Images.GetComponentsInChildren <Image>(); _hudItemCounts = Numbers.GetComponentsInChildren <Text>(); for (int i = 0; i < _hudImages.Length; i++) { _hudGameObjects[i] = _hudImages[i].gameObject; } for (int i = 0; i < IngredientTyperOrders.Length; i++) { IndexMappings[IngredientTyperOrders[i]] = i; } CraftingManager.Instance.OnResourceCountChanged += CheckResourceNumbers; buttonStateSprites = new Dictionary <ButtonState, Sprite[]>(5); buttonStateSprites[ButtonState.Default] = DefaultSprites; buttonStateSprites[ButtonState.Craft] = CraftSprites; buttonStateSprites[ButtonState.Light] = LightSprites; buttonStateSprites[ButtonState.OutOf] = OutOfSprites; Sprite[] arr = new Sprite[9]; for (int i = 0; i < 9; i++) { arr[i] = CombatSprite; } buttonStateSprites[ButtonState.InCombat] = arr; current = ButtonState.InCombat; SetAllActiveState(true); BaseManager.Instance.RegisterOnBaseEnter(OnBaseEnter); BaseManager.Instance.RegisterOnBaseExit(OnBaseExit); // SetAllCounts(); SetAllButtonsImages(ButtonState.InCombat); Vector2[] pos = new Vector2[9]; for (int i = 0; i < pos.Length; i++) { Vector3 center = _hudImages[i].transform.position; pos[i] = Camera.main.ScreenToWorldPoint(center); // center.x += _hudImages[i].rectTransform.rect.width; // center.y += _hudImages[i].rectTransform.rect.height; } var go = GameObject.FindWithTag("TouchController"); _touchContoller = go.GetComponent <TouchController>(); _touchContoller.SetTouchContollerCenters(pos); Numbers.gameObject.SetActive(false); Initted = true; }
public void Start() { zoomTarget = 3.4f; angleTarget = PositionToVector(CameraPosition.Center); TouchController tc = TouchController.GetController(); tc.startTouch += StartTouch; tc.endTouch += EndTouch; }
// Use this for initialization void Start() { //origin = new Vector3(1, -0.75f, 0); originalRotation = this.transform.rotation; reference = GameObject.FindGameObjectsWithTag("TOUCHCONTROLLER"); touchController = reference[0].GetComponent<TouchController>(); fingerList = new List<Vector2>(); //touchType = TouchType.NONE; }
// Use this for initialization void Start() { originalRotation = this.transform.rotation; originalPosition = new Vector3(0,0,-1); reference = GameObject.FindGameObjectsWithTag("TOUCHCONTROLLER"); reference2 = GameObject.FindGameObjectsWithTag("GLOBALVARIABLES"); touchController = reference[0].GetComponent<TouchController>(); fingerList = new List<Vector2>(); stop = 0; prefab = this.transform; }
// ------------------- //public TouchControllerConstGenerator(TouchController joy) public void InitAndShow(TouchController joy) { this.joy = joy; this.buttonLabel = "BTN"; this.stickLabel = "STICK"; this.zoneLabel = "ZONE"; this.prefixMode = true; this.uppercaseMode = true; this.spacesToUnderscores = true; this.ShowUtility(); }
// Use this for initialization void Start() { collisionReference = GameObject.Find ("Collision").GetComponent<BoxCollider>(); originalRotation = this.transform.rotation; //originalPosition = new Vector3(0,0,-1); originalPosition = this.transform.position; touchController = GameObject.FindGameObjectWithTag("MainObject").GetComponent<TouchController>(); foldReference = GameObject.Find("backsidepivot").GetComponent<Fold>(); fingerList = new List<Vector2>(); tearPoints = new List<Vector3>(); prefab = this.transform; zLayerTmp = GVariables.zFoldLayer; prevMousestate = false; currMouseState = false; firstTouch = false; isFolded = false; }
// Use this for initialization void Start() { // the following is now needed // due to the prefab of 'MainObject' GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject GameStateManager gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); gameStateManagerRef.EnsureScriptAdded("TouchController"); collisionReference = GameObject.Find ("Collision").GetComponent<BoxCollider>(); originalRotation = this.transform.rotation; //originalPosition = new Vector3(0,0,-1); originalPosition = this.transform.position; touchController = mainObject.GetComponent<TouchController>(); foldReference = GameObject.Find("backsidepivot").GetComponent<Fold>(); fingerList = new List<Vector2>(); tearPoints = new List<Vector3>(); prefab = this.transform; zLayerTmp = GVariables.zFoldLayer; prevMousestate = false; currMouseState = false; firstTouch = false; isFolded = false; }
// Use this for initialization void Start() { // NOTICE : DOM originalPosition = new Vector3(0,0,-3); originalRotation = this.transform.rotation; touchController = GameObject.FindGameObjectWithTag("MainObject").GetComponent<TouchController>(); foldCollide = GameObject.Find("Collision").GetComponent<FoldCollision>(); foldReference = GameObject.Find("backsidepivot").GetComponent<Fold>(); fingerList = new List<Vector2>(); prefab = this.transform; zLayerTmp = GVariables.zCoverLayer; reference3 = this.transform.FindChild("coverup").gameObject; script = gameObject.GetComponent<ChangeMeshScript>(); prevMouseState = false; currMouseState = false; firstTouch = false; isFolded = false; }
public void Dispose() { this.RemoveTouch(); m_Instance = null; }
/// <summary> /// Use this for initialization /// </summary> public void Start() { gameObject.AddComponent<TouchController>(); screenManagerRef = gameObject.GetComponent<ScreenManager>(); gameStateManagerRef = gameObject.GetComponent<GameStateManager>(); screenManagerRef = gameObject.GetComponent<ScreenManager>(); animationManagerRef = gameObject.GetComponent<AnimationManager>(); touchController = gameObject.GetComponent<TouchController>(); keyDownWatch = new Stopwatch(); idleWatch = new Stopwatch(); lastReleaseWatch = new Stopwatch(); lastJustPressedWatch = new Stopwatch(); moveRight = KeyCode.D; moveLeft = KeyCode.A; jump = KeyCode.Space; }
// -------------------- public void ControlByTouch(TouchController ctrl, DemoRpgGameCS game) { TouchStick stickWalk = ctrl.GetStick(DemoRpgGameCS.STICK_WALK); TouchZone zoneScreen = ctrl.GetZone(DemoRpgGameCS.ZONE_SCREEN), zoneAction = ctrl.GetZone(DemoRpgGameCS.ZONE_ACTION), zoneFire = ctrl.GetZone(DemoRpgGameCS.ZONE_FIRE); // Get stick's normalized direction in world space relative to camera's angle... Vector3 moveWorldDir = stickWalk.GetVec3d(TouchStick.Vec3DMode.XZ, true, game.camOrbitalAngle); // Get stick's angle in world space by adding it to camera's angle.. float stickWorldAngle = stickWalk.GetAngle() + game.camOrbitalAngle; // Get walking speed from stick's current tilt... float speed = stickWalk.GetTilt(); // Get gun's trigger state by checking Fire zone's state (including mid-frame press) bool gunTriggerState = zoneFire.UniPressed(true, false); // Check if Action should be performed - either by pressing the Action button or // by tapping on the right side of the screen... bool performAction = zoneAction.JustUniPressed(true, true) || zoneScreen.JustTapped(); if ((this.charaState == CharaState.IDLE) || (this.charaState == CharaState.WALK) || (this.charaState == CharaState.RUN)) { if (speed > this.walkStickThreshold) { float moveSpeed = 0; // Walk... if (speed < this.runStickThreshold) { moveSpeed = this.walkSpeed; if (this.charaState != CharaState.WALK) this.StartWalking(); // Set animation speed... this.charaAnim[this.ANIM_WALK_F].speed = this.walkAnimSpeed; } // Run! else { moveSpeed = this.runSpeed; if (this.charaState != CharaState.RUN) this.StartRunning(); // Set animation speed... this.charaAnim[this.ANIM_RUN_F].speed = this.runAnimSpeed; } // Update player's angle... this.angle = DampAngle(this.angle, stickWorldAngle, this.angleSmoothingTime, this.turnMaxSpeed, Time.deltaTime); // Move player's collider... this.charaCtrl.Move(moveWorldDir * moveSpeed * Time.deltaTime); } else if ((this.charaState == CharaState.WALK) || (this.charaState == CharaState.RUN)) { // Stop... this.StartIdle(); } // Perform Action... if (performAction) this.PerformUseAction(); } // Every other state than USE... if (this.charaState != CharaState.USE) { if (this.gun != null) this.gun.SetTriggerState(gunTriggerState); if (performAction) this.PerformUseAction(); } // USE state updates... else { if (this.gun != null) this.gun.SetTriggerState(false); this.useElapsed += Time.deltaTime; if (this.useElapsed > this.useAnimDuration) this.StartIdle(); } }
/// \} // ----------------- // Hide documentation /// \cond // ------------------ // --------------------- public override void Init(TouchController joy) { base.Init(joy); this.joy = joy; this.fingerA = new Finger(this); this.fingerB = new Finger(this); this.OnReset(); if (this.initiallyDisabled) this.Disable(true); if (this.initiallyHidden) this.Hide(true); }
/// <summary> /// Start this instance. /// </summary> private void Start() { // Init manger refs touchController = GameObject.FindGameObjectWithTag("MainObject").GetComponent<TouchController>(); gameStateManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<GameStateManager>(); gameStateManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<GameStateManager>(); inputManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<InputManager>(); soundManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<SoundManager>(); PlayerObjectRef = GameObject.FindGameObjectWithTag("Player"); twCharController = PlayerObjectRef.GetComponent<TWCharacterController>(); unfoldBorderObjectRef = GameObject.FindGameObjectWithTag("unfoldborder"); //Initialize the tornPlatform list which will be modified //during runtime when player triggeres tearing mechanic TornPlatforms = new List<GameObject>(); //Initialize the centerPosition dictionary centerPositions = new Dictionary<GameObject, Vector3>(); //Initialize the list storing the tearable objects which need //to be parented to the world cut piece objectsBelongingToCutPiece = new List<GameObject>(); //Initialize decalObject dictionary storeing every decal object for proper updating and cleanup decalObjects = new Dictionary<GameObject, int>(); //Create new dictionary for platforms original positions originalPlatformPositions = new Dictionary<GameObject, Vector3>(); //Init haveCheckedDecalCollision = new Dictionary<GameObject, bool>(); GameObject[] platforms = GameObject.FindGameObjectsWithTag("Platform"); Platforms = new List<GameObject>(); foreach(GameObject go in platforms) { Platforms.Add(go); } platforms = null; //Store original positions of paltforms foreach(GameObject go in Platforms) { originalPlatformPositions.Add(go, go.transform.position); } OriginalPlatformTopology = new Dictionary <GameObject, int[]>(); foreach(GameObject go in Platforms) { OriginalPlatformTopology.Add(go, go.GetComponent<MeshFilter>().mesh.triangles); } OriginalPlatformTopology.Add(MainStartingWorldPaper, MainStartingWorldPaper.GetComponent<MeshFilter>().mesh.triangles); //init local ref TearLimitBounds = GameObject.FindGameObjectWithTag("TearLimit"); CreateDecalPool(); }
// Use this for initialization void Start() { originalRotation = this.transform.rotation; //originalPosition = new Vector3(0,0,-1); originalPosition = this.transform.position; touchController = GameObject.FindGameObjectWithTag("MainObject").GetComponent<TouchController>(); fingerList = new List<Vector2>(); tearPoints = new List<Vector3>(); // stop = 0; prefab = this.transform; zLayerTmp = GVariables.zFoldLayer; backsideReference = this.transform.FindChild("backside").gameObject; foldCollide = GameObject.Find("Collision").GetComponent<FoldCollision>(); backsideCollisionReference = GameObject.FindGameObjectsWithTag("FoldPlatform"); cameraReference = GameObject.Find("Main Camera"); script = gameObject.GetComponent<ChangeMeshScript>(); prevMousestate = false; currMouseState = false; firstTouch = false; isFolded = false; }
// ------------------ public virtual void Init(TouchController joy) { this.joy = joy; this.visible = true; this.enabled = true; //this.OnReset(); }
// ------------------- //public TouchControllerConstGenerator(TouchController joy) public void InitAndShow(TouchController joy) { this.joy = joy; this.stickLabel = "STICK"; this.zoneLabel = "ZONE"; this.ctrlVarName = "ctrl"; this.prefixMode = true; this.uppercaseMode = true; this.spacesToUnderscores = true; this.genCtrlVar = true; this.genCustomGuiSection = false; this.genLayoutSection = false; this.LoadSettings(); this.ShowUtility(); this.title = "Control Freak Code Generator"; }
public void AssignTouchController() { if(!gameObject.GetComponent<TouchController>()){ gameObject.AddComponent<TouchController>(); } touchControllerRef = gameObject.GetComponent<TouchController>(); }
// Ensures game needed scripts are added to the overall 'MainObject'. Should only be called if you're referencing the MainObject! public void EnsureGameScriptsAdded() { if(!gameObject.GetComponent<AnimationManager>()){ gameObject.AddComponent<AnimationManager>(); } if(!gameObject.GetComponent<PlayerManager>()){ gameObject.AddComponent<PlayerManager>(); } if(!gameObject.GetComponent<TouchController>()){ gameObject.AddComponent<TouchController>(); } if(!gameObject.GetComponent<WorldCollision>()){ gameObject.AddComponent<WorldCollision>(); } if(!gameObject.GetComponent<InputManager>()){ gameObject.AddComponent<InputManager>(); } gameObject.GetComponent<AnimationManager>().enabled = true; gameObject.GetComponent<PlayerManager>().enabled = true; gameObject.GetComponent<TouchController>().enabled = true; gameObject.GetComponent<WorldCollision>().enabled = true; gameObject.GetComponent<InputManager>().enabled = true; if(!animManagerRef){ animManagerRef = gameObject.GetComponent<AnimationManager>(); } if(!touchControllerRef){ touchControllerRef = gameObject.GetComponent<TouchController>(); } if(!worldCollisionRef){ worldCollisionRef = gameObject.GetComponent<WorldCollision>(); // UnityEngine.Debug.Log("TRUE"); } }
/// \} // ----------------- // Hide documentation /// \cond // ------------------ // --------------------- override public void Init(TouchController joy) { base.Init(joy); this.joy = joy; this.fingerA = new Finger(this); this.fingerB = new Finger(this); this.AnimateParams( (this.overrideScale ? this.releasedScale : this.joy.releasedZoneScale), (this.overrideColors ? this.releasedColor : this.joy.defaultReleasedZoneColor), 0); this.OnReset(); if (this.initiallyDisabled) this.Disable(true); if (this.initiallyHidden) this.Hide(true); }
void OnTriggerEnter2D(Collider2D other) { // If the player enters the trigger zone... if(!pegou && other.tag == "Player") { // ... play the pickup sound effect. AudioSource.PlayClipAtPoint(pickupClip, transform.position); pegou = true; touch = GameObject.Find("hero2").GetComponent<TouchController>(); touch.enabled = false; } }
// Use this for initialization void Start() { #region initialization // NOTICE : DOM // the following is now needed // due to the prefab of 'MainObject' GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); gameStateManagerRef.EnsureScriptAdded("TouchController"); soundManagerRef = mainObject.GetComponent<SoundManager>(); screenManagerRef = mainObject.GetComponent<ScreenManager>(); #region initialize references backsidePivotReference = GameObject.Find("backsidepivot"); coverupPivotReference = GameObject.Find ("coveruppivot"); tornBacksidePieceReference = GameObject.Find ("tornBacksidePiece"); //sets the reference of the touchcontroller to the touchcontroller script. touchController = mainObject.GetComponent<TouchController>(); //sets the reference of the backsidesideReference to the backside or "fold" backsideReference = backsidePivotReference.transform.FindChild("backside").gameObject; backSideInitialColor = backsideReference.GetComponent<MeshRenderer>().material.color; //sets the reference of the backsideCollisionReference to the platforms on the back of the paper. backsideCollisionReference = GameObject.FindGameObjectsWithTag("FoldPlatform"); //sets the camera reference to the main camera cameraReference = GameObject.Find("Main Camera"); //sets the player reference to the player playerReference = GameObject.Find("Player_Prefab"); //sets the backgroundTransform to the transform of the background paper. origBackground = GameObject.FindGameObjectWithTag("background"); backgroundTransform = origBackground.transform; //sets backgroundBounds to the bounds of the background paper backgroundBounds = backgroundTransform.GetComponent<MeshFilter>().mesh.bounds; //sets changeMeshScript to the ChangeMeshScript which removes and restores triangles. changeMeshScript = this.GetComponent<ChangeMeshScript>(); tearReference = GameObject.Find("Tear_Manager").GetComponent<TearManager>(); coverupReference = coverupPivotReference.transform.FindChild("coverup").gameObject; tearPaperMesh = GameObject.Find("backside").GetComponent<MeshFilter>().mesh; unfoldCollisionReference = GameObject.Find("Player_Prefab").GetComponent<UnfoldCollision>(); shadowReference = GameObject.Find("shadow"); rayTraceBlockRef = GameObject.Find("rayTraceBlocker"); paperBorderInsideRef = GameObject.Find("paper_border_inside"); paperBorderOutsideRef = GameObject.Find("paper_border_outside"); worldCollisionRef = mainObject.GetComponent<WorldCollision>(); backsideTriangles = tearPaperMesh.triangles; #endregion //sets original position and rotation to its starting position and rotation foldOriginalRotation = backsidePivotReference.transform.rotation; foldOriginalPosition = backsidePivotReference.transform.position; //sets starting position coverup's starting position coverupStartingPosition = coverupPivotReference.transform.position; //sets coverup's original position to the vector required for the tranforms to work properly coverupOriginalPosition = new Vector3(0,0,-3); //sets coverup's original rotation to its starting rotation coverupOriginalRotation = coverupPivotReference.transform.rotation; coverupPrefab = coverupPivotReference.transform; foldPrefab = backsidePivotReference.transform; //initializes variables to defaults. fingerList = new List<Vector2>(); backgroundObjMax = new Vector2(); backgroundObjMin = new Vector2(); posModifier = new Vector3(); posModLastValid = new Vector3(); unfoldPosModifier = new Vector3(); foldTmpZLayer = GVariables.zFoldLayer - 1; coverupTmpZLayer = GVariables.zCoverLayer -1; prevMousestate = false; currMouseState = false; firstTouch = false; isFolded = false; overPlayer = false; needsToUnfold = false; isOffPaper = true; backsideIsInstantiated = false; currentlyFolding = false; missingTriangles = new List<Vector3>(); //changeMeshScript.GrabUpdatedPlatforms("FoldPlatform"); deletedTri = new int[0]; startingQuadrant = Quadrant.NONE; currentQuadrant = Quadrant.NONE; foldEdge = Edge.BuildManifoldEdges(backsideReference.GetComponent<MeshFilter>().mesh); guiEnable = false; blah = false; foldInput = false; prevFoldInput = false; #endregion }
/// <summary> /// Use this for initialization /// </summary> private void Start() { // assign touch controller for android touchController = GameObject.FindGameObjectWithTag("MainObject").GetComponent<TouchController>(); gameStateManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<GameStateManager>(); gameStateManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<GameStateManager>(); inputManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<InputManager>(); originalColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); paperPlatforms = new List<GameObject>(); paperPlatforms.Add (Platform1); paperPlatforms.Add (Platform2); paperPlatforms.Add (Platform3); paperPlatforms.Add (Platform4); //Update platofrms attacked to sutt piece if(paperPlatforms.Count() > 0 && NeedToUpdatePlatforms) { foreach(GameObject go in paperPlatforms) { //Debug.LogError("TESTING"); if(Clone.GetComponent<MeshFilter>().mesh.triangles.Contains(go.GetComponent<Demo_PlatformMovement>().Indexer)) { go.transform.Rotate(new Vector3(0, 0, go.GetComponent<Demo_PlatformMovement>().AngleOffset)); } else { go.transform.Rotate(new Vector3(0, 0, go.GetComponent<Demo_PlatformMovement>().AngleOffset)); } } } newPiece = newPaper; if(GetComponent<MeshFilter>().mesh.vertices[0].x != GetComponent<MeshFilter>().mesh.vertices[1].x) { MESH_VERT_OFFSET = this.transform.TransformPoint(GetComponent<MeshFilter>().mesh.vertices[0]).x - this.transform.TransformPoint(GetComponent<MeshFilter>().mesh.vertices[1]).x; } else { MESH_VERT_OFFSET = this.transform.TransformPoint(GetComponent<MeshFilter>().mesh.vertices[0]).y - this.transform.TransformPoint(GetComponent<MeshFilter>().mesh.vertices[1]).y; } if(MESH_VERT_OFFSET < 0) MESH_VERT_OFFSET *= -1; //Initially, we set the paper's screen position to be zero screenPoint = new Vector3(0.0f, 0.0f, 0.0f); //Initialize the newMesh to be the same length of the previous newMesh = new Vector3[mesh.vertices.Length]; //Create a clone world mesh for deformation, we do not change the original world gameobject mesh //if (!CloneObject) CreateNewPaperWorld(); //Make sure the offset is positive if(MESH_VERT_OFFSET < 0) { MESH_VERT_OFFSET *= -1; } //Testing, output the offset //Debug.LogWarning("Mesh vertice offset = " + MESH_VERT_OFFSET.ToString()); //Initialize the max and min world values of mesh mertex coordinates WIDTH_MAX = -100; WIDTH_MIN = 100; HEIGHT_MAX = -100; HEIGHT_MIN = 100; SetBoundsOfPaper(); //init the dictionary storing the vertices along the tear line and their associated index //into the the mesh.vertice array tearLine = new Dictionary<Vector3, int>(); tearLineTime = new Dictionary<Vector3, float>(); tearLinePositionTime = new Dictionary<float, Vector3>(); decalDictionary = new Dictionary<GameObject, int>(); //edgeVertsForcedTorn = new List<Vector3>(); //Set the tearLineTimer to zero initially as the starting tear line 'time' tearLineTimer = 0; SetPaperGrid(); int testListCount = 1; foreach(List<Vector3> list in paperGrid.Values) { //Debug.LogError("list #" + testListCount.ToString()); int testPosCount = 1; //foreach(Vector3 pos in list) { //Debug.LogError("Adding new vert #" + testPosCount + " to newPaperGrid = " + pos.ToString()); ++testPosCount; } ++testListCount; } //Create a clone world mesh for deformation, we do not change the original world gameobject mesh if (!CloneObject) CreateNewPaperWorld(); //Find the distance between any two adjacent points on mesh //(assumming mesh has even distribution of vertices) // This is used to know where neighbor vertices are located //MESH_VERT_OFFSET = paperGrid.Values.ElementAt(0).ElementAt(0).x - paperGrid.Values.ElementAt(0).ElementAt(1).x; //Debug.Log("MESH_VERT_OFFSET = " + MESH_VERT_OFFSET.ToString()); }
// ------------------- public void SetTouchController(TouchController joy) { this.touchCtrl = joy; }
// Use this for initialization. public void Start() { // Keeping GameObject component grabbing consistent among classes. - J.T. GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if(GameObject.FindGameObjectsWithTag("MainObject").Length > 1){ GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for(int i = 0; i < mainObjectList.Length; ++i){ if(mainObjectList[i].GetComponent<GameStateManager>().objectSaved){ mainObject = mainObjectList[i]; } } } gameStateManagerRef = mainObject.GetComponent <GameStateManager>(); gameStateManagerRef.EnsureGameScriptsAdded(); gameStateManagerRef.EnsureCoreScriptsAdded(); screenManagerRef = mainObject.GetComponent<ScreenManager>(); animManagerRef = mainObject.GetComponent<AnimationManager>(); worldCollisionRef = mainObject.GetComponent<WorldCollision>(); touchController = gameObject.GetComponent<TouchController>(); soundManagerRef = gameStateManagerRef.GetSoundManager(); paperObject = GameObject.FindGameObjectWithTag("background"); tearBorder = GameObject.FindGameObjectWithTag("DeadSpace"); foldBorder = GameObject.FindGameObjectWithTag("foldborder"); unfoldBorder = GameObject.FindGameObjectWithTag("unfoldborder"); unfoldBlocker = GameObject.FindGameObjectWithTag("RayTraceBlocker"); moveBorder = GameObject.FindGameObjectWithTag("insideBorder"); menuButton = GameObject.Find("MenuButton_Prefab"); restartButton = GameObject.Find("RestartButton_Prefab"); moveMode = true; tearMode = false; foldMode = false; //Keeping old code here in case something gets broken. - J.T. // Ensures all necessary scripts are added for the MainObject. /* gameStateManagerRef = gameObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); gameStateManagerRef.EnsureGameScriptsAdded(); screenManagerRef = gameObject.GetComponent<ScreenManager>(); animManagerRef = gameObject.GetComponent<AnimationManager>(); worldCollisionRef = gameObject.GetComponent<WorldCollision>(); touchController = gameObject.GetComponent<TouchController>(); */ idleTriggerLimit = Random.Range (1000, 3000); keyDownWatch = new Stopwatch(); idleKeyWatch = new Stopwatch(); releaseWatch = new Stopwatch(); justPressedWatch = new Stopwatch(); playerBottomCollisionWatch = new Stopwatch(); idlePlayerWatch = new Stopwatch(); watchList.Add(keyDownWatch); watchList.Add(idleKeyWatch); watchList.Add(releaseWatch); watchList.Add(justPressedWatch); watchList.Add(playerBottomCollisionWatch); watchList.Add(idlePlayerWatch); wasdRight = KeyCode.D; wasdLeft = KeyCode.A; arrowRight = KeyCode.RightArrow; arrowLeft = KeyCode.LeftArrow; keyJump = KeyCode.Space; hasHorizontalCollision = false; currentDirection = ScreenSide.NONE; tornPieceInitiated = false; movingTornPiece = false; }