Exemplo n.º 1
0
 //设置名字,并保存
 public void setNewPlayer(string name)
 {
     if (name.Length != 0 && TextCheck.isUserName(name) && name.Length <= 8)
     {
         data.nowId = data.allIdCount++ + 1;
         PlayerPrefs.SetInt("nowId", data.nowId);
         PlayerPrefs.SetInt("AllIDCount", data.allIdCount);
         myNpc.npcName = name;
         LoadAndSave.saveNpc(myNpc, data.nowId);
         this.uiCamera.gameObject.SetActive(false);
     }
     else if (name.Length == 0)
     {
         GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").transform.Find("Placeholder").GetComponent <Text>().text = "名字不能为空";
         GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").GetComponent <InputField>().text = "";
     }
     else if (name.Length <= 8)
     {
         GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").transform.Find("Placeholder").GetComponent <Text>().text = "名字里不能带字符";
         GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").GetComponent <InputField>().text = "";
     }
     else
     {
         GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").transform.Find("Placeholder").GetComponent <Text>().text = "名字不能超过8位";
         GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").GetComponent <InputField>().text = "";
     }
 }
Exemplo n.º 2
0
    //更新函数
    void FixedUpdate()
    {
        if (Input.anyKey && !isStart)
        {
            isStart = true;
            data.init();
            gameStart();
        }
        if (this.mode != MainGame.MODE_FIGHT)
        {
            this.autoSaveTime += Time.fixedDeltaTime;
            if (this.autoSaveTime >= this.autoSaveMaxTime)
            {
                this.autoSaveTime = 0;
                LoadAndSave.saveNpc(myNpc, myNpc.id);
            }
        }

        /*******************
        *更新战斗相关
        *
        *
        *******************/
        if (this.mode == MainGame.MODE_FIGHT)
        {
            myNpc.speedTime += Time.fixedDeltaTime;
            if (myNpc.speedTime >= (this.myNpc.norFightSpeed * (1f + this.myNpc.fightSpeedAmp)))
            {
                myNpc.speedTime  = (this.myNpc.norFightSpeed * (1f + this.myNpc.fightSpeedAmp));
                myNpc.isCanFight = true;
            }
            else
            {
                myNpc.isCanFight = false;
            }
            enemyNpc.speedTime += Time.fixedDeltaTime;
            if (enemyNpc.speedTime >= (this.enemyNpc.norFightSpeed * (1f + this.enemyNpc.fightSpeedAmp)))
            {
                enemyNpc.speedTime  = (this.enemyNpc.norFightSpeed * (1f + this.enemyNpc.fightSpeedAmp));
                enemyNpc.isCanFight = true;
            }
            else
            {
                enemyNpc.isCanFight = false;
            }
            fightNpcAI(enemyNpc, myNpc);
            switch (updateNpcStatus())
            {
            case 0:
                break;

            case 1:    //myNpc失败
                textEvent.setNotice("很遗憾你输掉了战斗\n作为惩罚将扣除你当前经验的50%", 1.5f, true);
                endFight(enemyNpc, myNpc);
                break;

            case 2:    //enemyNpc失败
                textEvent.setNotice("恭喜你赢得了战斗", 1.5f, true);
                endFight(myNpc, enemyNpc);
                break;
            }
        }

        /*******************
        *文本相关
        *
        *
        *******************/
        if (isShowStatusPanel)
        {
            uploadStatus(this.myNpc);
        }

        /*******************
        *更新按键
        *
        *
        *******************/
        if (xuanXiangTime < 1000f)
        {
            xuanXiangTime += Time.fixedDeltaTime;
        }
        if (this.mode != MainGame.MODE_MOVE)
        {
            buttonList.get(choseXuanXiang).GetComponent <Button>().Select();
        }
    }