示例#1
0
    // Update is called once per frame
    private void FixedUpdate()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.tag.Equals("CheckPoint") || hit.transform.tag.Equals("Pawn"))
            {
                //Enable area highlight
                this.light.enabled = true;
                this.gameObject.transform.LookAt(hit.transform);

                //Set current target
                if (hit.transform.tag.Equals("CheckPoint"))
                {
                    this.targetCheckSpace = hit.transform.gameObject.GetComponent <CheckSpace>();
                }
                else
                {
                    this.targetCheckSpace = hit.transform.gameObject.GetComponent <Pawn>().checkSpace;
                }
            }
            else
            {
                this.light.enabled    = false;
                this.targetCheckSpace = null;
            }
        }
        else
        {
            this.light.enabled    = false;
            this.targetCheckSpace = null;
        }
    }
示例#2
0
    private void ExecuteGameLogic()
    {
        if (!gameManager.isInitialised)
        {
            //wait for ready state of operation so it's interactable
            gameInfo.text = "Setting up";
            return;
        }

        //check if can move
        if (mTurnJSON.GetColour(this.userID).Equals(Color.white))
        {
            if (!gameManager.isWhitesTurn)
            {
                gameInfo.text = "It's your opponents turn (Black)";
                return; //not your turn;
            }
            else
            {
                gameInfo.text = "It's Your turn (White)";
            }
        }
        else
        {
            if (!gameManager.isBlacksTurn)
            {
                gameInfo.text = "It's your opponents turn (White)";
                return; //not your turn;
            }
            else
            {
                gameInfo.text = "It's Your turn (Black)";
            }
        }

        if (Input.GetMouseButtonUp(0) && this.checkPositionTarget.targetCheckSpace != null)
        {
            if (this.selectedCheckspace != null)
            {
                this.selectedCheckspace.gameObject.GetComponent <Renderer>().material = oldMaterial;
                this.selectedCheckspace = null;
            }
            this.selectedCheckspace = this.checkPositionTarget.targetCheckSpace;
            this.oldMaterial        = this.selectedCheckspace.gameObject.GetComponent <Renderer>().material;
            this.selectedCheckspace.gameObject.GetComponent <Renderer>().material = highlightMaterial;
        }
        else if (Input.GetMouseButtonUp(1))
        {
            if (this.selectedCheckspace != null)
            {
                this.selectedCheckspace.gameObject.GetComponent <Renderer>().material = oldMaterial;
                this.selectedCheckspace = null;
            }
        }
    }