Example #1
0
    static Text Player_text;             //玩家

    public static void B_Blood_Text(RoleBase B_roleBase, int value)
    {
        if (B_roleBase.Equals(Player.Instance))                                                               //玩家
        {
            Blood_GameObject  = GameObject.Find("Blood_GameObject");                                          //找到空物体
            Player_Blood_Text = Instantiate(Resources.Load <GameObject>("Bloodreduction/Player_Blood_Text")); //实例化动态加载
            Player_text       = Player_Blood_Text.GetComponent <Text>();                                      //获取玩家的text
            string str = value.ToString();                                                                    //强转成string类型
            Player_text.text = "-" + str;                                                                     //赋值参数
            Player_Blood_Text.transform.parent        = Blood_GameObject.transform;                           //设置父级
            Player_Blood_Text.transform.localPosition = new Vector3(185, -676, 0);                            //设置位置
            Player_animator = Player_Blood_Text.GetComponent <Animator>();                                    //获取玩家的动画

            Player_animator.SetFloat("B_text", 5f);                                                           //执行动画
            Destroy(Player_Blood_Text, 3);                                                                    //3秒后销毁
        }

        if (B_roleBase.Equals(Enemy.Instance))                                                               //敌人
        {
            Blood_GameObject = GameObject.Find("Blood_GameObject");                                          //找到空物体
            Blood_Text       = Instantiate(Resources.Load <GameObject>("Bloodreduction/Player_Blood_Text")); //实例化动态加载
            B_text           = Blood_Text.GetComponent <Text>();                                             //获取敌人的text
            string str = value.ToString();                                                                   //强转成string类型
            B_text.text = "-" + str;                                                                         //赋值参数
            Blood_Text.transform.parent        = Blood_GameObject.transform;                                 //设置父级
            Blood_Text.transform.localPosition = new Vector3(200, 519, 0);                                   //设置位置
            B_animator = Blood_Text.GetComponent <Animator>();                                               //获取敌人的动画
            B_animator.SetFloat("B_text", 5f);                                                               //执行动画
            Destroy(Blood_Text, 3);                                                                          //3秒后销毁
        }
    }
Example #2
0
 public void FaliUIChange(RoleBase role, int addFali)
 {
     if (role.Equals(Enemy.Instance))
     {
         Text faliText = Instantiate(faliTextPrefab, Vector3.zero, Quaternion.identity, battlePanelTrsf);
         faliText.rectTransform.anchoredPosition = new Vector2(50, 84);
         faliText.text = "+" + addFali.ToString();
     }
     if (role.Equals(Player.Instance))
     {
         Debug.Log("玩家掉血");
         Text bloodText = Instantiate(faliTextPrefab, Vector3.zero, Quaternion.identity, battlePanelTrsf);
         bloodText.rectTransform.anchoredPosition = new Vector2(250, -620);
         bloodText.text = "+" + addFali.ToString();
     }
 }
Example #3
0
 public void BloodUIChange(RoleBase role, int damage)
 {
     if (damage == 0)
     {
         return;
     }
     if (role.Equals(Enemy.Instance))
     {
         Text bloodText = Instantiate(bloodTextPrefab, Vector3.zero, Quaternion.identity, battlePanelTrsf);
         bloodText.rectTransform.anchoredPosition = new Vector2(50, 84);
         bloodText.text = "-" + damage.ToString();
         imgEnemyTrsf.DOShakePosition(2f, new Vector3(10, 10, 0));
     }
     if (role.Equals(Player.Instance))
     {
         Debug.Log("玩家掉血");
         Text bloodText = Instantiate(bloodTextPrefab, Vector3.zero, Quaternion.identity, battlePanelTrsf);
         bloodText.rectTransform.anchoredPosition = new Vector2(250, -620);
         bloodText.text = "-" + damage.ToString();
     }
 }
    /// <summary>
    /// 接牌,添加至手牌list,返回手牌List
    /// </summary>
    /// <param name="cardCount">接牌数</param>
    /// <param name="role">对象</param>
    public List <string> ChouPai(int cardCount, RoleBase role)
    {
        //随机索引存储在列表
        List <int> randomIndex = new List <int>();

        for (int i = 0; i < cardCount; i++)
        {
            while (true)
            {
                int index = UnityEngine.Random.Range(0, role.OwnedCard.Count);
                if (randomIndex.Contains(index) == false)
                {
                    randomIndex.Add(index);
                    //Debug.Log(index);
                    break;
                }
            }
        }
        //获得对应索引卡的Id
        List <string> cardId = new List <string>();

        for (int i = 0; i < randomIndex.Count; i++)
        {
            int index = randomIndex[i];
            cardId.Add(role.OwnedCard[index]);
        }
        //添加至手牌List中
        for (int i = 0; i < cardId.Count; i++)
        {
            role.HandCard.Add(cardId[i]);
        }
        //移除卡包中的该牌
        for (int i = 0; i < cardId.Count; i++)
        {
            int index = role.OwnedCard.IndexOf(cardId[i]);
            role.OwnedCard.RemoveAt(index);
        }
        //如果对象是玩家,则顺便实例化手牌
        if (role.Equals(Player.Instance))
        {
            BattleRoundCtrl._instance.GenerateCard(cardId);
        }

        return(cardId);
    }