コード例 #1
0
ファイル: GameBehavior.cs プロジェクト: asrutan/CyberGang
    void Hover(Vector3 mposition)
    {
        RaycastHit hit;
        Ray        ray = camera.ScreenPointToRay(mposition);

        if (Physics.Raycast(ray, out hit))
        {
            Transform objectHit = hit.transform;
            if (objectHit.tag == "Card")
            {
                if (highlightedCard != null)
                {
                    highlightedCard.Highlight(false);
                }
                highlightedCard = objectHit.gameObject.GetComponent <CardBehavior>();
                highlightedCard.Highlight(true);
            }

            else if (objectHit.tag == "Button")
            {
                highlightedButton = objectHit.gameObject.GetComponent <ButtonBehavior>();
                highlightedButton.Highlight(true);
            }

            else if (objectHit.tag == "Combatant")
            {
                highlightedCombatant = objectHit.gameObject.GetComponent <CombatantBehavior>();
                highlightedCombatant.Highlight(true);
            }

            else
            {
                if (highlightedCard != null)
                {
                    highlightedCard.Highlight(false);
                    highlightedCard = null;
                }
                if (highlightedButton != null)
                {
                    highlightedButton.Highlight(false);
                    highlightedButton = null;
                }
                if (highlightedCombatant != null)
                {
                    highlightedCombatant.Highlight(false);
                    highlightedCombatant = null;
                }
            }
        }
    }