コード例 #1
0
ファイル: CarSelector.cs プロジェクト: cbleck/UnityLab6
    // 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
        }
    }
コード例 #2
0
    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;
        }
    }
コード例 #3
0
    void ConfirmSelection()
    {
        Debug.Log("CONFIRM  selection");
//		selctionConfirmed = true;
        selectorState = SelectorState.ShipSelected;

        gameController.SetPlayerShip(playerID, shipSelectionDisplay[selectionIndex].shipType);
    }
コード例 #4
0
 public void closeHeroSelector()
 {
     if (currentState == SelectorState.Open)
     {
         currentState = SelectorState.Closed;
         heroSelectorUiAnimator.Play("SlideDown");
     }
 }
コード例 #5
0
 void Start()
 {
     heroButtons            = gameObject.GetComponentsInChildren <SelectHeroButton>().ToList();
     heroSelectorUiAnimator = gameObject.GetComponent <Animator>();
     buildHeroPicker();
     requisitionManager = GameObject.FindWithTag("RequisitionManager").GetComponent <RequisitionManager>();
     currentState       = SelectorState.Closed;
 }
コード例 #6
0
    void UnConfirmSelection()
    {
        Debug.Log("Unconfiurm selection");
        selectorState = SelectorState.WaitingForShipSelection;
//		selctionConfirmed = false;

        gameController.RemovePlayerShip(playerID);
    }
コード例 #7
0
    void QuitGame()
    {
        Debug.Log("QUIT GAME");
//		joinedGame = false;
        selectorState = SelectorState.WaitingToJoin;
        shipSelector.SetActive(false);
        joinMessage.SetActive(true);
    }
コード例 #8
0
    void JoinGame()
    {
        Debug.Log("JOIN GAME");
//		joinedGame = true;
        selectorState = SelectorState.WaitingForShipSelection;
        shipSelector.SetActive(true);
        joinMessage.SetActive(false);
    }
コード例 #9
0
    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);
    }
コード例 #10
0
 public void openHeroSelector()
 {
     if (currentState == SelectorState.Closed)
     {
         heroSelectorUiAnimator.Play("SlideUp");
         currentState = SelectorState.Open;
     }
     else
     {
         heroSelectorUiAnimator.Play("Blink");
     }
 }
コード例 #11
0
ファイル: SelectorLike.cs プロジェクト: bionick7/4040Machines
 /// <summary> Finishes the closing of the selector </summary>
 private void FinishClosing()
 {
     currentstate = SelectorState.closed;
     time_frames  = 1;
 }
コード例 #12
0
ファイル: SelectorLike.cs プロジェクト: bionick7/4040Machines
 /// <summary> Finishes the opening of the selector </summary>
 private void FinishOpening()
 {
     currentstate = SelectorState.opened;
     time_frames  = 1;
 }
コード例 #13
0
ファイル: SelectorLike.cs プロジェクト: bionick7/4040Machines
 /// <summary> Beginns the closing of the selector </summary>
 private void Close()
 {
     currentstate = SelectorState.closing;
     time_frames  = 1;
 }
コード例 #14
0
 public void OnPointerUp(PointerEventData eventData)
 {
     selectorState = SelectorState.None;
 }
コード例 #15
0
	void UnConfirmSelection() {
		Debug.Log("Unconfiurm selection");
		selectorState = SelectorState.WaitingForShipSelection;
//		selctionConfirmed = false;

		gameController.RemovePlayerShip(playerID);
	}
コード例 #16
0
	void JoinGame() {
		Debug.Log("JOIN GAME");
//		joinedGame = true;
		selectorState = SelectorState.WaitingForShipSelection;
		shipSelector.SetActive (true);
		joinMessage.SetActive (false);
	}
コード例 #17
0
 public void SetVisibleSelection(int playerID, SelectorState state, int change)
 {
     visibleSelection[playerID] = state;
     SetCharacterSelection(visibleSelection[playerID], change, playerID);
 }
コード例 #18
0
ファイル: CarSelector.cs プロジェクト: cbleck/UnityLab6
 // Use this for initialization
 void Start()
 {
     currentState = SelectorState.CAR_SELECTION;
 }
コード例 #19
0
	void QuitGame() {
		Debug.Log("QUIT GAME");
//		joinedGame = false;
		selectorState = SelectorState.WaitingToJoin;
		shipSelector.SetActive (false);
		joinMessage.SetActive (true);
	}
コード例 #20
0
ファイル: SelectorLike.cs プロジェクト: bionick7/4040Machines
    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();
    }
コード例 #21
0
	void ConfirmSelection() {
		Debug.Log("CONFIRM  selection");
//		selctionConfirmed = true;
		selectorState = SelectorState.ShipSelected;

		gameController.SetPlayerShip(playerID, shipSelectionDisplay[selectionIndex].shipType);
	}
コード例 #22
0
ファイル: SelectorLike.cs プロジェクト: bionick7/4040Machines
 /// <summary> Beginns the opening of the selector </summary>
 private void Open()
 {
     currentstate = SelectorState.opening;
     time_frames  = 1;
 }