internal void EnterScene(User newUser) { Msg_LR_RoomUserInfo lobbyUserData = newUser.LobbyUserData; if (null == lobbyUserData) { return; } TableConfig.Actor cfg = TableConfig.ActorProvider.Instance.GetActor(lobbyUserData.Hero); EntityInfo info = m_EntityMgr.AddEntity(0, lobbyUserData.Camp, cfg, (int)AiStateLogicId.Entity_Leader); info.SetUnitId(EntityInfo.c_StartUserUnitId + info.GetId()); info.GetMovementStateInfo().FormationIndex = 0; if (null != m_SceneConfig) { info.GetMovementStateInfo().SetPosition2D(m_SceneConfig.EnterX + (Helper.Random.NextFloat() - 0.5f) * m_SceneConfig.EnterRadius, m_SceneConfig.EnterY + (Helper.Random.NextFloat() - 0.5f) * m_SceneConfig.EnterRadius); } newUser.Info = info; AttrCalculator.Calc(info); if (newUser.HaveHpArmor) { info.SetHp(Operate_Type.OT_Absolute, newUser.Hp); info.SetEnergy(Operate_Type.OT_Absolute, newUser.Energy); } else { info.SetHp(Operate_Type.OT_Absolute, newUser.Info.GetActualProperty().HpMax); info.SetEnergy(Operate_Type.OT_Absolute, newUser.Info.GetActualProperty().EnergyMax); } info.SceneContext = m_SceneContext; AddCareList(info); if (newUser.IsEntered) { m_StorySystem.SendMessage("user_enter_scene", info.GetId(), info.GetUnitId(), info.GetCampId(), info.GetMovementStateInfo().PositionX, info.GetMovementStateInfo().PositionZ); } }
protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime) { if (entity.IsDead()) { if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle) { NotifyAiStopPursue(entity); ChangeToState(entity, (int)AiStateId.Idle); } return false; } if (IsLeaderDead(entity)) { entity.SetHp(Operate_Type.OT_Absolute, 0); return false; } return true; }
protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime) { if (entity.IsDead()) { if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle) { NotifyAiStopPursue(entity); ChangeToState(entity, (int)AiStateId.Idle); } return(false); } if (IsLeaderDead(entity)) { entity.SetHp(Operate_Type.OT_Absolute, 0); return(false); } return(true); }
private void TickEntities() { m_DeletedEntities.Clear(); for (LinkedListNode <EntityInfo> linkNode = m_EntityMgr.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) { EntityInfo info = linkNode.Value; info.RetireAttackerInfos(60000); if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged) { AttrCalculator.Calc(info); info.LevelChanged = false; info.GetSkillStateInfo().BuffChanged = false; } if (info.IsBorning) { if (info.BornTime <= 0) { SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId); if (info.BornSkillId > 0 && null != skillInfo) { info.BornTime = TimeUtility.GetLocalMilliseconds(); m_SkillSystem.StartSkill(info.GetId(), skillInfo.ConfigData, 0); } else { info.IsBorning = false; info.BornTime = 0; info.SetAIEnable(true); info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible); } } else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds()) { info.IsBorning = false; info.BornTime = 0; info.SetAIEnable(true); info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible); } } if (info.IsDead() && !info.NeedDelete) { if (info.DeadTime <= 0) { CalcKillIncome(info); //发送npc死亡消息 Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead(); npcDeadBuilder.npc_id = info.GetId(); NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder); SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId); if (info.DeadSkillId > 0 && null != skillInfo) { info.DeadTime = TimeUtility.GetLocalMilliseconds(); m_SkillSystem.StopAllSkill(info.GetId(), true, false, true); m_SkillSystem.StartSkill(info.GetId(), skillInfo.ConfigData, 0); OnEntityKilled(info); } else { if (null == info.CustomData as User) { info.DeadTime = 0; info.NeedDelete = true; OnEntityKilled(info); } else { info.DeadTime = TimeUtility.GetLocalMilliseconds(); } } } else { if (null == info.CustomData as User && info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds()) { info.DeadTime = 0; info.NeedDelete = true; //重新发送npc死亡消息 Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead(); npcDeadBuilder.npc_id = info.GetId(); NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder); } else if (null != info.CustomData as User && info.DeadTime + info.ReliveTimeout < TimeUtility.GetLocalMilliseconds()) { info.DeadTime = 0; info.SetHp(Operate_Type.OT_Absolute, info.GetActualProperty().HpMax); info.SetEnergy(Operate_Type.OT_Absolute, info.GetActualProperty().EnergyMax); Msg_RC_SyncProperty npcProp = DataSyncUtility.BuildSyncPropertyMessage(info); NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, npcProp); } } } if (info.NeedDelete) { m_DeletedEntities.Add(info); } } if (m_DeletedEntities.Count > 0) { int enemyCt = 0; int friendCt = 0; Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc(); for (int i = 0; i < m_DeletedEntities.Count; ++i) { EntityInfo ni = m_DeletedEntities[i]; if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId())) { ++enemyCt; } else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId())) { ++friendCt; } //发送npc消失消息 destroyNpcBuilder.npc_id = ni.GetId(); NotifyAllUser(RoomMessageDefine.Msg_RC_DestroyNpc, destroyNpcBuilder); DestroyEntity(ni); } TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0); } m_EntityMgr.ExecuteDelayAdd(); }
internal void ImpactDamage(int srcObjId, int targetId, int impactId, int seq) { EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId); EntityInfo srcObj = m_Scene.EntityManager.GetEntityInfo(srcObjId); if (null != targetObj && !targetObj.IsDead()) { ImpactInfo impactInfo = targetObj.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) { targetObj.SetHp(Operate_Type.OT_Relative, (int)impactInfo.DamageData.HpRecover); targetObj.SetAttackerInfo(srcObjId, false, true, false, -impactInfo.DamageData.HpRecover, 0); } if (addShield != 0) { targetObj.SetShield(Operate_Type.OT_Relative, impactInfo.DamageData.AddShield); } if ((targetType == (int)SkillTargetType.Enemy || targetType == (int)SkillTargetType.RandEnemy) && damage != 0) { if (targetObj.EntityType == (int)EntityTypeEnum.Tower) { if (null != srcObj && srcObj.NormalSkillId != impactInfo.SkillId) { //技能打塔不产生伤害 return; } } bool isKiller = false; if (targetObj.Shield >= damage) { targetObj.SetShield(Operate_Type.OT_Relative, -(int)damage); } else if (targetObj.Shield > 0) { int leftDamage = (int)damage - targetObj.Shield; targetObj.SetShield(Operate_Type.OT_Absolute, 0); targetObj.SetHp(Operate_Type.OT_Relative, -(int)leftDamage); if (targetObj.Hp <= 0) { isKiller = true; } } else { targetObj.SetHp(Operate_Type.OT_Relative, -(int)damage); if (targetObj.Hp <= 0) { isKiller = true; } } if (isKiller) { targetObj.GetCombatStatisticInfo().AddDeadCount(1); if (null != srcObj) { EntityInfo killer = srcObj; if (killer.SummonerId > 0) { killer = m_Scene.EntityManager.GetEntityInfo(killer.SummonerId); } 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); } } } }
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); } } } }