//发送公告,显示在屏幕中间偏下方 protected void setNotice(string str, float time, bool isChangeColor) { if (selectNotice()) { notice.setNotice(str, time, isChangeColor); } }
/************************ *不对外开放的函数 * * ************************/ /******************* *基础相关 * * *******************/ //初始化函数,系统自动调用 void Start() { buttonList = new LinkedList <GameObject>(); //初始化移动相关 ani = npc.transform.GetComponent <Animator>(); move = npc.transform.GetComponent <Move>(); //文本相关 textEvent = GameObject.Find("Game").transform.Find("GameGraphics").transform.Find("NoticeCanvas").transform.Find("Notice").transform.GetComponent <TextEvent>(); this.textOfStatusPanel = this.statusPanel.GetComponentInChildren <Text>(); //摄像头相关 gameCanvas = this.transform.Find("GameGraphics").transform.Find("UICanvas").GetComponent <Canvas>(); gameCamera = this.transform.Find("GameCamera").GetComponent <Camera>(); fightCamera = this.transform.Find("GameFight").transform.Find("FightCamera").GetComponent <Camera>(); uiCamera = this.transform.Find("UICamera").GetComponent <Camera>(); //战斗相关 this.myNpc = npc.GetComponent <GameNpc>(); this.myHp = status.transform.Find("MyHp").gameObject; this.myMp = status.transform.Find("MyMp").gameObject; this.mySpeed = status.transform.Find("MySpeed").gameObject; this.enemyHp = status.transform.Find("EnemyHp").gameObject; this.enemyMp = status.transform.Find("EnemyMp").gameObject; this.enemySpeed = status.transform.Find("EnemySpeed").gameObject; //数据相关 this.data = new GameData(this, myNpc); //开始界面 this.textDoc.gameObject.SetActive(false); this.statusPanel.gameObject.SetActive(false); this.backpackPanel.gameObject.SetActive(false); uiCamera.gameObject.SetActive(false); gameCanvas.gameObject.SetActive(false); gameCamera.gameObject.SetActive(false); fightCamera.gameObject.SetActive(false); textEvent.setNotice("任意键继续", 100f, true); PlayerPrefs.SetInt("nowId", 0); PlayerPrefs.SetInt("AllIdCount", 0); }
void OnTriggerEnter2D(Collider2D other) { other.transform.position = Vector3.zero; text.setNotice("上帝将你传回了原点", 2.5f, true); }
//更新函数 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(); } }