zoukankan      html  css  js  c++  java
  • Unity3d

    前期工程搭建了背包的基本功能,现在开始创建角色的状态界面。

    功能需求:

    ①当用户点击状态按钮时,在界面显示角色状态栏;

    ②状态栏中包含信息有角色的属性(伤害、防御、速度),剩余点数及状态总结;

    ③当角色存在剩余点数时,在属性面板处显示加点按钮;

    ④再次点击状态按钮,角色界面隐藏掉。

    思路:

    综上,我们需要建立5个UILabel来显示角色状态数值,且需要将角色状态脚本中的变量值赋值给Label中的text组件,实现信息的显示。

    脚本如下:

    Class PlayerStatus

    {

        public int attack = 20;

        public int attack_plus = 0;

        public int def = 20;

        public int def_plus = 0;

        public int speed = 20;

        public int speed_plus = 0;

    }

    Class Status

    {

        public static Status _instance;

        private PlayerStatus palyerstatus;

        private TweenPosition tween;

        prviate bool isShow = false;

        public UILabel attackLabel;

        public UILabel defLabel;

        public UILabel speedLabel;

        public UILabel point_Remain;

        public UILabel sum;

        public GameObject a_plus;

        public GameObject d_plus;

        public GameObject s_plus;

        void Start( )

        {

            _instance = this;

            tween = GetCompnent<TweenPosition>( );

            playerstatus = gameObject.FindGameObjectWithTag(Tag.player).GetCompnent<PlayerStatus>( );

        }

        public void TranslateState( )

        {

            if(isShow == false)

            {

                 ShowDetails( );

                 tween.PlayForward( );

                 isShow =  true;

            }

            else

            {

                 tween.PlayReserved( );

                 isShow = false;

            }

        } 

        void ShowDetails( )

        {

            attackLabel.text = "伤害:" + playerstatus.attack + "+" + playerstatus.attack_plus;

            defLabel.text = "防御:" + playerstatus.def + "+" + playerstatus.def_plus;

            speedLabel.text = "速度:" + playerstatus.speed + "+" + playerstatus.speed_plus;

            point_Remain.text =  playerstatus.pont_Remain.ToString( );

            if(playerstatus.point_Remain > 0)

            {

                a_plus.SetActive(true);

                d_plus.SetActive(true);

                s_plus.SetActive(true);

            }

            else

            {

                a_plus.SetActive(false);

                d_plus.SetActive(false);

                s_plus.SetActive(false);

            }

        }

    }

  • 相关阅读:
    HDU 4069 Squiggly Sudoku
    SPOJ 1771 Yet Another NQueen Problem
    POJ 3469 Dual Core CPU
    CF 118E Bertown roads
    URAL 1664 Pipeline Transportation
    POJ 3076 Sudoku
    UVA 10330 Power Transmission
    HDU 1426 Sudoku Killer
    POJ 3074 Sudoku
    HDU 3315 My Brute
  • 原文地址:https://www.cnblogs.com/yanbenxin/p/5849234.html
Copyright © 2011-2022 走看看