示例#1
0
    public void PrintGoldTips(Vector3 pos, int value)
    {
        GameObject tips = Instantiate(GameRoot.GetInstance().BattleField.assetManager.GoldTips);

        tips.GetComponent <RectTransform>().parent = GameRoot.GetInstance().battleTextUI.GetComponent <RectTransform>();
        tips.SetActive(true);
        tips.GetComponent <Text>().text = "+" + value.ToString();
        Canvas        canvas    = GameRoot.GetInstance().battleTextUI.GetComponent <Canvas>();
        CamaraManager camara    = GameRoot.GetInstance().CameraMng;
        Vector2       screenPos = Camera.main.WorldToScreenPoint(pos);

        tips.transform.position = new Vector3(screenPos.x, screenPos.y, 0);

        MessageEffect effect = new MessageEffect
        {
            effect   = tips,
            uid      = -1,
            duration = 0.6f,
            pos      = pos
        };

        messageCantainer.Add(effect);
        //float scale = camara.minSize / camara.size;
        tips.transform.localScale = Vector3.one;
    }
示例#2
0
 public override void OnEnter()
 {
     //GameRoot.BattleStartAction += BattleEnter;
     //GameRoot.BattleStartDelayAction += BattleStart;
     cameraMng = GameRoot.GetInstance().CameraMng;
     uiMng     = GameRoot.GetInstance().battleUI.GetComponent <BattleUIManager>();
 }
示例#3
0
 public override void OnEnter()
 {
     Debug.Log("Enter MoveCameraState");
     camareMng = GameRoot.GetInstance().CameraMng;
     state     = MoveCameraStateFSM.Idle;
     lastSingleTouchPosition = useMouse ? (Vector2)Input.mousePosition : Input.GetTouch(0).position;
 }
示例#4
0
    // Start is called before the first frame update
    void Start()
    {
        states = GetComponent <StateManager>();
        states.Init();

        camManager = CamaraManager.singleton;
        camManager.Init(states);
    }
示例#5
0
        // Use this for initialization
        private void Start()
        {
            var         obj         = new GameObject("hoge");
            ViewManager viewManager = obj.AddComponent <ViewManager>();

            obj = new GameObject("Camera");
            CamaraManager cameraManager = obj.AddComponent <CamaraManager>();
        }
示例#6
0
 public void StartBattle()
 {
     state     = MoveCameraStateFSM.Idle;
     camareMng = gameObject.GetComponent <CamaraManager>();
     //lastSingleTouchPosition = useMouse ? (Vector2)Input.mousePosition : Input.GetTouch(0).position;
     m_Camera       = cameraObj.GetComponent <Camera>();
     m_CameraOffset = new Vector3(16.65f, 29.88f, 20f);
     m_Camera.transform.rotation = Quaternion.Euler(66.5f, 90f, 0f);
     xMin         = 1;
     xMax         = 23;
     zMin         = 12.5f;
     zMax         = 27.8f;
     viewField    = 60f;
     maxSize      = 80f;
     minSize      = 40f;
     scaleFactor  = 0.5f;
     scrollFactor = 0.45f;
     active       = true;
 }
示例#7
0
    private void Update()
    {
        if (inBattle)
        {
            for (int index = messageCantainer.Count - 1; index >= 0; --index)
            {
                MessageEffect effect   = messageCantainer[index];
                MapField      mapField = GameRoot.GetInstance().MapField;
                //Debug.Log("duration " + effect.duration);
                if (effect.duration <= 0)
                {
                    messageCantainer.RemoveAt(index);
                    Destroy(effect.effect);
                    continue;
                }


                Canvas        canvas    = GameRoot.GetInstance().battleTextUI.GetComponent <Canvas>();
                CamaraManager camara    = GameRoot.GetInstance().CameraMng;
                Vector2       screenPos = Camera.main.WorldToScreenPoint(effect.pos);

                float scale = camara.GetViewSize();
                float hight = Screen.height / 10 * scale;

                effect.effect.transform.position = new Vector3(screenPos.x, screenPos.y + Mathf.Clamp((1.1f - effect.duration) * 0.2f, 0, 0.2f) * hight, 0);
                if (effect.canvas == BattleUICanvas.BattleText)
                {
                    Text text = effect.effect.GetComponentInChildren <Text>();
                    if (text != null)
                    {
                        text.gameObject.transform.localScale = Vector3.one * scale * 1.3f;
                    }
                }


                messageCantainer[index].duration = effect.duration - Time.deltaTime;
            }
        }
    }
示例#8
0
        public void UpdateHpBar()
        {
            if (hpBar != null && hpBar.activeSelf == true)
            {
                hpBarCacheTime += Time.deltaTime;
                if (hpBarCacheTime > 5)
                {
                    hpBar.SetActive(false);
                    hpBarCacheTime = 0;
                    return;
                }
                Canvas        canvas    = GameRoot.GetInstance().battleUI.GetComponent <Canvas>();
                CamaraManager camara    = GameRoot.GetInstance().CameraMng;
                Vector2       screenPos = Camera.main.WorldToScreenPoint(GetSocketPos("S_Hp"));
                //Vector2 uiPos = Vector2.zero;
                //RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, screenPos, canvas.worldCamera, out uiPos);
                //uiPos.x = screenPos.x - (Screen.width / 2);
                //uiPos.y = screenPos.y - (Screen.height / 2);
                //hpBar.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
                hpBar.transform.position = new Vector3(screenPos.x, screenPos.y, 0);

                hpBar.transform.localScale = new Vector3(0.9f + ((float)radius - 4) / 16f, 1f, 1) * 0.8f * camara.GetViewSize();
            }
        }
