/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static int CalculateMeleeDamage(Entity attacker, Entity target, int damageMods = 0) { if (attacker == null || target == null) { return(0); } float damageLow = 0; float damageHigh = 0; int baseDamage = 0; int damageResult = 0; float chanceToHitMod = 0.0f; damageLow = Mathf.Pow(attacker.GetAttribute((int)AttributeName.Strength).AdjustedBaseValue * 0.5f, 2); damageHigh = Mathf.Pow(attacker.GetAttribute((int)AttributeName.Strength).AdjustedBaseValue * 1.5f, 2); //chanceToHitMod = attacker.GetSkill((int)SkillName.Melee_Offence).AdjustedBaseValue / 2; baseDamage = Random.Range((Mathf.RoundToInt(damageLow)), Mathf.RoundToInt(damageHigh)); //TODO: implement damage modifiers for race, vulnerabilities etc. int damageModifiers = damageMods; if (CalculateMeleeHit(attacker, target, chanceToHitMod)) { damageResult = Mathf.Max(0, (baseDamage + damageModifiers)); damageResult = Mathf.RoundToInt((damageResult / target.GetAttribute((int)AttributeName.Strength).AdjustedBaseValue) * CalculateLevelFactor(attacker, target)); } return(damageResult); }
private ApplicationMetadata DetermineSchemaFromAsset(Entity initialValues) { var assetclassstructure = (string)initialValues.GetAttribute("classstructureid"); var typeofimac = (string)initialValues.GetAttribute("typeofimac"); var completeApplication = MetadataProvider.Application("imac"); if (typeofimac.EqualsAny("add", "update", "move")) { //these doesn´t have subtypes return(completeApplication.ApplyPoliciesWeb(new ApplicationMetadataSchemaKey(typeofimac))); } if (IsPrinterAsset(assetclassstructure)) { //installlan , replacelan or removelan return(completeApplication.ApplyPoliciesWeb(new ApplicationMetadataSchemaKey(typeofimac + "lan"))); } if (IsStdAsset(assetclassstructure)) { return(completeApplication.ApplyPoliciesWeb(new ApplicationMetadataSchemaKey(typeofimac + "std"))); } return(completeApplication.ApplyPoliciesWeb(new ApplicationMetadataSchemaKey(typeofimac + "other"))); //installstd , replacestd or removestd }
private void AdjustInitialValues(Entity initialValues) { var assetnum = initialValues.GetAttribute("assetnum", true); initialValues.SetAttribute("asset", assetnum); var fromLocation = (string)initialValues.GetAttribute(ISMConstants.PluspCustomerColumn); //workaround as the dropdown values of the locations contains currently, just MT4,MT4 instead of HLC-DE-MT4 //TODO: shouldn´t that be the entire value? fromLocation = fromLocation.Replace(HapagPersonGroupConstants.PersonGroupPrefix, ""); initialValues.SetAttribute("fromlocation", fromLocation); }
private void Inject(Entity <IUIPool> entity) { var context = entity.GetAttribute <LuaElementContext, ILuaTable>(); var props = entity.GetAttribute <LuaScopeProps, ILuaTable>(); context.Set("props", props); entity.SetAttribute <LuaElementContext, ILuaTable>(context); entity.Toggle <LuaScopePropsUpdate>(true); foreach (var element in _uiPool.GetElementsInScope(entity.Get <Scope>().Id)) { element.Toggle <LuaScopeStateUpdate>(true); } // entity.Toggle<LuaScopeStateUpdate>(true); }
void InitParam() { if (null != m_Param) { if (Entity.proto == EEntityProto.Monster) { MonsterProtoDb.Item protoData = MonsterProtoDb.Get(Entity.ProtoID); if (null != protoData) { if (protoData.RepulsedType > 0 && Entity.GetAttribute(AttribType.ThresholdRepulsed) > 550f) { Entity.SetAttribute(AttribType.ThresholdRepulsed, 550f); } if (protoData.RepulsedType == 2) { if (Entity.GetAttribute(AttribType.ThresholdRepulsed) > 130f) { Entity.SetAttribute(AttribType.ThresholdRepulsed, 130f); } m_Param.m_ForceToVelocity.keys = LongMoveVelocity; m_Param.m_ForceToMoveTime.keys = LongMoveTime; } else { m_Param.m_ForceToVelocity.keys = NearMoveVelocity; m_Param.m_ForceToMoveTime.keys = NearMoveTime; } m_Param.m_ApplyMoveStopTime.keys = MoveStopTime; m_Param.m_WentflyTimeCurve.keys = MoveWentflyTime; } } } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void SetupAttributes(Entity entity) { foreach (EnemyAttributes attribute in attributes) { entity.GetAttribute((int)attribute.Attribute).BaseValue = attributes[(int)attribute.Attribute].Value; } }
/// <summary> /// Om entiteten innehåller attribut från länkade entiteter efter läsning så måste aliaset för den länkade entiteten anges. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity"></param> /// <param name="linkedEntityAlias"></param> /// <param name="name"></param> /// <param name="default"></param> /// <returns></returns> public static T PropertyLinkedEntity <T>(this Entity entity, string linkedEntityAlias, string name, T @default) { var defaultValue = new AliasedValue(linkedEntityAlias, name, @default); var value = (T)entity.GetAttribute(linkedEntityAlias + "." + name, defaultValue).Value; return(value); }
public bool CheckEquipmentAmmunition() { if (!(m_ActiveableEquipment is IWeapon)) { return(true); } IWeapon weapon = m_ActiveableEquipment as IWeapon; PEGun gun = weapon as PEGun; if (null != gun) { if (gun.m_AmmoType == AmmoType.Bullet) { return(null != m_Package && m_Package.GetItemCount(gun.curItemID) > 0); } return(gun.magazineValue > PETools.PEMath.Epsilon || Entity.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon); } PEBow bow = weapon as PEBow; if (null != bow) { return(null != m_Package && m_Package.GetItemCount(bow.curItemID) > 0); } return(true); }
/// <summary> /// 初始化驯服数据 /// </summary> private void InitTameData(PeEntity master) { if (!Entity) { return; } m_Move = Entity.motionMove as Motion_Move_Motor; m_Master = master; SetctrlType(ECtrlType.Free); if (!m_SkillData.canUse()) { m_SkillData.Reset(MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_L), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_Space), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_pounce) ); } m_PlayerForceDb = new ForceData((int)m_Master.GetAttribute(AttribType.CampID), (int)m_Master.GetAttribute(AttribType.DamageID), (int)m_Master.GetAttribute(AttribType.DefaultPlayerID)); if (m_MountsForceDb == null) { m_MountsForceDb = new ForceData((int)Entity.GetAttribute(AttribType.CampID), (int)Entity.GetAttribute(AttribType.DamageID), (int)Entity.GetAttribute(AttribType.DefaultPlayerID)); } }
private SpeedState calculateSpeed(SpeedState speed) { switch (speed) { case SpeedState.Sprint: if (Entity.GetAttribute(AttribType.SprintSpeed) > 0) { return(SpeedState.Sprint); } else if (Entity.GetAttribute(AttribType.RunSpeed) > 0) { return(SpeedState.Run); } else { return(SpeedState.Walk); } case SpeedState.Run: if (Entity.GetAttribute(AttribType.RunSpeed) > 0) { return(SpeedState.Run); } else { return(SpeedState.Walk); } default: return(SpeedState.Walk); } }
public override void ApplyForce(Vector3 power, ForceMode mode) { // float prob = m_Param != null ? m_Param.repulsedProb : 1.0f; if (m_Motor != null || Entity.GetAttribute(AttribType.Rigid) < 0) { m_Motor.desiredMovementEffect = power; } }
protected override void SetupAttribute(Entity <IUIPool> uiEntity, IView view)//, GameObject go) { Debug.Log($"Update parent for {uiEntity.GetAttribute<Name, string>()}"); var parentId = uiEntity.Get <Parent>().Id; var parent = UIPool.GetElement(parentId); var parentView = ViewPool.GetByIdentity(parent.Get <ViewLink>().Id); view.SetParent(parentView); }
private void Inject(Entity <IUIPool> entity) { var context = entity.GetAttribute <LuaElementContext, ILuaTable>(); var scope = _uiPool.GetScope(entity.Get <Scope>().Id); var scopeState = scope.GetAttribute <LuaScopeState, ILuaTable>(); context.Set("state", scopeState); entity.SetAttribute <LuaElementContext, ILuaTable>(context); }
public override void ApplyEffect(Entity entity) { var attribute = entity.GetAttribute(m_Attribute) as IntAttribute; if (attribute == null) { return; } attribute.SetValue(m_Mode, m_Value); }
void UpdateImpactDamage() { if (!PeGameMgr.IsMulti && PeGameMgr.gamePause) { return; } if (null != m_PhyCtrl) { if (Entity.IsDeath() || mView.IsRagdoll || mMotionMgr.freezePhyState || mMotionMgr.IsActionRunning(PEActionType.Step) || mMotionMgr.IsActionRunning(PEActionType.RopeGunShoot) || Entity.passengerCmpt.IsOnCarrier()) { m_MoveState.Clear(); return; } if (m_MoveState.Count >= MoveRecordCount) { m_MoveState.RemoveAt(0); } m_MoveState.Add(m_PhyCtrl.velocity); if (m_MoveState.Count < MoveRecordCount) { return; } Vector3 oldVelocity = Vector3.zero; for (int i = 0; i < MoveRecordCount - CurrentSpeedFramCount; i++) { oldVelocity += m_MoveState [i]; } oldVelocity /= MoveRecordCount - CurrentSpeedFramCount; Vector3 newVelocity = Vector3.zero; for (int i = 0; i < CurrentSpeedFramCount; i++) { newVelocity += m_MoveState [MoveRecordCount - 1 - i]; } newVelocity /= CurrentSpeedFramCount; float dtSpeed = Vector3.Distance(newVelocity, oldVelocity); if (mMotionMgr.IsActionRunning(PEActionType.SwordAttack) || mMotionMgr.IsActionRunning(PEActionType.TwoHandSwordAttack)) { dtSpeed = Mathf.Abs(newVelocity.y - oldVelocity.y); } if (dtSpeed > FallDamageSpeedThreshold) { float hp = Entity.GetAttribute(AttribType.Hp); hp = Mathf.Clamp(hp - (dtSpeed - FallDamageSpeedThreshold) * FallDamageSpeedToDamage, 0, hp); Entity.SetAttribute(AttribType.Hp, hp, false); m_MoveState.Clear(); } } }
public void OnApply(Entity entity) { switch (OnApplyStatusEffect) { case StatusEffect.MoveSpeed: entity.SetMovementSpeed(entity.MovementSpeed + OnApplyStatusEffectValue); break; case StatusEffect.Stun: entity.SetMovementSpeed(0); break; case StatusEffect.Root: entity.SetMovementSpeed(0); break; case StatusEffect.Snare: entity.SetMovementSpeed(0); break; case StatusEffect.Knokback: break; case StatusEffect.Cleanse: break; case StatusEffect.Interrupt: break; case StatusEffect.IncreaseEndurance: entity.GetAttribute(Attribute.Endurance) += OnApplyStatusEffectValue; break; case StatusEffect.IncreaseKnowledge: entity.GetAttribute(Attribute.Knowledge) += OnApplyStatusEffectValue; break; case StatusEffect.Rage: entity.GetAttribute(Attribute.Endurance) += OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Strength) += OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Agility) += OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Intelligence) += OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Knowledge) += OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Luck) += OnApplyStatusEffectValue; //entity.SetMovementSpeed(30); //entity.AttackRange = 15 * 15; break; } entity.Server.OutgoingMessageHandler.SendBuffApply(entity, this); }
public void OnEnd(Entity entity) { switch (OnApplyStatusEffect) { case StatusEffect.MoveSpeed: entity.SetMovementSpeed(entity.MovementSpeed - OnApplyStatusEffectValue); break; case StatusEffect.Stun: entity.SetMovementSpeed(NPCFactory.Instance.GetNpcValuesOf(ModelType.MeleeNPC).MovementSpeed); break; case StatusEffect.Root: entity.SetMovementSpeed(NPCFactory.Instance.GetNpcValuesOf(ModelType.MeleeNPC).MovementSpeed); break; case StatusEffect.Snare: entity.SetMovementSpeed(NPCFactory.Instance.GetNpcValuesOf(ModelType.MeleeNPC).MovementSpeed); break; case StatusEffect.Knokback: break; case StatusEffect.Cleanse: break; case StatusEffect.Interrupt: break; case StatusEffect.IncreaseEndurance: entity.GetAttribute(Attribute.Endurance) -= OnApplyStatusEffectValue; break; case StatusEffect.IncreaseKnowledge: entity.GetAttribute(Attribute.Knowledge) -= OnApplyStatusEffectValue; break; case StatusEffect.Rage: entity.GetAttribute(Attribute.Endurance) -= OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Strength) -= OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Agility) -= OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Intelligence) -= OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Knowledge) -= OnApplyStatusEffectValue; entity.GetAttribute(Attribute.Luck) -= OnApplyStatusEffectValue; //entity.SetMovementSpeed(ProtoNpc.Instance.GetNpcValuesOf(entity.ModelType).MovementSpeed); //entity.AttackRange = ProtoNpc.Instance.GetNpcValuesOf(entity.ModelType).AttackRange; break; } entity.Server.OutgoingMessageHandler.SendBuffRemove(entity, this); }
private void MakeFor(Entity <IUIPool> entity) { var cycle = entity.Need <LuaLifeCycle>(); var compiled = entity.GetAttribute <LuaCompiled, ILuaTable>(); compiled.Get(ExecutionMethod.Tick.ToString(), out cycle.OnTick); compiled.Get(ExecutionMethod.Create.ToString(), out cycle.OnCreate); compiled.Get(ExecutionMethod.Destroy.ToString(), out cycle.OnDestroy); compiled.Get(ExecutionMethod.Props.ToString(), out cycle.OnProps); compiled.Get(ExecutionMethod.State.ToString(), out cycle.OnState); compiled.Get(ExecutionMethod.PropertyInjection.ToString(), out cycle.PropertyInjection); entity.ReplaceInstance(cycle); }
void OnAttack(SkEntity skEntity, float damage) { PeEntity tarEntity = skEntity.GetComponent <PeEntity>(); if (tarEntity != null && tarEntity != Entity) { float tansDis = tarEntity.IsBoss ? 128f : 64f; int playerID = (int)Entity.GetAttribute(AttribType.DefaultPlayerID); bool canTrans = false; if (GameConfig.IsMultiClient) { if (ForceSetting.Instance.GetForceType(playerID) == EPlayerType.Human) { canTrans = true; } int tarPlayerId = (int)tarEntity.GetAttribute(AttribType.DefaultPlayerID); if (ForceSetting.Instance.GetForceType(tarPlayerId) == EPlayerType.Human) { List <PeEntity> entities = EntityMgr.Instance.GetEntities(tarEntity.position, tansDis, tarPlayerId, false, tarEntity); for (int i = 0; i < entities.Count; i++) { if (!entities[i].Equals(Entity) && entities[i].target != null) { entities[i].target.TransferHatred(Entity, damage); } } } } else { if (ForceSetting.Instance.GetForceID(playerID) == 1) { canTrans = true; } } if (canTrans) { List <PeEntity> entities = EntityMgr.Instance.GetEntities(Entity.position, tansDis, playerID, false, Entity); for (int i = 0; i < entities.Count; i++) { if (!entities[i].Equals(tarEntity) && entities[i].target != null) { entities[i].target.TransferHatred(tarEntity, damage); } } } } }
/// <summary> /// /// </summary> void UpdateMoveState() { if (ctrlType != ECtrlType.Mount || Entity.skEntity.IsSkillRunning()) { return; } if (m_Move == null) { return; } //if(PeInput.Get(PeInput.LogicFunction.InteractWithItem) && null != SelectItem_N.Instance && SelectItem_N.Instance.HaveOpItem()) //计算移动方向 Vector3 moveDirLocal = PeInput.GetAxisH() * Vector3.right + PeInput.GetAxisV() * Vector3.forward; m_MoveDir = Vector3.ProjectOnPlane(PETools.PEUtil.MainCamTransform.rotation * moveDirLocal, Vector3.up); //计算行走速度 if (PeInput.Get(PeInput.LogicFunction.SwitchWalkRun)) { m_MoveWalk = !m_MoveWalk; } SpeedState state = m_MoveWalk ? SpeedState.Walk : SpeedState.Run; if (PeInput.Get(PeInput.LogicFunction.Sprint) && Entity.GetAttribute(AttribType.SprintSpeed) > 0) { state = SpeedState.Sprint; } //移动 m_Move.Move(m_MoveDir.normalized, state); //跳跃 if ((m_SkillData.canSpace() || m_SkillData.canProunce()) && PeInput.Get(PeInput.LogicFunction.Jump)) { Jump(); } //左键攻击 if (m_SkillData.canAttack() && PeInput.Get(PeInput.LogicFunction.Attack)) { AttackL(); } //右键攻击:还需要定义右键攻击逻辑键 //if (PeInput.Get(PeInput.LogicFunction.Item_Use)) // AttackR(); }
private void TransferHared(PeEntity targetentity, float damage) { float tansDis = targetentity.IsBoss ? 128f : 64f; int playerID = (int)Entity.GetAttribute(AttribType.DefaultPlayerID); List <PeEntity> entities = EntityMgr.Instance.GetEntities(Entity.position, tansDis, playerID, false, Entity); for (int i = 0; i < entities.Count; i++) { if (!entities[i].Equals(targetentity) && entities[i].target != null) { entities[i].target.TransferHatred(targetentity, damage); } } }
private void AdjustInitialValues(Entity initialValues, string schemaId) { var isCustodian = (String)initialValues.GetAttribute("#iscustodian"); var originalLocation = (string)initialValues.GetAttribute(ISMConstants.PluspCustomerColumn, true); //workaround as the dropdown values of the locations contains currently, just MT4,MT4 instead of HLC-DE-MT4 //TODO: shouldn´t that be the entire value? var prefixedOnlyLocation = originalLocation.Replace(HapagPersonGroupConstants.PersonGroupPrefix, ""); if (schemaId.Equals("phone")) { initialValues.SetAttribute("affectedDevice", "Cisco-IP-Phone"); initialValues.SetAttribute("phonepluspcustomer", originalLocation); } else if (schemaId.Equals("printer")) { initialValues.SetAttribute("printerpluspcustomer", originalLocation); } else if (isCustodian.EqualsIc("false")) { var assetnum = initialValues.GetAttribute("assetnum", true); initialValues.SetAttribute("itcassetnum", assetnum); initialValues.SetAttribute("itcassetlocation", prefixedOnlyLocation); } }
private ApplicationMetadata DetermineSchemaFromAsset(Entity initialValues) { var assetclassstructure = (string)initialValues.GetAttribute("classstructureid"); var completeApplication = MetadataProvider.Application("servicerequest"); if (AssetConstants.PhoneClassStructure.Equals(assetclassstructure)) { return(completeApplication.ApplyPoliciesWeb(new ApplicationMetadataSchemaKey("phone"))); } if (IsPrinterAsset(assetclassstructure)) { return(completeApplication.ApplyPoliciesWeb(new ApplicationMetadataSchemaKey("printer"))); } return(completeApplication.ApplyPoliciesWeb(new ApplicationMetadataSchemaKey("general"))); }
protected override void SetupAttribute(Entity <IUIPool> uiEntity, IView view)//, GameObject go) { var path = uiEntity.GetAttribute <Resource, string>(); _contentPool.RequestFont(path, delegate(string p, ContentReceiveResult <UnityEngine.Font> result) { if (!result.IsError) { view.SetFont(result.Data);//go.GetComponent<UnityEngine.UI.Text>().font = result.Data; } else { Debug.LogError(result.ErrorMessage); } }); }
protected override void SetupAttribute(Entity <IUIPool> uiEntity, IView view)//, GameObject go) { var path = uiEntity.GetAttribute <Resource, string>(); _contentPool.RequestSprite(path, delegate(string p, ContentReceiveResult <Sprite> result) { if (!result.IsError) { // uiEntity.GetAttribute<Graphic, UnityEngine.UI.Graphic>().Value(go.GetComponent<Image>().sprite = result.Data); view.SetSprite(result.Data); } else { Debug.LogError(result.ErrorMessage); } }); }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static float CalculateLUKChance(Entity attacker, Entity target) { if (attacker == null || target == null) { return(0); } float luk = 0.0f; float levelFactor = CalculateLevelFactor(attacker, target); float compareLUK = (float)attacker.GetAttribute((int)AttributeName.Luck).AdjustedBaseValue / target.GetAttribute((int)AttributeName.Luck).AdjustedBaseValue; luk += compareLUK * 5 * levelFactor; return(luk); }
private static string GetEntityDisplayString(IExecutionContainer container, DataBlockImportMatch match, Entity cdEntity) { var unique = new List <string>(); if (match != null && match.Attribute.Length > 0) { foreach (var attribute in match.Attribute) { var matchdisplay = attribute.Display; if (string.IsNullOrEmpty(matchdisplay)) { matchdisplay = attribute.Name; } var matchvalue = "<null>"; if (cdEntity.Contains(matchdisplay, true)) { if (cdEntity[matchdisplay] is EntityReference) { // Don't use PropertyAsString, that would perform GetRelated that we don't want due to performance var entref = cdEntity.GetAttribute <EntityReference>(matchdisplay, null); if (!string.IsNullOrEmpty(entref.Name)) { matchvalue = entref.Name; } else { matchvalue = entref.LogicalName + ":" + entref.Id.ToString(); } } else { matchvalue = container.Attribute(matchdisplay).On(cdEntity).ToString(); } } unique.Add(matchvalue); } } if (unique.Count == 0) { unique.Add(cdEntity.Id.ToString()); } return(string.Join(", ", unique)); }
public bool WeaponCanUse(IWeapon weapon) { if (!isMainPlayer && null != m_NPC && !m_NPC.HasConsume) { return(true); } PeSword sword = weapon as PeSword; if (null != sword) { return(true); } PEGun gun = weapon as PEGun; if (null != gun) { if (m_GunFire.m_IgnoreItem) { return(true); } if (gun.m_AmmoType == AmmoType.Bullet) { return(gun.durability > PETools.PEMath.Epsilon && (gun.magazineValue > PETools.PEMath.Epsilon || null == m_Package || m_Package.GetItemCount(gun.curItemID) > 0)); } return(gun.durability > PETools.PEMath.Epsilon && (gun.magazineValue > PETools.PEMath.Epsilon || Entity.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon)); } PEBow bow = weapon as PEBow; if (null != bow) { if (m_BowShoot.m_IgnoreItem) { return(true); } return(bow.durability > PETools.PEMath.Epsilon && null == m_Package || m_Package.GetItemCount(bow.curItemID) > 0); } return(true); }
protected internal void SetAttribute(Entity entity, EntityInstance targetInstance, string attributeName, IAttributeData attributeData) { if (attributeData.Value == null && !attributeData.Changepoints.Any()) { return; } RBAttr attribute = entity.GetAttribute(attributeName); if (attribute != null) { if (attributeData.Changepoints.Any()) { var changePoints = this.MapTemporalValue(attributeData.Changepoints); attribute.SetValue(targetInstance, new TemporalValue(null, changePoints)); } else if (attribute.GetValueType() == 16) { attribute.SetValue(targetInstance, new Date(DateTime.Parse(attributeData.Value.ToString()))); } else if (attribute.GetValueType() == 4) { attribute.SetValue(targetInstance, new Oracle.Determinations.Masquerade.Lang.Double(attributeData.Value.ToString())); } else if (attribute.GetValueType() == 8) { attribute.SetValue(targetInstance, new Oracle.Determinations.Masquerade.Lang.Double(attributeData.Value.ToString())); } else if (attribute.GetValueType() == 2) { attribute.SetValue(targetInstance, attributeData.Value.ToString().Trim()); } else { attribute.SetValue(targetInstance, bool.Parse(attributeData.Value.ToString())); } } else { // TODO: Log something } }
/// <summary> /// 初始化坐骑数据(被驯服后数据) /// </summary> private bool InitMountData() { if (!Entity) { return(false); } m_Move = Entity.motionMove as Motion_Move_Motor; m_Move.Stop(); SetctrlType(ECtrlType.Mount); Pathea.FastTravelMgr.Instance.OnFastTravel += OnFastTravel; m_PlayerForceDb = new ForceData((int)m_Master.GetAttribute(AttribType.CampID), (int)m_Master.GetAttribute(AttribType.DamageID), (int)m_Master.GetAttribute(AttribType.DefaultPlayerID)); if (m_MountsForceDb == null) { m_MountsForceDb = new ForceData((int)Entity.GetAttribute(AttribType.CampID), (int)Entity.GetAttribute(AttribType.DamageID), (int)Entity.GetAttribute(AttribType.DefaultPlayerID)); } if (!m_SkillData.canUse()) { m_SkillData.Reset(MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_L), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_Space), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_pounce) ); } StartMountsForceDb(); DispatchEvent(Entity); //lw:2017.3.13:读档后如果在晚上,怪物不能结束睡觉动作 if (Entity.animCmpt != null) { Entity.animCmpt.SetBool("Sleep", false); } m_Init = true; return(true); }
public void AttributeBecomesNonInheritableAfterRemoveFromParent() { Entity parent = new Entity() { Name = "parent" }; Attribute attribute = new Attribute("test") { Value = new Value("value") }; parent.AddAttribute(attribute); Entity child = new Entity(); child.AddPrototype(parent); Attribute childAttribute = child.GetAttribute("test"); //childAttribute.IsInherited = false; childAttribute.Value = new Value("new value"); //Assert.IsTrue(childAttribute.CanInherit); parent.RemoveAttribute(attribute); //Assert.IsFalse(childAttribute.CanInherit); Assert.AreEqual(0, parent.Attributes.Count); Assert.AreEqual(1, child.Attributes.Count); }
public void ValueFollowsInheritedAttribute() { //bool propertyChanged = false; Entity parent = new Entity() { Name = "parent" }; Attribute parentAttribute = new Attribute("test"); parent.AddAttribute(parentAttribute); Entity child = new Entity(); child.AddPrototype(parent); Attribute childAttribute = child.GetAttribute("test"); //childAttribute.PropertyChanged += (o, e) => propertyChanged = (e.PropertyName == "Value"); parentAttribute.Value = new Value("value"); //Assert.IsTrue(propertyChanged); Assert.AreEqual("value", childAttribute.Value.Initializer); }
public void KeyFollowsInheritedAttribute() { Entity parent = new Entity() { Name = "parent" }; Attribute parentAttribute = new Attribute("test"); parent.AddAttribute(parentAttribute); Entity child = new Entity(); child.AddPrototype(parent); Attribute childAttribute = child.GetAttribute("test"); parentAttribute.Name = "test2"; Assert.IsFalse(childAttribute.HasOwnValue); Assert.AreEqual(0, child.Attributes.Count(x => x.Name == "test")); Assert.AreEqual(1, child.Attributes.Count(x => x.Name == "test2")); }
public void GiveInheritedAttributeLocalValue() { bool propertyChanged = false; Entity parent = new Entity() { Name = "parent" }; Attribute parentAttribute = new Attribute("test"); parent.AddAttribute(parentAttribute); Entity child = new Entity(); child.AddPrototype(parent); Assert.AreEqual(1, child.Attributes.Count(x => x.IsInherited && !x.HasOwnValue)); Attribute childAttribute = child.GetAttribute("test"); childAttribute.PropertyChanged += (o, e) => propertyChanged |= (e.PropertyName == "HasOwnValue"); childAttribute.Value = new Value("value"); Assert.IsTrue(propertyChanged); Assert.AreEqual(1, child.Attributes.Count(x => x.HasOwnValue)); }
public void ClearAttributeValue() { Entity parent = new Entity() { Name = "parent" }; Attribute parentAttribute = new Attribute("test") { Value = new Value("originalValue") }; parent.AddAttribute(parentAttribute); Entity child = new Entity(); child.AddPrototype(parent); Attribute childAttribute = child.GetAttribute("test"); childAttribute.Value = new Value("value"); Assert.AreEqual(childAttribute.Value.Initializer, "value"); Assert.AreEqual(1, child.Attributes.Count(x => x.HasOwnValue)); childAttribute.Value = null; Assert.AreEqual(childAttribute.Value.Initializer, "originalValue"); Assert.AreEqual(0, child.Attributes.Count(x => x.HasOwnValue)); }
public void CannotChangeKeyForInheritedAttribute() { Entity parent = new Entity() { Name = "parent" }; Attribute attribute = new Attribute("test") { Value = new Value("value") }; parent.AddAttribute(attribute); Entity child = new Entity(); child.AddPrototype(parent); Attribute childAttribute = child.GetAttribute("test"); childAttribute.Value = new Value("new value"); Assert.IsTrue(childAttribute.IsInherited); Assert.IsTrue(childAttribute.Name == "test"); childAttribute.Name = "test2"; Assert.IsTrue(childAttribute.IsInherited); Assert.IsTrue(childAttribute.Name == "test"); Assert.AreEqual(1, parent.Attributes.Count); Assert.AreEqual(1, child.Attributes.Count); }
public void CannotRemoveInheritedAttribute() { Entity parent = new Entity() { Name = "parent" }; parent.AddAttribute(new Attribute("test")); Entity child = new Entity(); child.AddPrototype(parent); Attribute childAttribute = child.GetAttribute("test"); child.RemoveAttribute(childAttribute); Assert.AreEqual(1, child.Attributes.Where(x => x.Name == "test").Count()); }
public void AttributesBecomesNonInheritableAfterParentKeyChange() { Entity parent = new Entity() { Name = "parent" }; Attribute attribute = new Attribute("test") { Value = new Value("value") }; parent.AddAttribute(attribute); Entity child = new Entity(); child.AddPrototype(parent); Attribute childAttribute = child.GetAttribute("test"); //childAttribute.IsInherited = false; childAttribute.Value = new Value("new value"); attribute.Name = "test2"; Assert.AreEqual(childAttribute.Name, "test"); //Assert.IsFalse(childAttribute.CanInherit); Assert.AreEqual(1, parent.Attributes.Count); Assert.AreEqual(2, child.Attributes.Count); }