public void SyncBossAnimation(BossAnimationModel model) { Dictionary <byte, object> parameters = new Dictionary <byte, object>(); ParameterTool.AddParameter(parameters, ParameterCode.BossAnimationModel, model); PhotonEngine.Instance.SendRequest(OpCode, SubCode.SyncBossAnimation, parameters); }
public void OnSyncBossAnimation(BossAnimationModel model) { if (model.walk) { anim.SetBool("walk", true); } if (model.walk == false) { anim.SetBool("walk", false); } if (model.TakeDamage) { anim.SetBool("TakeDamage", true); } if (model.die) { anim.SetBool("die", true); } if (model.attack01) { anim.SetBool("attack01", true); } if (model.attack02) { anim.SetBool("attack02", true); } if (model.attack03) { anim.SetBool("attack03", true); } }
public void OnSyncBossAnimation(BossAnimationModel model) { if (model.stand) { GetComponent <Animation>().Play("stand"); } if (model.attack01) { GetComponent <Animation>().Play("attack01"); } if (model.attack02) { GetComponent <Animation>().Play("attack02"); } if (model.attack03) { GetComponent <Animation>().Play("attack03"); } if (model.die) { GetComponent <Animation>().Play("die"); } if (model.hit) { GetComponent <Animation>().Play("hit"); } if (model.walk) { GetComponent <Animation>().Play("walk"); } }
public void Attack() { int hp = targetGo.GetComponent <PlayerAttack>().hp; if (hp <= 0) { return; } attacking = true; if (attackIndex == 4) { attackIndex = 1; } animation.CrossFade("attack0" + attackIndex); BossAnimationModel model = new BossAnimationModel() { attack01 = attackIndex == 1 ? true : false, attack02 = attackIndex == 2 ? true : false, attack03 = attackIndex == 3 ? true : false, damage = damageArray[attackIndex - 1] //对玩家造成的伤害 }; if (TeamInviteController.Instance.isTeam) { EnermyController.Instance.SyncBossAnimationRequest(this.GUID, model); } //targetGo.SendMessage("GetHurt", damageArray[attackIndex-1] + "," + false, SendMessageOptions.DontRequireReceiver); attackIndex++; }
public override void OnEvent(EventData eventData) { SubCode subcode = ParameterTool.GetSubcode(eventData.Parameters); switch (subcode) { case SubCode.SyncBossAnimation: BossAnimationModel model = ParameterTool.GetParameter <BossAnimationModel>(eventData.Parameters, ParameterCode.BossAnimationModel); if (OnSyncBossAnimation != null) { OnSyncBossAnimation(model); } break; } }
//同步Boss 动画(移动动画除外) public void SyncBossAnimationRequest(string guid, BossAnimationModel model) { Dictionary <byte, object> parameters = new Dictionary <byte, object>(); parameters.Add((byte)ParameterCode.SubCode, SubCode.SyncBossAnimation); string json = JsonMapper.ToJson(model); parameters.Add((byte)ParameterCode.BossAnimationModel, json); parameters.Add((byte)ParameterCode.EnermyGuid, guid); //其它必要参数: parameters.Add((byte)ParameterCode.ChannelID, PhotonEngine.Instance.ChannelId); parameters.Add((byte)ParameterCode.RoleId, PhotonEngine.Instance.role.ID); parameters.Add((byte)ParameterCode.MasterRoleID, PhotonEngine.Instance.masterid); //发送请求 PhotonEngine.Instance.SendRequest(OperationCode.SyncEnermy, parameters); }
// void TakeBossDamageResponse(string guid, BossAnimationModel model) { //int damage = model.damage; int hp = model.hp; GameObject enermyGo = null; enermyGoDict.TryGetValue(guid, out enermyGo); HUDText hudText = null; if (null != enermyGo) { Boss boss = enermyGo.GetComponent <Boss>(); hudText = boss.hudText; boss.hp = hp; //boss.damage = damage; //显示血条 } }
// void SyncBossAniamtionResponse(Dictionary <byte, object> parameters) { //根据guid获取 enermyGo,更新之 string guid = ""; object o = null; parameters.TryGetValue((byte)ParameterCode.EnermyGuid, out o); guid = o.ToString(); GameObject enermyGo = null; EnermyController.Instance.enermyGoDict.TryGetValue(guid, out enermyGo); parameters.TryGetValue((byte)ParameterCode.BossAnimationModel, out o); BossAnimationModel model = new BossAnimationModel(); model = JsonMapper.ToObject <BossAnimationModel>(o.ToString()); Animation anim = enermyGo.GetComponent <Animation>();//null reference if (model.attack01) { anim.Play("attack01"); } if (model.attack02) { anim.Play("attack02"); } if (model.attack03) { anim.Play("attack03"); } if (model.die) { enermyGo.GetComponent <Boss>().Dead(model.damage); anim.Play("die"); } if (model.takeDamage) { //怪物血条血量减少 TakeBossDamageResponse(guid, model); } }
public void Dead(int damage) { isDead = true; animation.Play("die"); //同步死亡动画到其它客户端 if (isSyncBoss) { BossAnimationModel model = new BossAnimationModel() { die = true }; EnermyController.Instance.SyncBossAnimationRequest(this.GUID, model); } //从TranscriptManager中移除该敌人 TranscriptManager.Instance.RemoveEnermy(this.gameObject); //Boss死后保留尸体 this.gameObject.rigidbody.isKinematic = true; Destroy(hudTextGo, 1.0f); //通关成功 TranscriptManager.Instance.GameCompleteHandle(); }
public void SyncBossAnimation(BossAnimationModel model) { Dictionary<byte,object> parameters = new Dictionary<byte, object>(); ParameterTool.AddParameter(parameters,ParameterCode.BossAnimationModel, model); PhotonEngine.Instance.SendRequest(OpCode,SubCode.SyncBossAnimation,parameters); }
public void OnSyncBossAnimation(BossAnimationModel model) { if (model.stand) { GetComponent<Animation>().Play("stand"); } if (model.attack01) { GetComponent<Animation>().Play("attack01"); } if (model.attack02) { GetComponent<Animation>().Play("attack02"); } if (model.attack03) { GetComponent<Animation>().Play("attack03"); } if (model.die) { GetComponent<Animation>().Play("die"); } if (model.hit) { GetComponent<Animation>().Play("hit"); } if (model.walk) { GetComponent<Animation>().Play("walk"); } }