Beispiel #1
0
    public void SetActiveToken(bool isActive)
    {
        this.isActive = isActive;

        if (isActive)
        {
            activeToken = this;

            material.SetInt("_IsHighlighted", 1);
            material.SetColor("_HighlightColor", AdventureManager.Instance.colorSelections.active);
        }
        else
        {
            activeToken = null;

            material.SetInt("_IsHighlighted", 0);
            material.SetColor("_HighlightColor", AdventureManager.Instance.colorSelections.unselected);
        }
    }
Beispiel #2
0
    public void ActiveToken()
    {
        isActive = !isActive;

        if (isActive)
        {
            if (activeToken != null)
            {
                activeToken.ActiveToken();
            }

            activeToken = this;

            material.SetInt("_IsHighlighted", 1);
            material.SetColor("_HighlightColor", AdventureManager.Instance.colorSelections.active);
        }
        else
        {
            activeToken = null;

            material.SetInt("_IsHighlighted", 0);
            material.SetColor("_HighlightColor", AdventureManager.Instance.colorSelections.unselected);
        }
    }
Beispiel #3
0
    private void Update()
    {
        //Ping debug
        if (Input.GetKeyDown(KeyCode.P))
        {
            NetworkManager.PingServer();
        }

        MouseStep mouseLeftStep = MouseStep.NONE;

        if (Input.GetMouseButtonUp(0))
        {
            mouseLeftStep = MouseStep.RELEASED;
        }
        else if (Input.GetMouseButtonDown(0))
        {
            mouseLeftStep = MouseStep.JUST_PRESSED;
        }
        else if (Input.GetMouseButton(0))
        {
            mouseLeftStep = MouseStep.PRESSED;
        }

        MouseStep mouseRightStep = MouseStep.NONE;

        if (Input.GetMouseButtonUp(1))
        {
            mouseRightStep = MouseStep.RELEASED;
        }
        else if (Input.GetMouseButtonDown(1))
        {
            mouseRightStep = MouseStep.JUST_PRESSED;
        }
        else if (Input.GetMouseButton(1))
        {
            mouseRightStep = MouseStep.PRESSED;
        }


        Ray        ray = mainCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo))
        {
            if (TokenPawn.activeToken != null)
            {
                switch (mouseLeftStep)
                {
                case MouseStep.RELEASED:
                    TokenPawn.activeToken.SetActiveToken(false);
                    break;

                case MouseStep.PRESSED:
                    TokenPawn.activeToken.MovePawn(hitInfo.point, Vector3.zero, Vector3.one);
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (hitInfo.collider.tag == "Pawn")
                {
                    TokenPawn pawn = hitInfo.collider.GetComponent <TokenPawn>();
                    if (pawn != null)
                    {
                        //if a token is selected and is not the token
                        if (tokenSelected != null && tokenSelected != pawn)
                        {
                            tokenSelected.UnselectToken();
                            tokenSelected = null;
                        }

                        switch (mouseLeftStep)
                        {
                        case MouseStep.NONE:
                            tokenSelected = pawn;
                            tokenSelected.SelectToken();
                            break;

                        case MouseStep.RELEASED:
                            pawn.SetActiveToken(false);
                            break;

                        case MouseStep.JUST_PRESSED:
                            pawn.SetActiveToken(true);
                            break;

                        case MouseStep.PRESSED:
                            if (TokenPawn.activeToken != null)
                            {
                                TokenPawn.activeToken.MovePawn(hitInfo.point, Vector3.zero, Vector3.one);
                            }
                            break;

                        default:
                            break;
                        }

                        if (mouseRightStep == MouseStep.JUST_PRESSED)
                        {
                            pawn.DestroyPawn();
                        }
                    }
                }
                else
                {
                    if (tokenSelected != null)
                    {
                        tokenSelected.UnselectToken();
                        tokenSelected = null;
                    }
                }
            }
        }
    }