//not used private void HandleSyncTransform(EventData eventData) { int roleId = (int)eventData.Parameters[(byte)ParameterCode.RoleId]; UserRole.RoleState roleState = Serialization.LoadStruct <UserRole.RoleState>((byte[])eventData.Parameters[(byte)ParameterCode.RoleState]); _gamePlayManager.OnSyncTransform(roleId, roleState.CurrentPos); }
void TestEffect() { if (Input.GetKeyDown(KeyCode.S)) { UserRole.RoleState roleState = new UserRole.RoleState() { RoleUId = 1, }; roleState.MagicStates = new UserRole.MagicState[1]; UserRole.MagicState magicState = new UserRole.MagicState() { RemainTime = 5, AttribType = AttribType.SkillDisable, EffectType = EffectType.Slow, AffectValue = 1 }; roleState.MagicStates[0] = magicState; CheckEffect(roleState); } }
public void OnReciveBattleSync(UserRole.RoleState roleState) { if (this == null) { return; } role.State = roleState; float damage = hp - roleState.CurHP; this.hp -= damage; //update MP from server if (this._healthBar != null) { this._healthBar.SetMP(roleState.CurMP, roleState.MaxMP); } // set die from server if (roleState.Action == RoleAction.Dead) { this.hp = 0; StartCoroutine(OnDied()); } if (damage > 0) { this.damageGet = Mathf.Abs(damage); this.TakingDamage(); if (role.Base.UserId == GameManager.GameUser.Id) { this.InitTextDamage(Color.green); } else { this.InitTextDamage(Color.red); } float curHPPercent = hp / maxhp; float l = Mathf.Lerp(2.0f / 3.0f, 0.1f, curHPPercent); if (damage > 10) { if (Random.Range(0.0f, 1.0f) <= l) { OnHit(); //Debug.Log("Hit " + curHPPercent.ToString("0.0") + " " + l); } } } else//Buff { this.damageGet = Mathf.Abs(damage); if (this.damageGet > 1) { this.InitTextDamage(Color.green, true); } } if (this.hp <= 0) { //Debug.Log("this.hp " + this.hp); actionStat = ActionStat.Dead; if (isMob) { UIBattleManager.Instance.OnMonsterIsDie(); } } else { CheckEffect(roleState); } }
private void CheckEffect(UserRole.RoleState roleState) { foreach (UserRole.MagicState magicAttrib in roleState.MagicStates) { if (magicAttrib.EffectType != EffectType.None && magicAttrib.AttribType != AttribType.None) { if (!_effect.ContainsKey(magicAttrib.EffectType)) { //_effectManager.AddEffect(magicAttrib); //if (isConnectedServer()) //{ // if (role.Base.UserId == GameManager.GameUser.Id) // UITextManager.Instance.createText(string.Format(GameManager.localization.GetText("Battle_Effect"), role.Name, magicAttrib.EffectType.ToString())); //} _effect.Add(magicAttrib.EffectType, magicAttrib); _healthBar.AddEffect(magicAttrib); switch (magicAttrib.EffectType) { case EffectType.Stun: { //Debug.Log(gameObject.name + " Stun"); _oldMoveSpeed = speedMove; _oldActionSpeed = actionSpeed; PauseAnim(); Invoke("DePauseAnim", magicAttrib.RemainTime); } break; case EffectType.Slow: { Slow(Mathf.Abs(magicAttrib.AffectValue / 100.0f)); Invoke("RestoreAnimationSpeed", magicAttrib.RemainTime); } break; case EffectType.BattleMage: case EffectType.ATSup: { float percent = magicAttrib.AffectValue / 100.0f; GetComponent <Animation>()[action.name].speed = _actionAnimSpeed * (1 + percent); Invoke("RestoreAnimationSpeed", magicAttrib.RemainTime); } break; case EffectType.ATSdown: { float percent = magicAttrib.AffectValue / 100.0f; GetComponent <Animation>()[action.name].speed = _actionAnimSpeed * (1 - percent); Invoke("RestoreAnimationSpeed", magicAttrib.RemainTime); } break; case EffectType.MVSup: { float percent = magicAttrib.AffectValue / 100.0f; GetComponent <Animation>()[walk.name].speed = _moveAnimSpeed * (1 + percent); Invoke("RestoreAnimationSpeed", magicAttrib.RemainTime); } break; case EffectType.Cleansing: { _healthBar.ClearAllEffect(); RestoreAnimationSpeed(); } break; } } } } actionSpeed = roleState.AtkDelay; speedMove = roleState.MoveSpeed; CheckAndRemoveEffect(roleState.MagicStates); }