void Awake() { Bind(FightEvent.FIGHT_DO_ATTACK, FightEvent.FIGHT_SET_FIREINTERVAL, FightEvent.FIGHT_RESET_FIREINTERVAL, FightEvent.FIGHT_SYNC_ARMSTYPS); FirePoint = this.transform.Find("FirePoint"); curBullet = new BulletBase(); damageMesg = new DamageMesg(); effectMesg = new EffectMesg(); shootDto = new ShootDto(); }
private void FullPower() { Dispatch(AreaCode.TRANSFORM, TransformEvent.TRANS_SET_SPEED, 9); Dispatch(AreaCode.FIGHT, FightEvent.FIGHT_SET_FIREINTERVAL, 0.3f); EffectMesg effectMesg = new EffectMesg(GameObject.FindGameObjectWithTag("Player"), EffectType.Skill_Fullpower); Dispatch(AreaCode.EFFECT, EffectsEvents.SHOW_EFFECTS, effectMesg); StartCoroutine(ResetFullPower()); Dispatch(AreaCode.GAME, GameEvent.GAME_REDUCE_HG, 50); }
/// <summary> /// 销毁玩家角色 /// </summary> private void DestroyPlayer(string acc) { GameObject obj = userGameObjDict[acc]; userGameObjDict.Remove(acc); EffectMesg effectMesg = new EffectMesg(obj, EffectType.DeathEffect); Dispatch(AreaCode.EFFECT, EffectsEvents.SHOW_EFFECTS, effectMesg); Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_DEATH_AUDIO, obj.transform.position); Destroy(obj); }
private void SyncSkill(SkillMesg skillMesg) { if (skillMesg == null) { return; } switch (skillMesg.Type) { case SkillType.FullPower: AnimationMesg mesg = new AnimationMesg(skillMesg.Account, "Speed", false, 1); Dispatch(AreaCode.ANIMATION, AnimationEvent.ANIMATION_SET_FLOAT, mesg); EffectMesg effectMesg = new EffectMesg(skillMesg.gameObject, EffectType.Skill_Fullpower); Dispatch(AreaCode.EFFECT, EffectsEvents.SHOW_EFFECTS, effectMesg); break; default: break; } }
private void ShowEffects(EffectMesg mesg) { if (mesg == null) { return; } EffectType type = mesg.Effect; GameObject go = mesg.Parent; switch (type) { case EffectType.CureEffect: Instantiate(CureEffect, go.transform); break; case EffectType.FoodEffect: Instantiate(FoodEffect, go.transform); break; case EffectType.ArmsEffect: Instantiate(ArmsEffect, go.transform); break; case EffectType.Skill_Fullpower: Instantiate(FullPowerEffect, go.transform); break; case EffectType.DeathEffect: Instantiate(DeathEffect, go.transform.position, Quaternion.identity); break; case EffectType.RespawnEffect: GameObject obj = Instantiate(RespawnEffect, go.transform.position, Quaternion.identity); obj.transform.rotation = Quaternion.Euler(new Vector3(-90, 0, 0)); break; default: break; } }
/// <summary> /// 根据数据生成玩家角色(加入或者复活) /// </summary> /// <param name="dto"></param> private void SpawnPlayer(TransformDto dto) { Vector3 pos = new Vector3(dto.pos[0], dto.pos[1], dto.pos[2]); Vector3 rota = new Vector3(dto.rota[0], dto.rota[1], dto.rota[2]); Quaternion qRota = Quaternion.Euler(rota); GameObject obj = Instantiate(character, pos, qRota); string acc = dto.Account; userGameObjDict.Add(acc, obj); UserDto userDto = userDtoDict[acc]; GameObject model = Resources.Load("Model/Model" + userDto.ModelID) as GameObject; Instantiate(model, obj.transform); obj.gameObject.GetComponent <AnimationController>().SetAccount(acc); obj.gameObject.GetComponent <FightController>().SetAccount(acc); EffectMesg effectMesg = new EffectMesg(obj, EffectType.RespawnEffect); Dispatch(AreaCode.EFFECT, EffectsEvents.SHOW_EFFECTS, effectMesg); if (acc == localAcc) { obj.tag = "Player"; //obj.AddComponent<CharacterController>(); obj.AddComponent <MainTransformCtrl>(); obj.gameObject.GetComponent <FightController>().IsLocalPlayer = true; obj.AddComponent <AudioListener>(); obj.transform.Find("Canvas").gameObject.SetActive(false); Dispatch(AreaCode.UI, UIEvent.UI_SHOWHIDE_ETC, true); SocketMessage socketMessage = new SocketMessage(OpCode.GAME, GameCode.GAME_LOADCOMPLETE_CERQ, null); Dispatch(AreaCode.NET, 0, socketMessage); return; } obj.transform.Find("Canvas").transform.Find("NameText").GetComponent <Text>().text = userDto.Name; obj.transform.Find("Canvas").transform.Find("LVText").GetComponent <Text>().text = "LV." + userDto.Lv.ToString(); Sprite sprite = Resources.Load("Icon/Icon" + userDto.IconID, typeof(Sprite)) as Sprite; obj.transform.Find("Canvas").transform.Find("ICON").GetComponent <Image>().sprite = sprite; }