示例#9
0
    //flag:1,crit,2,miss,3,heal,4,warning
    public void PrintMessage(int uid, string text, int flag)
    {
        MapField mapField = GameRoot.GetInstance().MapField;
        Entity   entity;

        entity = mapField.FindEntity(uid);
        if (entity == null)
        {
            Debug.Log("entity is null");
            return;
        }
        Canvas        canvas    = GameRoot.GetInstance().battleTextUI.GetComponent <Canvas>();
        CamaraManager camara    = GameRoot.GetInstance().CameraMng;
        Vector2       screenPos = Camera.main.WorldToScreenPoint(entity.GetSocketPos("S_Center"));
        //Vector2 uiPos = Vector2.zero;

        //uiPos.x = screenPos.x - (Screen.width / 2);
        //uiPos.y = screenPos.y - (Screen.height / 2);
        //hpBar.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
        GameObject message = Instantiate(GameRoot.GetInstance().BattleField.assetManager.Message);

        message.GetComponent <RectTransform>().parent = GameRoot.GetInstance().battleTextUI.GetComponent <RectTransform>();
        //hpBar.GetComponent<RectTransform>().sizeDelta = new Vector2(Mathf.Sqrt(radius) / 2 * 80, 22);
        message.SetActive(true);

        if (entity.side == 2)
        {
            switch (flag)
            {
            case 0:
                message.GetComponentInChildren <Text>().text  = text;
                message.GetComponentInChildren <Text>().color = new Color(0.95f, 0.10f, 0.18f);
                message.transform.localScale = Vector3.one;
                break;

            case 1:
                message.GetComponentInChildren <Text>().text  = text;
                message.GetComponentInChildren <Text>().color = new Color(0.9f, 0.1f, 0.7f);
                message.GetComponent <TipMessage>().SetLogo(int.Parse(text));
                message.transform.DOScale(Vector3.one * 3.5f, 0.1f).onComplete += () => {
                    message.transform.DOScale(Vector3.one * 2f, 0.15f).onComplete += () => {
                        message.transform.DOScale(Vector3.one * 1.5f, 0.45f);
                    };
                };
                break;

            case 4:
                message.GetComponentInChildren <Text>().text  = StrUtil.GetText(text);
                message.GetComponentInChildren <Text>().color = new Color(0.87f, 0.82f, 0.34f);
                message.transform.localScale = new Vector3(1.2f, 1, 1);
                break;
            }
        }
        else
        {
            switch (flag)
            {
            case 0:
            case 1:
                message.GetComponentInChildren <Text>().text  = text;
                message.GetComponentInChildren <Text>().color = new Color(0.7f, 0.6f, 1f);
                message.transform.localScale = Vector3.one * 0.7f;
                break;

            case 4:
                message.GetComponentInChildren <Text>().text  = StrUtil.GetText(text);
                message.GetComponentInChildren <Text>().color = new Color(0.87f, 0.82f, 0.34f);
                message.transform.localScale = new Vector3(0.96f, 0.8f, 0.8f);
                break;
            }
        }
        message.transform.position = new Vector3(screenPos.x, screenPos.y, 0);
        Color t_color = message.GetComponentInChildren <Text>().color;

        message.GetComponentInChildren <Text>().DOColor(new Color(t_color.r, t_color.g, t_color.b, 1), 0.5f).onComplete += () =>
        {
            message.GetComponentInChildren <Text>().DOColor(new Color(t_color.r, t_color.g, t_color.b, 0), 0.5f);
        };
        Image logo    = message.GetComponent <TipMessage>().CritLogo.GetComponentInChildren <Image>();
        Color l_color = logo.color;

        if (logo != null && logo.gameObject.activeSelf == true)
        {
            logo.DOColor(new Color(l_color.r, l_color.g, l_color.b, 1), 0.3f).onComplete += () =>
            {
                logo.DOColor(new Color(l_color.r, l_color.g, l_color.b, 0), 0.4f);
            }
        }
        ;

        //init message struct
        MessageEffect effect = new MessageEffect
        {
            effect   = message,
            uid      = uid,
            duration = 1.1f,
            pos      = entity.GetSocketPos("S_Center"),
            canvas   = BattleUICanvas.BattleText,
        };

        messageCantainer.Add(effect);

        //float scale = camara.minSize / camara.size;
        //message.transform.localScale = Vector3.one;
        //message.transform.DOMoveY(message.transform.position.y + 20, 0.2f);
        //Destroy(message, 0.2f);
    }
 private void Awake()
 {
     Instance        = this;
     initialPosition = transform.position;
 }