Beispiel #1
0
    protected override void Awake()
    {
        m_transform = transform;

        m_MouseLook = GetComponent <MouseLook>();
        hPadLook    = GetComponent <PadLook>();

        ObjectManager.instance.AddObject(this);

        //used to highlight previews vs real objects
        _previewMaterial = Resources.Load <Material>("Materials/previewmat");

        power = defaultPower;

        //attach camera
        //use the camera placed in the world rather than put cameras into prefabs for now
        m_cameraTransform               = Camera.main.transform;
        _cameraParentOrigin             = m_cameraTransform.parent;
        m_cameraTransform.parent        = m_transform.GetChild(0).transform;
        m_cameraTransform.localPosition = Vector3.zero;
        m_cameraTransform.localRotation = Quaternion.identity;

        ON_ABSORBED.AddListener(OnAbsorbed);

        base.Awake();
    }
Beispiel #2
0
    public void PosessBody(PowerObject obj)
    {
        DebugUtils.Assert(obj != null);
        if (obj == null)
        {
            return;
        }

        if (obj.GetType() != typeof(PO_Robot))
        {
            return;
        }

        if (m_currentBody)
        {
            foreach (Renderer ren in m_currentBody.GetComponentsInChildren <Renderer>(true))
            {
                ren.enabled = true;
            }

            m_currentBody.transform.parent = null;
        }

        m_transform.root.position   = obj.transform.position;
        obj.transform.parent        = m_transform;
        obj.transform.localRotation = Quaternion.identity;
        obj.transform.localPosition = Vector3.zero;

        if (m_currentBody)
        {
            //look at the body you came from
            hPadLook = GetComponent <PadLook>();
            hPadLook.LookAt(m_currentBody.transform.position);

            m_MouseLook = GetComponent <MouseLook>();
        }

        m_currentBody = obj;

        foreach (Renderer ren in m_currentBody.GetComponentsInChildren <Renderer>(true))
        {
            ren.enabled = false;
        }
    }