2 qq 31509937 qq_31509937 于 2017.09.09 00:47 提问

做了一个U3d的回合制游戏,但是为何只有一回合的战斗?

代码如下:

玩家的

public class PlayerFight : MonoBehaviour
{

public static PlayerFight _instance;                                //单例 
public PlayerAnimState State = PlayerAnimState.Atk;               //玩家默认状态

private Vector3 targetPos;                                          //目标位置坐标
private Transform target;                                           //目标

// public Text huiheshuText; //获取回合数
private float PlayerSpeed = 2.0f;
public GameObject XuanXiang; //选择页面
private bool isDie = false; //是否死亡

public bool isBoutOver = false;                                    //回合是否结束

private bool isShowControlPanel=false;                              //是否显示选择页面
private bool isAtk=false;                                           //是否攻击过

private Vector3 StartPos;                                           //玩家初始位置
private Vector3 StartRot;                                           //玩家初始角度
private Transform PlayerPos;
public Scrollbar actionBarPre;                                       //行动条的预制体
public GameObject actionBar;
public GameObject SkillEffect1;                                     //技能1特效
public GameObject SkillEffect2;                                     //技能2特效
public GameObject SkillEffect3;                                     //技能3特效
public GameObject SkillEffect4;                                     //技能4特效

// private EnemysFigth EnemySpeed;
public float speed = 3f; //玩家速度
public float HP = 200; //玩家血量
public int atk = 20; //玩家普通攻击攻击力

//public float BarSpeed = 1;                      //进度条速度


private CharacterController controller;         //游戏控制器
private Animation anima;                //动画系统
public string animName_Idle;            //站立
public string animName_Run;             //奔跑
public string animName_Bruise;          //受伤
public string animName_Atk;             //普通攻击
public string animName_Skill1;          //技能1攻击
public string animName_Skill2;          //技能2攻击
public string animName_Skill3;          //技能3攻击
public string animName_Skill4;          //技能4攻击
public string animName_Die;             //死亡
public float atkTimer;                  //攻击动画显示时间

public void Awake()
{
    _instance = this;
}


// Use this for initialization
void Start ()
{

   // EnemySpeed = GameObject.FindGameObjectWithTag("Enemy").GetComponent<EnemysFigth>();
    target = GameObject.FindGameObjectWithTag("Player").transform;     //获取玩家坐标

    XuanXiang.SetActive(false);       //控制也面开始为显示状态
    StartPos = transform.position;    //储存玩家开始的位置,为以后做准备
    StartRot = transform.localEulerAngles;//储存玩家开始角度
    targetPos = StartPos;
    controller = transform.GetComponent<CharacterController>();  //获取玩家控制组件
    anima = transform.GetChild(0).GetComponent<Animation>();   //获取玩家动画组件
}

// Update is called once per frame
void Update () 

{

    if(isDie)
    {

    }
    else
    {
        if (isShowControlPanel==false)
        {
            FightManager._instance.state = FightState.Player;//整个游戏的战斗状态为玩家控制
            if (isShowControlPanel == false)//如果战斗菜单没有显示
            {
                isShowControlPanel = true;//显示战斗菜单
                XuanXiang.SetActive(true);
            }
        }
        if (FightManager._instance.state != FightState.Player)//当整个游戏战斗状态不是玩家控制,则要隐藏战斗菜单
        {
            XuanXiang.SetActive(false);
        }

        else 
        {
            //if (State)
            //{

            //}
            //State = PlayerAnimState.Idle;
            State = PlayerAnimState.Atk;
            FightManager._instance.state = FightState.Player;
            if (isShowControlPanel==false)
            {
                isShowControlPanel = true;
                XuanXiang.SetActive(true);
            }
        }
       if (FightManager._instance.state != FightState.Player)
        {
            XuanXiang.SetActive(false);
        }

        switch (State)
        {
            case PlayerAnimState.Idle:
                PlayerAtk1();
                break;
            case PlayerAnimState.Atk:
            {
                PlayerAtk();
                break;
            }


            case PlayerAnimState.Skill1:
                PlayerSkill1();
                break;
            case PlayerAnimState.Skill2:
                PlayerSkill2();
                break;
            case PlayerAnimState.Skill3:
                PlayerSkill3();
                break;
            case PlayerAnimState.Skill4:
                PlayerSkill4();
                break;
            case PlayerAnimState.Die:
                break;
            default:
                break;
        }

    }
}
public void OnAttack()
{
    State = PlayerAnimState.Atk;
    isAtk = false;
}
//对外接口——技能攻击
public void OnSkill()
{
    switch (State)
    {
        case PlayerAnimState.Skill1:
            PlayerSkill1();
            break;
        case PlayerAnimState.Skill2:
            PlayerSkill2();
            break;
        case PlayerAnimState.Skill3:
            PlayerSkill3();
            break;
        case PlayerAnimState.Skill4:
            PlayerSkill4();
            break;
        case PlayerAnimState.Die:
            break;
        default:
            break;
    }
    isAtk = false;
}

1个回答

devmiao
devmiao   Ds   Rxr 2017.09.11 00:12
Csdn user default icon
上传中...
上传图片
插入图片