internal void CreateEntityView(int objId) { if (objId <= 0) { LogSystem.Error("Error:CreateEntityView objId<=0 !!!"); Helper.LogCallStack(); return; } if (!m_EntityViews.ContainsKey(objId)) { EntityInfo obj = ClientModule.Instance.EntityManager.GetEntityInfo(objId); if (null != obj) { EntityViewModel view = new EntityViewModel(); view.Create(obj); m_EntityViews.Add(objId, view); if (null != view.Actor) { if (m_Object2Ids.ContainsKey(view.Actor)) { m_Object2Ids[view.Actor] = objId; } else { m_Object2Ids.Add(view.Actor, objId); } } else { LogSystem.Warn("CreateEntityView:{0}, model:{1}, actor is null", objId, obj.GetModel()); } } } }
static public int get_Animator(IntPtr l) { try { GameFramework.EntityViewModel self = (GameFramework.EntityViewModel)checkSelf(l); pushValue(l, true); pushValue(l, self.Animator); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int UpdateEdgeColor(IntPtr l) { try { GameFramework.EntityViewModel self = (GameFramework.EntityViewModel)checkSelf(l); self.UpdateEdgeColor(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { GameFramework.EntityViewModel o; o = new GameFramework.EntityViewModel(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int set_Visible(IntPtr l) { try { GameFramework.EntityViewModel self = (GameFramework.EntityViewModel)checkSelf(l); bool v; checkType(l, 2, out v); self.Visible = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int ToggleMaskEffect(IntPtr l) { try { GameFramework.EntityViewModel self = (GameFramework.EntityViewModel)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); self.ToggleMaskEffect(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int SetRedEdge(IntPtr l) { try { GameFramework.EntityViewModel self = (GameFramework.EntityViewModel)checkSelf(l); System.Single a1; checkType(l, 2, out a1); self.SetRedEdge(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int Create(IntPtr l) { try { GameFramework.EntityViewModel self = (GameFramework.EntityViewModel)checkSelf(l); GameFramework.EntityInfo a1; checkType(l, 2, out a1); self.Create(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int MoveTo(IntPtr l) { try { GameFramework.EntityViewModel self = (GameFramework.EntityViewModel)checkSelf(l); System.Single a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); System.Single a3; checkType(l, 4, out a3); self.MoveTo(a1, a2, a3); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public int GetTargetType(int actorId, TableConfig.Skill cfg, int seq) { if (cfg.type == (int)SkillOrImpactType.Skill) { return(cfg.targetType); } else { EntityViewModel view = GetEntityViewById(actorId); if (null != view && null != view.Entity) { EntityInfo entity = view.Entity; ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq); if (null != impactInfo) { return(impactInfo.TargetType); } } } return(0); }
internal void AddShield(int objId, TableConfig.Skill cfg, int seq) { EntityViewModel view = GetEntityViewById(objId); if (null != view && null != view.Entity) { EntityInfo entity = view.Entity; if (cfg.type == (int)SkillOrImpactType.Skill) { entity.SetShield(Operate_Type.OT_Relative, cfg.addshield); } else { ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq); if (null != impactInfo) { entity.SetShield(Operate_Type.OT_Relative, impactInfo.DamageData.AddShield); } } } }
internal void RemoveShield(int objId, TableConfig.Skill cfg, int seq) { EntityViewModel view = GetEntityViewById(objId); if (null != view && null != view.Entity) { EntityInfo entity = view.Entity; if (cfg.type == (int)SkillOrImpactType.Skill) { entity.SetShield(Operate_Type.OT_Absolute, 0); } else { ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq); if (null != impactInfo) { entity.SetShield(Operate_Type.OT_Absolute, 0); } } } }
public void DeactivateSkill(int actorId, int skillId, int seq) { EntityViewModel view = GetEntityViewById(actorId); if (null != view && null != view.Entity) { SkillInfo skillInfo = view.Entity.GetSkillStateInfo().GetSkillInfoById(skillId); if (null != skillInfo) { if (skillId == view.Entity.ManualSkillId) { LogSystem.Warn("ManualSkill {0} deactivate.", skillId); } skillInfo.IsSkillActivated = false; view.Entity.IsControlByManual = false; } else { view.Entity.GetSkillStateInfo().RemoveImpact(seq); } } }
public bool CanCastSkill(int objId, TableConfig.Skill configData, int seq) { bool ret = true; if (configData.type == (int)SkillOrImpactType.Skill) { EntityViewModel view = GetEntityViewById(objId); if (null != view && null != view.Entity) { EntityInfo entity = view.Entity; if (entity.GetSkillStateInfo().IsSkillActivated()) { SkillInfo skillInfo = entity.GetSkillStateInfo().GetCurSkillInfo(); if (null != skillInfo && skillInfo.ConfigData.skillData.interruptPriority >= configData.skillData.interruptPriority) { ret = false; } } } } return(ret); }
public GfxSkillSenderInfo BuildSkillInfo(UnityEngine.GameObject obj, TableConfig.Skill configData, int seq) { GfxSkillSenderInfo ret = null; EntityViewModel view = GetEntityView(obj); if (null != view && null != view.Actor && null != view.Entity && null != configData) { EntityInfo entity = view.Entity; int objId = view.Entity.GetId(); int targetId = 0; if (configData.type == (int)SkillOrImpactType.Skill) { targetId = entity.GetAiStateInfo().Target; } else { ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq); if (null != impactInfo) { targetId = impactInfo.ImpactSenderId; } } UnityEngine.GameObject targetObj = GetGameObject(targetId); if (null != targetObj) { ret = new GfxSkillSenderInfo(configData, seq, objId, view.Actor, targetId, targetObj); } else { ret = new GfxSkillSenderInfo(configData, seq, objId, view.Actor); } } else { ret = new GfxSkillSenderInfo(configData, seq, 0, obj); } return(ret); }
public void ImpactDamage(int srcObjId, int targetId, int impactId, int seq, bool isFinal) { if (!PluginFramework.Instance.IsBattleScene) { return; } EntityViewModel view = GetEntityViewById(targetId); EntityViewModel srcView = GetEntityViewById(srcObjId); if (null != view && null != view.Entity && null != view.Actor) { EntityInfo targetObj = view.Entity; EntityInfo srcObj = null; if (null != srcView && null != srcView.Entity) { srcObj = srcView.Entity; } if (null != targetObj && !view.Entity.IsDeadSkillCasting()) { ImpactInfo impactInfo = targetObj.GetSkillStateInfo().GetImpactInfoBySeq(seq); if (null != impactInfo && impactId == impactInfo.ImpactId) { EntityInfo ownerObj = GetRootSummoner(srcObj); int ownerId = 0; if (null != ownerObj) { ownerId = ownerObj.GetId(); } int addsc = impactInfo.DamageData.AddSc; int adduc = impactInfo.DamageData.AddUc; int index = impactInfo.CurDamageCount; ++impactInfo.CurDamageCount; int multiple = impactInfo.DamageData.GetMultiple(index); int damage = impactInfo.DamageData.GetDamage(index); long hitrate = 0; long critrate = 0; long blockrate = 0; long phyDamage = 0; long magDamage = 0; hitrate = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "hitrate"); critrate = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "critrate"); blockrate = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "blockrate"); long rnd = Helper.Random.Next(); long critonoff = 0; long blockonoff = 0; if (rnd <= critrate) { critonoff = 1; } else if (rnd > critrate && rnd <= critrate + blockrate) { blockonoff = 1; } impactInfo.DamageData.IsCritical = critonoff > 0; impactInfo.DamageData.IsBlock = blockonoff > 0; phyDamage = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "phydamage", multiple, damage, critonoff, blockonoff); magDamage = AttrCalculator.Calc(targetObj.SceneContext, impactInfo.SenderProperty, targetObj.ActualProperty, "magdamage", multiple, damage, critonoff, blockonoff); damage = (int)(phyDamage + magDamage); if (damage < 0) { damage = 0; } int vampire = impactInfo.DamageData.GetVampire(index); bool isKiller = false; if (targetObj.Shield >= damage) { targetObj.Shield -= (int)damage; } else if (targetObj.Shield > 0) { int leftDamage = (int)damage - targetObj.Shield; targetObj.Shield = 0; if (targetObj.GetId() == PluginFramework.Instance.LeaderID && targetObj.Hp <= leftDamage) { //队长不死,demo专用代码 } else { targetObj.Hp -= (int)leftDamage; if (targetObj.Hp <= 0) { isKiller = true; } } } else { if (targetObj.GetId() == PluginFramework.Instance.LeaderID && targetObj.Hp <= damage) { //队长不死,demo专用代码 } else { targetObj.Hp -= (int)damage; if (targetObj.Hp <= 0) { isKiller = true; } } } if (isKiller) { targetObj.GetCombatStatisticInfo().AddDeadCount(1); if (null != srcObj) { EntityInfo killer = srcObj; if (killer.SummonerId > 0) { EntityViewModel npcViewModel = GetEntityViewById(killer.SummonerId); if (null != npcViewModel) { killer = npcViewModel.Entity; } } if (targetObj.EntityType == (int)EntityTypeEnum.Tower) { killer.GetCombatStatisticInfo().AddKillTowerCount(1); } else if (targetObj.EntityType == (int)EntityTypeEnum.Hero) { killer.GetCombatStatisticInfo().AddKillHeroCount(1); killer.GetCombatStatisticInfo().AddMultiKillCount(1); } else { killer.GetCombatStatisticInfo().AddKillNpcCount(1); } } } targetObj.SetAttackerInfo(srcObjId, isKiller, true, false, (int)damage, 0); } } } }
private static void AiStopPursue(EntityInfo npc) { EntityViewModel npcView = EntityViewModelManager.Instance.GetEntityViewById(npc.GetId()); npcView.StopMove(); }
private static void AiPursue(EntityInfo npc, ScriptRuntime.Vector3 target) { EntityViewModel npcView = EntityViewModelManager.Instance.GetEntityViewById(npc.GetId()); npcView.MoveTo(target.X, target.Y, target.Z); }
private void OnAiStopPursue(EntityInfo entity) { EntityViewModel npcView = EntityViewModelManager.Instance.GetEntityViewById(entity.GetId()); npcView.StopMove(); }
public ImpactInfo SendImpact(TableConfig.Skill cfg, int seq, int curObjId, int srcObjId, int targetId, int impactId, bool isFinal, Dictionary <string, object> args) { EntityViewModel view = GetEntityViewById(targetId); if (null != view && null != view.Entity && null != view.Actor && !view.Entity.IsDeadSkillCasting()) { EntityInfo npc = view.Entity; if (null != cfg) { UnityEngine.Quaternion hitEffectRotation = UnityEngine.Quaternion.identity; UnityEngine.GameObject srcObj = GetGameObject(srcObjId); UnityEngine.GameObject targetObj = view.Actor; if (null != srcObj && null != targetObj) { hitEffectRotation = srcObj.transform.localRotation; } var addArgs = new Dictionary <string, object> { { "hitEffectRotation", hitEffectRotation } }; ImpactInfo impactInfo = null; if (impactId <= 0 || impactId >= SkillInstance.c_FirstInnerHitSkillId) { impactInfo = new ImpactInfo(PredefinedSkill.Instance.HitSkillCfg); impactId = PredefinedSkill.c_HitSkillId; } else { impactInfo = new ImpactInfo(impactId); } if (null != impactInfo.ConfigData) { if (TryInitImpactInfo(impactInfo, cfg, seq, curObjId, srcObjId, args)) { if (impactInfo.ConfigData.type == (int)SkillOrImpactType.Buff) { ImpactInfo oldImpactInfo = npc.GetSkillStateInfo().FindImpactInfoById(impactInfo.ImpactId); if (null != oldImpactInfo) { oldImpactInfo.DurationTime += impactInfo.DurationTime; return(oldImpactInfo); } } impactInfo.DamageData.IsFinal = isFinal; npc.GetSkillStateInfo().AddImpact(impactInfo); SkillInfo skillInfo = npc.GetSkillStateInfo().GetCurSkillInfo(); if (null != skillInfo && cfg.skillData.isInterrupt) { GfxSkillSystem.Instance.StopSkill(targetId, skillInfo.SkillId, 0, true); } GfxSkillSystem.Instance.StartSkill(targetId, impactInfo.ConfigData, impactInfo.Seq, args, addArgs); return(impactInfo); } } else { LogSystem.Error("impact {0} config can't found !", impactInfo.ImpactId); } } } return(null); }
private void OnDeadNotify(EntityInfo npc) { EntityViewModel view = EntityController.Instance.GetEntityViewById(npc.GetId()); view.Death(); }
internal void ImpactDamage(int srcObjId, int targetId, int impactId, int seq, bool isFinal) { if (ClientModule.Instance.IsRoomScene) { return; } EntityViewModel view = GetEntityViewById(targetId); EntityViewModel srcView = GetEntityViewById(srcObjId); if (null != view && null != view.Entity && null != view.Actor) { EntityInfo entity = view.Entity; EntityInfo srcNpc = null; if (null != srcView && null != srcView.Entity) { srcNpc = srcView.Entity; } ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq); if (null != impactInfo && impactId == impactInfo.ImpactId) { TableConfig.Skill cfg = impactInfo.ConfigData; int targetType = impactInfo.TargetType; float damage = impactInfo.DamageData.Damage; int addShield = impactInfo.DamageData.AddShield; int hpRecover = impactInfo.DamageData.HpRecover; if (hpRecover != 0) { entity.SetHp(Operate_Type.OT_Relative, (int)impactInfo.DamageData.HpRecover); entity.SetAttackerInfo(srcObjId, false, true, false, -impactInfo.DamageData.HpRecover, 0); } if (addShield != 0) { entity.SetShield(Operate_Type.OT_Relative, impactInfo.DamageData.AddShield); } if ((targetType == (int)SkillTargetType.Enemy || targetType == (int)SkillTargetType.RandEnemy) && damage != 0) { if (entity.EntityType == (int)EntityTypeEnum.Tower) { if (null != srcNpc && srcNpc.NormalSkillId != impactInfo.SkillId) { //技能打塔不产生伤害 return; } } bool isKiller = false; if (entity.Shield >= damage) { entity.SetShield(Operate_Type.OT_Relative, -(int)damage); } else if (entity.Shield > 0) { int leftDamage = (int)damage - entity.Shield; entity.SetShield(Operate_Type.OT_Absolute, 0); if (entity.GetId() == ClientModule.Instance.LeaderID && entity.Hp <= leftDamage) { //队长不死,demo专用代码 } else { entity.SetHp(Operate_Type.OT_Relative, -(int)leftDamage); if (entity.Hp <= 0) { isKiller = true; } } } else { if (entity.GetId() == ClientModule.Instance.LeaderID && entity.Hp <= damage) { //队长不死,demo专用代码 } else { entity.SetHp(Operate_Type.OT_Relative, -(int)damage); if (entity.Hp <= 0) { isKiller = true; } } } if (isKiller) { entity.GetCombatStatisticInfo().AddDeadCount(1); if (null != srcNpc) { EntityInfo killer = srcNpc; if (killer.SummonerId > 0) { EntityViewModel npcViewModel = GetEntityViewById(killer.SummonerId); if (null != npcViewModel) { killer = npcViewModel.Entity; } } if (entity.EntityType == (int)EntityTypeEnum.Tower) { killer.GetCombatStatisticInfo().AddKillTowerCount(1); } else if (entity.EntityType == (int)EntityTypeEnum.Hero) { killer.GetCombatStatisticInfo().AddKillHeroCount(1); killer.GetCombatStatisticInfo().AddMultiKillCount(1); } else { killer.GetCombatStatisticInfo().AddKillNpcCount(1); } } } entity.SetAttackerInfo(srcObjId, isKiller, true, false, (int)damage, 0); } } } }