void Awake() { if (_instance == null) { _instance = this; } }
/// <summary> /// 觸發事件 /// </summary> void TriggerEvent() { switch (Events[NextEvent]) { case MilestoneEvent.Monster: FightScene.MeetEnemy(MonsterGetter.GetMonsterDicsFromEvent(MyAdventure.MonsterEvent)); //遭遇敵人 break; case MilestoneEvent.Accident: CharaDataUI.ShowCharas(false); //隱藏腳色資料介面 AccidentUI.CallAccident(EventGetter.GetAccidentInGroup(MyAdventure.AccidentGroup)); //呼叫意外事件 FightScene.AccidentEvent(); //遭遇意外事件 break; case MilestoneEvent.Investigate: CharaDataUI.ShowCharas(false); //隱藏腳色資料介面 InvestigateUI.CallInvestigate(EventGetter.GetInvestigateInGroup(MyAdventure.InvestigateGroup)); //呼叫調查事件 FightScene.InvestigateEvent(); //遭遇調查事件 break; case MilestoneEvent.Camp: CharaDataUI.ShowCharas(false); //隱藏腳色資料介面 CampUI.CallCamp(EventGetter.GetCampInGroup(MyAdventure.CampGroup)); //呼叫紮營事件 FightScene.InvestigateEvent(); //遭遇調查事件 break; } NextEvent++; }
public Monster(FightScene fightScene) { Hitpoint.Val = 30; this.fightScene = fightScene; GameObject gObject = GameObject.FindGameObjectsWithTag("Placeholder").Single(o => o.name == "Monster"); this.renderer = gObject.AddComponent <MonsterRenderer> (); this.renderer.Register(this); Hitpoint.OnChange += (oldVal, newVal) => { if (newVal < oldVal) { this.renderer.Shake(); } if (newVal <= 0) { onDeath(); } }; this.States = new StatesBar(gObject); }
/// <summary> /// 檢查是否還存活 /// </summary> protected virtual void AliveCheck() { //腳色死亡 if (CurHP <= 0) { Debug.Log(string.Format("{0}死亡", Name)); IsAlive = false; PlayMotion(Motion.Die, 0); FightScene.CheckAliveChara();//更新死亡腳色清單 } }
// Start is called before the first frame update void Start() { bleedingImg.gameObject.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width - 150, Screen.height); countdownCoroutine = StartCoroutine(Countdown()); audioController = GetComponent <AudioController>(); audioController.BGMPlay(AudioEunm.fightBGM, 0.8f); instance = this; gameTime = 0; settlementPlane.gameObject.SetActive(false); InitPlayers(); InitLight(); }
/// <summary> /// 前進 /// </summary> public void GoForward() { NextPos = RTransfrom.anchoredPosition - Vol; if (NextPos.x <= (StartPos.x - EventMiles[NextEvent] * MileDist)) { Mile = EventMiles[NextEvent]; RTransfrom.anchoredPosition = StartPos - Mile * MileDist_Vec; FightScene.SetMile(Mile); TriggerEvent();//觸發事件 } else { RTransfrom.anchoredPosition -= Vol; SetMile(); FightScene.SetMile(Mile); } }
//事件協程 static IEnumerator EventCoroutine() { Go_Scenario.SetActive(true); yield return(new WaitForSeconds(1f)); Go_Feedback.SetActive(true); yield return(new WaitForSeconds(2f)); ShowResultUI(false); //隱藏結果UI CharaDataUI.ShowCharas(true); //顯示腳色資料介面 //如果有戰鬥就進入戰鬥沒有則繼續冒險 if (Data.CheckFight()) { FightScene.AmbushEvent(MonsterGetter.GetMonsterDicsFromEvent(Data.MonsterEvent));//埋伏事件 } else { FightScene.KeepAdventure();//繼續冒險 } }
public Player(FightScene fightScene) { this.fightScene = fightScene; this.gameStats = GameObject.FindGameObjectWithTag("GameStatsPersistor") .GetComponent <GameStatsPersistor> ().GameStats; // init for Fight Scene this.Hitpoint.Val = this.fightScene.GameStats.Hitpoint; this.MaxHitpoint = this.fightScene.GameStats.MaxHitpoint; this.Shield.Val = 0; this.Hitpoint.OnChange += (oldVal, newVal) => { if (newVal <= 0) { onDeath(); } }; this.playerObject = GameObject.FindGameObjectsWithTag("Placeholder").Single(o => o.name == "Player"); this.playerRenderer = playerObject.AddComponent <PlayerRenderer>(); this.playerRenderer.Register(this); this.States = new StatesBar(playerObject); }
void Start() { scene = GetComponent <FightScene>(); }
void Start() { instance = this; mainCamera = Camera.main; this.WriteMessage(Protocol.TYPE_FIGHT, 0, FightProtocol.ENTER_CREQ, null); }
/// <summary> /// 結束消滅敵方標題 /// </summary> public void EndShowClearTilte() { //繼續冒險 FightScene.KeepAdventure(); }
/// <summary> /// 結束腳色施法動作後呼叫 /// </summary> public void EndSpell() { SetDefaultTransfrom(); FightScene.SetAction(false);//設定結束動作 }
public void Awake() { this.FightScene = Camera.main.GetComponent<FightScene>(); this.handObject = this.gameObject; this.States = new StatesBar (handObject); this.drawPerTurn = this.FightScene.GameStats.GetSpeed(); }
/// <summary> /// 播放腳色施法 /// </summary> public void PlayMotion(Motion _motion, float _normalizedTime) { switch (_motion) { case Motion.Stay: if (Animator.StringToHash(string.Format("Base Layer.{0}", Motion.Stay.ToString())) != Ani_Chara.GetCurrentAnimatorStateInfo(0).fullPathHash) { Ani_Chara.SetTrigger(Motion.Stay.ToString()); } break; case Motion.GoForward: if (Animator.StringToHash(string.Format("Base Layer.{0}", Motion.GoForward.ToString())) != Ani_Chara.GetCurrentAnimatorStateInfo(0).fullPathHash) { Ani_Chara.Play(Motion.GoForward.ToString(), 0, _normalizedTime); } break; case Motion.Attack: Ani_Chara.SetBool("InFighting", FightScene.Fight); FightScene.SetAction(true); //設定有人在執行動作 if (Animator.StringToHash(string.Format("Base Layer.{0}", Motion.Attack.ToString())) != Ani_Chara.GetCurrentAnimatorStateInfo(0).fullPathHash) { Ani_Chara.Play(Motion.Attack.ToString(), 0, _normalizedTime); } else { //重播 Ani_Chara.StopPlayback(); } break; case Motion.Beaten: if (Animator.StringToHash(string.Format("Base Layer.{0}", Motion.Beaten.ToString())) != Ani_Chara.GetCurrentAnimatorStateInfo(0).fullPathHash) { Ani_Chara.Play(Motion.Beaten.ToString(), 0, _normalizedTime); } else { //重播 Ani_Chara.StopPlayback(); } break; case Motion.Support: FightScene.SetAction(true); //設定有人在執行動作 Ani_Chara.SetBool("InFighting", FightScene.Fight); if (Animator.StringToHash(string.Format("Base Layer.{0}", Motion.Support.ToString())) != Ani_Chara.GetCurrentAnimatorStateInfo(0).fullPathHash) { Ani_Chara.Play(Motion.Support.ToString(), 0, _normalizedTime); } else { //重播 Ani_Chara.StopPlayback(); } break; case Motion.Die: if (Animator.StringToHash(string.Format("Base Layer.{0}", Motion.Die.ToString())) != Ani_Chara.GetCurrentAnimatorStateInfo(0).fullPathHash) { Ani_Chara.Play(Motion.Die.ToString(), 0, _normalizedTime); } break; } }
// Use this for initialization void Start() { FightScene.Create(gameObject); }
public NPC(GameObject root, Value v) { this.config = v; var npcType = this.config.TryGet <string>("NPC类型"); Debug.Log(npcType); var prefab = "Prefabs/room/NPC"; if (npcType == "传送门") { prefab = "Prefabs/room/传送门"; } this.go = Game.CreatePrefab(root, new GameObjectItem { name = v.name, x = this.config.TryGet <int>("x"), y = this.config.TryGet <int>("y"), prefab = prefab, }); this.go.GetComponentInChildren <Text>().text = v.name; if (npcType == "传送门") { //增加传送事件 this.go.GetComponent <Button>().onClick.AddListener(() => { var buttonSelf = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject; //根据传送门按钮name,查找要传送的地图 var buttonConfig = User.GetConfigByName(buttonSelf.name); var targetRoomPosition = buttonConfig.TryGet <string>("目标传送门"); var targetConfig = User.GetConfigByName(targetRoomPosition); var targetRoom = targetConfig.TryGet <string>("房间"); Debug.Log(string.Format("传送至{0} : {1}", targetRoom, targetRoomPosition)); var g = GameObject.Find("UI").transform.Find("挂机按钮"); Debug.Log(g); if (g != null) { if (targetRoom == "郊外") { g.gameObject.SetActive(true); } else { g.gameObject.SetActive(false); } } MapManager.curMapManager.BuildRoom(targetRoom); }); } if (npcType == "NPC") { this.go.GetComponentInChildren <Button>().onClick.AddListener(() => { Game.ShowMessage(this.config.TryGet <string>("提示"), messageType: 1); }); } if (npcType == "Fight") { this.go.GetComponentInChildren <Button>().onClick.AddListener(() => { FightScene.Create(root); }); } if (npcType == "DrawCard") { this.go.GetComponentInChildren <Button>().onClick.AddListener(() => { //创建预制体抽卡 var bagGO = GameObject.Find("抽卡"); if (bagGO == null) { var top = GameObject.Find("Top"); var drawCard = Game.CreatePrefab(top, new GameObjectItem() { type = 1, name = "抽卡", prefab = "Prefabs/Room/DrawCard", }); var oneButton = Game.Find <Button>("DrawOne"); oneButton.onClick.AddListener(() => { var res = User.HttpSend <Prop[]>("/game/drawCard", new { }); RewardHelper.ShowRewards(res); Debug.Log(res); }); var tenButton = Game.Find <Button>("DrawTen"); tenButton.onClick.AddListener(() => { var res = User.HttpSend <Prop[]>("/game/drawCardTen", new { }); RewardHelper.ShowRewards(res); Debug.Log(res); }); var drawCardBack = Game.Find <Button>("DrawCardBack"); drawCardBack.onClick.AddListener(() => { GameObject.Destroy(drawCard); }); } }); } }
private void Awake() { instance = this; }
/// <summary> /// 戰鬥 /// </summary> public void GoFIght() { Ani.SetTrigger("Stay"); FightScene.StartFight(); }
public FightReport(FightScene fightScene) { this.rewardsWindowPrefab = Resources.Load <GameObject>("Prefabs/RewardsWindow"); this.rewardsWindowPosition = new Vector3(621, 390); this.fightScene = fightScene; }
public void Start() { this.fightScene = Camera.main.GetComponent <FightScene>(); }
/// <summary> /// 取消按鈕被按下 /// </summary> public void Click_Cancel() { CharaDataUI.ShowCharas(true); //顯示腳色資料介面 ShowInvestigateUI(false); //隱藏調查介面 FightScene.KeepAdventure(); //繼續冒險 }
/// <summary> /// 確認按鈕被按下 /// </summary> public void Click_Confirm() { CharaDataUI.ShowCharas(true); //顯示腳色資料介面 ShowCampUI(false); //隱藏紮營介面 FightScene.KeepAdventure(); //繼續冒險 }