// Use this for initialization void Start() { k = GameObject.Find("shengchengdian").GetComponent <shengchengboss> ().getk(); //string d =Read.Instance.GetString (0, 2); string[] str = Read.Instance.GetHang(k); string str1 = str [1]; string str2 = str [2]; string str3 = str [3]; int m = int.Parse(str1); int n = int.Parse(str2); float t = float.Parse(str3); //for (int i = 0; i < str.Length; i++) { //Debug.LogError (str [i]); //} //int s = int.Parse (d); StartCoroutine(wait(t)); player = GameObject.FindGameObjectWithTag(Tags.tag.Player); past = new PastSingle(this.gameObject); past.f = this.transform.position.x - player.transform.position.x; }
public void atk() { PastSingle past = new PastSingle(); past.i = -Data.monsterAtkForce; RunFacade.getInstance.sendNotificationCommand(NotificationConstant.playerCommand.ChangeHp, past); }
public void ChangeHp(PastSingle past) { if (past.i < 0) { int temp = past.i + Data.Cover; if (temp < 0) { Data.Hp += temp; } } else { Data.Hp += past.i; } if (Data.Hp > 100) { Data.Hp = 100; } if (Data.Hp < 0) { SendNotification(NotificationConstant.playerMediator.ReStart); } //改变UI SendNotification(NotificationConstant.UIMediator.ChangeHpUI, Data); }
void OnTriggerEnter(Collider other) { if (other.tag.Equals(Tags.tag.coin)) { PastSingle past = new PastSingle(other.gameObject); RunFacade.getInstance.sendNotificationCommand(NotificationConstant.playerCommand.ChangeCoin, past); Destroy(other.gameObject); } }
public void ChangeCoin(PastSingle past) { Data.Coins = past.obj; Data.Coin += 1; //改变UI SendNotification(NotificationConstant.UIMediator.ChangeCoinCount, Data); //past.obj.GetComponent<Player>().DestroyGameObject(Data.Coins); Data.Coins = null; }
public void UpdateMap(PastSingle recive) { float x = 50 * Data.TerrainCount; int index = Random.Range(101, 111); Map map; Data.maps.TryGetValue(index, out map); switch (map.mapType) { case MapType.Normal: { UpdateTerrain = GameObject.Instantiate(Resources.Load(Tags.prb_path.Map_Normal_path + map.name) as GameObject); Map temp = UpdateTerrain.GetComponent <Map>(); //生成金币 for (int i = 0; i < temp.CoinTransforms.Length; i++) { string str = Data.JinbiStrings[Random.Range(0, 7)]; str = str.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", ""); GameObject game = GameObject.Instantiate(Resources.Load(Tags.prb_path.Jinbi_path + str) as GameObject); game.transform.SetParent(temp.CoinTransforms[i].transform); game.transform.localPosition = Vector3.zero; } for (int i = 0; i < temp.EnemyTransforms.Length; i++) { int xx = Random.Range(1, 4); MonsterItem monster; Data.enemys.TryGetValue(xx, out monster); GameObject q = GameObject.Instantiate(Resources.Load <GameObject>(Tags.prb_path.Enemy_path + monster.Name)); q.transform.parent = temp.EnemyTransforms[i].transform; q.transform.localPosition = Vector3.zero; } } break; case MapType.Double: { UpdateTerrain = Resources.Load(Tags.prb_path.Map_Double_path + map.name) as GameObject; } break; case MapType.Chains: { UpdateTerrain = Resources.Load(Tags.prb_path.Map_Chains_path + map.name) as GameObject; } break; } Data.TerrainCount += 1; Data.Terrains [0] = Data.Terrains [1]; Data.Terrains[1] = UpdateTerrain.GetComponent <Map>(); UpdateTerrain.transform.position = new Vector3(x, 0, 0); //更改的是预制体中的内容 UpdateTerrain.transform.rotation = Quaternion.identity; }
// Update is called once per frame void Update() { if (player.transform.position.x > this.gameObject.transform.position.x + 65) { Destroy(this.gameObject); PastSingle past = new PastSingle(Terrain); RunFacade.getInstance.sendNotificationCommand(NotificationConstant.TerrainCommand.UpdateMap, past); } }
void Start() { past = new PastSingle(this.gameObject); past.vect = new Vector3(-200, -200, 0); RunFacade.getInstance.sendNotificationCommand(NotificationConstant.MonsterMediator.MonsterMove, past); InvokeRepeating("DestorySelf", 0, 0.1f); }
public void JuageMonsterDis(PastSingle past) { if (Data.curMonster != null && Data.curMonster.transform.position.x < past.obj.transform.position.x) { Data.curMonster = null; Data.TriggerTimes = 0; PastBtnColor pastColor = new PastBtnColor(Color.white); SendNotification(NotificationConstant.UIMediator.ChangeButtonColor, pastColor); } }
public void inAtkArea(PastSingle past) { Data.TriggerTimes += 1; if (Data.TriggerTimes == 1) { Data.curMonster = past.obj; PastBtnColor pastColor = new PastBtnColor(Color.red); SendNotification(NotificationConstant.UIMediator.ChangeButtonColor, pastColor); } if (Data.TriggerTimes == 2) { PastBtnColor pastColor = new PastBtnColor(Color.yellow); SendNotification(NotificationConstant.UIMediator.ChangeButtonColor, pastColor); Data.TriggerTimes = 0; } }
void OnTriggerEnter(Collider other) { if ((other.gameObject.CompareTag(Tags.tag.Monster)) && other.transform.position.x > this.transform.position.x) { PastSingle past = new PastSingle(other.gameObject); RunFacade.getInstance.sendNotificationCommand(NotificationConstant.playerCommand.AtkMonsterArea, past); } //if (other.gameObject.tag.Equals(Tags.tag.coin)) //{//碰到金币 // //PastCoinCompent pastA = new PastCoinCompent(other.gameObject, true); // //RunFacade.getInstance.sendNotificationCommand(NotificationConstant.TerrainMediator.ChangeCoinCompent, pastA); // PastSingle past = new PastSingle(other.gameObject); // RunFacade.getInstance.sendNotificationCommand(NotificationConstant.playerCommand.ChangeCoin, past); // Destroy (other.gameObject); //} }
public void atkMonster(PastSingle past) { if (Data.curMonster != null) { if (Data.curMonster.name.Equals(Tags.monster_type.smallBoss)) { Data.curMonster.GetComponent <SmallBoss>().Rebound(Data.smallBossRe); } else { //past.obj.GetComponent<Player>().DestroyGameObject(Data.curMonster); Data.curMonster.GetComponent <MonsterItem>().die(); } Data.Monster += 1; Data.TriggerTimes = 0; Data.curMonster = null; SendNotification(NotificationConstant.UIMediator.ChangeMonsterCount, Data); PastBtnColor pastColor = new PastBtnColor(Color.white); SendNotification(NotificationConstant.UIMediator.ChangeButtonColor, pastColor); } }
public override void Execute(PureMVC.Interfaces.INotification notification) { TerrainProxy proxy = (TerrainProxy)Facade.RetrieveProxy("TerrainProxy"); //通过名字获取Proxy switch (notification.Name) { case NotificationConstant.TerrainCommand.SetMapBasic: { PastTerrains past = notification.Body as PastTerrains; proxy.SetMapBasic(past); } break; //case NotificationConstant.TerrainCommand.InitMap: //{ // proxy.InitMap(); //}break; case NotificationConstant.TerrainCommand.UpdateMap: { PastSingle past = notification.Body as PastSingle; proxy.UpdateMap(past); } break; } }
public override void HandleNotification(PureMVC.Interfaces.INotification notification) { switch (notification.Name) { //执行和显示有关的命令 case NotificationConstant.MonsterMediator.ChangeMonsterCompent: { PastMonsterCompent recive = notification.Body as PastMonsterCompent; GameObject MonsterItem = recive.monster; MonsterItem.GetComponent <Rigidbody>().isKinematic = recive.isKinematic; MonsterItem.GetComponent <CapsuleCollider>().isTrigger = recive.isTrigger; } break; case NotificationConstant.MonsterMediator.ChangeMonsterAnimation: { PastAnimator recive = notification.Body as PastAnimator; GameObject MonsterItem = recive.monster; switch (recive.type) { case Tags.animator_type.Trigger: MonsterItem.GetComponent <Animator>().SetTrigger(recive.name); break; case Tags.animator_type.Bool: MonsterItem.GetComponent <Animator>().SetBool(recive.name, recive.boolState); break; } } break; case NotificationConstant.MonsterMediator.MonsterMove: { PastSingle recive = notification.Body as PastSingle; switch (recive.obj.name) { case Tags.monster_type.fly: { Vector3 fly_position = recive.obj.transform.position; fly_position.y = 2f + (float)Mathf.Sin(fly_x) * 0.5f; recive.obj.transform.position = fly_position; fly_x = 0; } break; case Tags.monster_type.water: { water_x += Time.deltaTime; if (water_x >= 2) { Debug.Log("Jump"); recive.obj.GetComponent <Rigidbody>().velocity = new Vector3(0, 5, 0); water_x = 0; } } break; case Tags.monster_type.Boss: { Vector3 pos = new Vector3(Player.transform.position.x + recive.f, recive.obj.transform.position.y, recive.obj.transform.position.z); recive.obj.transform.position = pos; } break; case Tags.monster_type.smallBoss: { recive.obj.GetComponent <Rigidbody>().AddForce(recive.vect); } break; } } break; case NotificationConstant.MonsterMediator.ChangeBossColor: { PastSingle recive = notification.Body as PastSingle; Renderer rend = recive.obj.GetComponent <Renderer>(); rend.material.shader = Shader.Find("Specular"); rend.material.SetColor("_SpecColor", recive.c); } break; case NotificationConstant.MonsterMediator.SpawnSmallBoss: { PastSingle recive = notification.Body as PastSingle; } break; } }
public override void Execute(PureMVC.Interfaces.INotification notification) { proxy = (PlayerProxy)Facade.RetrieveProxy("PlayerProxy");//通过名字获取Proxy PastSingle recive = notification.Body as PastSingle; switch (notification.Name) { case NotificationConstant.playerCommand.PlayerMove: { proxy.Move(); } break; case NotificationConstant.playerCommand.JumpCommond: { proxy.Jump(); } break; case NotificationConstant.playerCommand.CollisionBaseCommond: { proxy.CollisionBase(); } break; case NotificationConstant.playerCommand.DiedCommond: { proxy.Died(); } break; case NotificationConstant.playerCommand.CollisionStay: { proxy.CollisionStay(); } break; case NotificationConstant.playerCommand.MouseLeftDown: { proxy.MouseDown(); } break; case NotificationConstant.playerCommand.MouseLeftUP: { proxy.MouseUp(); } break; case NotificationConstant.playerCommand.AtkMonsterArea: { proxy.inAtkArea(recive); } break; case NotificationConstant.playerCommand.JuageMonsterDistance: { proxy.JuageMonsterDis(recive); } break; case NotificationConstant.playerCommand.AtkMonster: { proxy.atkMonster(recive); } break; case NotificationConstant.playerCommand.ChangeHp: { proxy.ChangeHp(recive); } break; case NotificationConstant.playerCommand.ChangeCoin: { proxy.ChangeCoin(recive); } break; case NotificationConstant.playerCommand.ChainStateToFallState: { proxy.ChainStateToFallState(); } break; case NotificationConstant.playerCommand.ResetJumpData: { proxy.ResetJumpData(); } break; } }
void Start() { RunFacade.getInstance.InitGameObject(this.gameObject); past = new PastSingle(this.gameObject); }
void Start() { past = new PastSingle(this.gameObject); player = GameObject.FindGameObjectWithTag(Tags.tag.Player); }