// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(mouseRay, out raycastHit)) { if (raycastHit.transform.tag == "Car") tmpCar = raycastHit.transform.gameObject; //else tmpCar = null; switch (currentState) { case SelectorState.CAR_SELECTION: if (tmpCar != null) currentState = SelectorState.TERRAIN_SELECTION; break; case SelectorState.TERRAIN_SELECTION: /* if (tmpCar != null) currentState = SelectorState.CAR_SELECTION; else {*/ if (raycastHit.transform.tag != "Car"){ destPosition = raycastHit.point; tmpCar.SendMessage("move", destPosition, SendMessageOptions.DontRequireReceiver); } //} break; }//End switch current state }//Endraycast } }
private void UpdateSelector(PointerEventData eventData) { Vector2 localPosition = Vector2.zero; RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position, eventData.pressEventCamera, out localPosition); localPosition *= 1.0f / (rectTransform.sizeDelta.x * 0.5f); if (selectorState == SelectorState.None) { float dist = Vector2.Distance(Vector2.zero, localPosition); if (dist <= 0.8f) { selectorState = SelectorState.InnerColor; } else { selectorState = SelectorState.OuterColor; } } switch (selectorState) { case SelectorState.InnerColor: SelectInnerColor(localPosition); break; case SelectorState.OuterColor: SelectOuterColor(localPosition); break; } }
void ConfirmSelection() { Debug.Log("CONFIRM selection"); // selctionConfirmed = true; selectorState = SelectorState.ShipSelected; gameController.SetPlayerShip(playerID, shipSelectionDisplay[selectionIndex].shipType); }
public void closeHeroSelector() { if (currentState == SelectorState.Open) { currentState = SelectorState.Closed; heroSelectorUiAnimator.Play("SlideDown"); } }
void Start() { heroButtons = gameObject.GetComponentsInChildren <SelectHeroButton>().ToList(); heroSelectorUiAnimator = gameObject.GetComponent <Animator>(); buildHeroPicker(); requisitionManager = GameObject.FindWithTag("RequisitionManager").GetComponent <RequisitionManager>(); currentState = SelectorState.Closed; }
void UnConfirmSelection() { Debug.Log("Unconfiurm selection"); selectorState = SelectorState.WaitingForShipSelection; // selctionConfirmed = false; gameController.RemovePlayerShip(playerID); }
void QuitGame() { Debug.Log("QUIT GAME"); // joinedGame = false; selectorState = SelectorState.WaitingToJoin; shipSelector.SetActive(false); joinMessage.SetActive(true); }
void JoinGame() { Debug.Log("JOIN GAME"); // joinedGame = true; selectorState = SelectorState.WaitingForShipSelection; shipSelector.SetActive(true); joinMessage.SetActive(false); }
private void Start() { selectedColor = Color.red; selectorAngle = 0.0f; innerDelta = Vector2.zero; finalColorImage.color = finalColor; rectTransform = transform as RectTransform; selectorState = SelectorState.None; SelectInnerColor(Vector2.zero); }
public void openHeroSelector() { if (currentState == SelectorState.Closed) { heroSelectorUiAnimator.Play("SlideUp"); currentState = SelectorState.Open; } else { heroSelectorUiAnimator.Play("Blink"); } }
/// <summary> Finishes the closing of the selector </summary> private void FinishClosing() { currentstate = SelectorState.closed; time_frames = 1; }
/// <summary> Finishes the opening of the selector </summary> private void FinishOpening() { currentstate = SelectorState.opened; time_frames = 1; }
/// <summary> Beginns the closing of the selector </summary> private void Close() { currentstate = SelectorState.closing; time_frames = 1; }
public void OnPointerUp(PointerEventData eventData) { selectorState = SelectorState.None; }
void JoinGame() { Debug.Log("JOIN GAME"); // joinedGame = true; selectorState = SelectorState.WaitingForShipSelection; shipSelector.SetActive (true); joinMessage.SetActive (false); }
public void SetVisibleSelection(int playerID, SelectorState state, int change) { visibleSelection[playerID] = state; SetCharacterSelection(visibleSelection[playerID], change, playerID); }
// Use this for initialization void Start() { currentState = SelectorState.CAR_SELECTION; }
void QuitGame() { Debug.Log("QUIT GAME"); // joinedGame = false; selectorState = SelectorState.WaitingToJoin; shipSelector.SetActive (false); joinMessage.SetActive (true); }
public void Init() { if (options_icons == null || options_icons.Length != options_str.Length) { options_icons = new Sprite [options_str.Length]; } for (int i = 0; i < options_str.Length; i++) { if (options_icons [i] == null) { options_icons [i] = Globals.selector_data.default_sprite; } } initialized = true; map_cam = SceneGlobals.map_camera; main_rect_trans = GetComponent <RectTransform>(); body_rect_trans = body.GetComponent <RectTransform>(); mousepos_delta = Vector2.zero; float txt_width = GetMaxWidth() + 30; head_height = head.GetComponent <RectTransform>().rect.height; tail_height = tail.GetComponent <RectTransform>().rect.height; width = txt_width + 20; _graphicscomponents.Add(head); _graphicscomponents.Add(body); _graphicscomponents.Add(tail); Position.Set((int)transform.position.x, (int)transform.position.y); button_height = optionsButton.GetComponent <RectTransform>().rect.height; for (byte i = 0; i < options_str.Length; i++) { string possibility = options_str[i]; GameObject new_button_obj = Instantiate(optionsButton.gameObject); RectTransform button_rect = new_button_obj.GetComponent <RectTransform>(); button_rect.position = new Vector3(0, -(i + .5f) * button_height); button_rect.sizeDelta = new Vector3(txt_width + 6, button_height); Text button_text = new_button_obj.GetComponentInChildren <Text>(); button_text.text = possibility; button_text.rectTransform.sizeDelta = new Vector3(txt_width, button_height); new_button_obj.transform.SetParent(body.transform, false); new_button_obj.transform.SetAsLastSibling(); new_button_obj.GetComponent <SelectorButton>().Init(this, i, options_icons[i], options_flags[i], option_functions[i]); } min_height = 0; max_height = (ushort)(button_height * options_str.Length); delta_height = (ushort)(max_height - min_height); Height = 0; currentstate = SelectorState.closed; Open(); }
/// <summary> Beginns the opening of the selector </summary> private void Open() { currentstate = SelectorState.opening; time_frames = 1; }