Ejemplo n.º 1
0
 private void Awake()
 {
     m_pc             = GetComponent <PlayerCharacter>();
     m_controller     = GetComponent <PlayerController>();
     m_statusWidget   = GetComponentInChildren <StatusWidget>();
     m_actionBar      = GetComponentInChildren <ActionBar>();
     m_characterAnim  = GetComponent <Animator>();
     m_weapon         = GetComponentInChildren <Weapon>();
     m_playerState    = new StateMachine((int)GSDefine.PlayerState.IDLE);
     m_pc.PlayerState = m_playerState;
     m_skillsColdTime = new float[5];
     SetHitEffect();
     SetSkillTree();
 }
Ejemplo n.º 2
0
    private void AddWidget(Widget widget)
    {
        GameObject widgetGO = new GameObject(widget.type.ToString() + ": " + widget.NetworkKey);

        widgetGO.transform.SetParent(gameObject.transform);
        widgetGO.transform.localScale    = new Vector3(0.1f, 0.1f, 0.1f);
        widgetGO.transform.localPosition = new Vector3(widget.Position[0] * 0.5f, widget.Position[1] * 0.5f, widget.Position[2] * 0.5f);

        //Background Plane
        GameObject backgroundPlane = GameObject.CreatePrimitive(PrimitiveType.Plane);

        backgroundPlane.transform.SetParent(widgetGO.transform);

        backgroundPlane.transform.localScale    = new Vector3(0.97f, 0.48f, 0.48f);
        backgroundPlane.transform.localRotation = Quaternion.Euler(90, 0, 180);
        backgroundPlane.transform.localPosition = new Vector3(0, 0, 0.05f);

        MeshRenderer planeRenderer = backgroundPlane.GetComponent <MeshRenderer>();

        planeRenderer.material.color = new Color(0.4f, 0.4f, 0.4f, 0.75f);

        //Text Component
        GameObject TextGO = Instantiate(Text, widgetGO.transform, false);

        TextGO.transform.localPosition = new Vector3(0, 0, -0.05f);
        TextGO.transform.localRotation = Quaternion.identity;


        switch (widget.type)
        {
        case WidgetType.Text:
            //Text Widget Display
            TextWidget textWidget = widgetGO.AddComponent <TextWidget>();
            textWidget.Text  = TextGO.GetComponent <TMPro.TextMeshPro>();
            textWidget.Key   = widget.NetworkKey;
            textWidget.Label = widget.Label;
            break;

        case WidgetType.Camera:
            //remove text
            Destroy(TextGO);

            backgroundPlane.transform.localScale = new Vector3(16f / 16f, 1, 9f / 16f);
            planeRenderer.material.color         = new Color(1f, 1f, 1f, 1f);

            //Camera Widget
            WebStream webStream = widgetGO.AddComponent <WebStream>();
            webStream.sourceURL = widget.NetworkKey;
            webStream.frame     = planeRenderer;
            break;

        case WidgetType.Status:
            //adjust the size of the background plane
            backgroundPlane.transform.localScale = new Vector3(0.5f, 0.25f, 0.25f);

            TextGO.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 5.0f);
            TextGO.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 2.5f);

            //Status Widget
            StatusWidget statusWidget = widgetGO.AddComponent <StatusWidget>();
            statusWidget.Text          = TextGO.GetComponent <TMPro.TextMeshPro>();
            statusWidget.PlaneRenderer = planeRenderer;
            statusWidget.Key           = widget.NetworkKey;
            statusWidget.Label         = widget.Label;
            break;
        }
    }