Exemplo n.º 1
0
    void OnMouseEnter()
    {
        if (!_pointerClass)
            _pointerClass = _gameObject.GetComponent<C_LocationPointer>();
        if (!_heroClass || !_heroGO || !_heroTran) {
            C_GameManager gameManagerClass = GameObject.Find("Game Manager").GetComponent<C_GameManager>();
            _heroGO = gameManagerClass.z_thisPlayerGO;
            _heroClass = _heroGO.GetComponent<C_Hero>();
            _heroTran = _heroGO.transform;
        }
        if (!_attackIconTran || !_attackIconTex) {
            _attackIconTran = GameObject.Find("Hero Attack Icon").transform;
            _attackIconTex = _attackIconTran.GetComponent<GUITexture>();
        }

        if (_pointerClass.z_associatedWith == null)
            return;
        //if (_pointerClass.z_associatedWith.z_team == _heroClass.z_team)
        //    return;
        if ( ((C_Hero.CurrentStats) _heroClass.z_curStats).energy == 0 )
            return;

        if ( C_LocationPointer.Z_InRange(_heroClass.z_associatedWith, _gameObject, 1, false) ) {
            _attackIconTex.enabled = true;
            _attackIconTran.position = _camera.WorldToViewportPoint(_transform.position);
        }
    }
Exemplo n.º 2
0
    void OnMouseEnter()
    {
        if (!_pointerClass)
            _pointerClass = _gameObject.GetComponent<C_LocationPointer>();
        if (!_heroClass || !_heroGO || !_heroTran) {
            C_GameManager gameManagerClass = GameObject.Find("Game Manager").GetComponent<C_GameManager>();
            _heroGO = gameManagerClass.z_thisPlayerGO;
            _heroClass = _heroGO.GetComponent<C_Hero>();
            _heroTran = _heroGO.transform;
        }
        if (!_moveIconTran || !_moveIconRender) {
            _moveIconTran = GameObject.Find("Hero Move Icon").transform;
            _moveIconRender = _moveIconTran.GetComponent<Renderer>();
        }

        if (_pointerClass.z_associatedWith != null)
            return;
        if ( ((C_Hero.CurrentStats) _heroClass.z_curStats).energy == 0 )
            return;

        if ( C_LocationPointer.Z_InRange(_heroClass.z_associatedWith, _gameObject, 1, false) ) {
            _moveIconRender.enabled = true;
            _moveIconTran.position = _transform.position + (new Vector3(0,0.01f,0));

            float angle = Vector3.Angle(Vector3.forward, _transform.position - _heroTran.position);
            int dir = Z_AngleDir(Vector3.forward, _transform.position - _heroTran.position, Vector3.up);
            if (dir != 0)
                angle *= dir;
            Vector3 eulerAngles = _moveIconTran.rotation.eulerAngles;
            eulerAngles.y = angle;
            _moveIconTran.rotation = Quaternion.Euler(eulerAngles);
        }
    }
    /************************************ private  methods *********************************/
    bool Z_IsConnectedTo(C_LocationPointer pointer, int range)
    {
        if (range == 0)
            return false;

        for (int i=0; i < m_connectionsNo; i++) {
            if (pointer == m_connectionsClass[i])
                return true;
            else if ( m_connectionsClass[i].Z_IsConnectedTo(pointer, range - 1) )
                return true;
        }

        return false;
    }