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; } } } }
void OnDeath(SkillSystem.SkEntity skEntity1, SkillSystem.SkEntity skEntity2) { MonsterProtoDb.Item protoItem = MonsterProtoDb.Get(Entity.ProtoID); if (protoItem != null && protoItem.deathAudioID > 0) { AudioManager.instance.Create(transform.position, protoItem.deathAudioID); } }
public override void Start() { base.Start(); if (Entity.Race == ERace.Monster && Entity.Field != MovementField.water) { MonsterProtoDb.Item item = MonsterProtoDb.Get(Entity.ProtoID); if (item != null && item.idleSounds != null && item.idleSounds.Length > 0) { StartCoroutine(IdleAudio(item.idleSounds, item.idleSoundDis)); } } }
public static bool CheckPos(out Vector3 outPutPos, Vector3 curPos, SpawnPoint point, MonsterSpawnArea area) { outPutPos = curPos; MonsterProtoDb.Item protoItem = MonsterProtoDb.Get(point.Prototype); bool pass = false; if (protoItem.movementField == MovementField.Land) { pass = CheckOnLand(out outPutPos, curPos, point, area); } else if (protoItem.movementField == MovementField.Sky) { pass = CheckOnSky(out outPutPos, curPos, point, area); } else if (protoItem.movementField == MovementField.water) { pass = CheckInWater(out outPutPos, curPos, point, area); } else if (protoItem.movementField == MovementField.Amphibian) { pass = CheckOnLand(out outPutPos, curPos, point, area); if (!pass) { pass = CheckInWater(out outPutPos, curPos, point, area); } } else if (protoItem.movementField == MovementField.All) { pass = CheckOnLand(out outPutPos, curPos, point, area); if (!pass) { pass = CheckOnSky(out outPutPos, curPos, point, area); } if (!pass) { pass = CheckInWater(out outPutPos, curPos, point, area); } } return(pass); }
public static void OnMonsterDeath(SkEntity cur, SkEntity caster) { caster = PETools.PEUtil.GetCaster(caster); SkAliveEntity curAlive = cur as SkAliveEntity; SkAliveEntity casAlive = caster as SkAliveEntity; if (curAlive != null && casAlive != null) { int curPlayerID = Mathf.RoundToInt(curAlive.GetAttribute(AttribType.DefaultPlayerID)); if (ReputationSystem.IsReputationTarget(curPlayerID)) { int casPlayerID = Mathf.RoundToInt(casAlive.GetAttribute(AttribType.DefaultPlayerID)); int casLvl = (int)ReputationSystem.Instance.GetReputationLevel(casPlayerID, curPlayerID); //operate value depend the one be killed //lz-2017.05.08 冒险模式如果声望等级大于Cold的时候,攻击一下直接掉为Cold if (PeGameMgr.IsAdventure && casLvl > (int)ReputationSystem.ReputationLevel.Cold) { int targetLvl = (int)ReputationSystem.ReputationLevel.Cold; int reduceValue = 0; for (int i = targetLvl; i < casLvl; i++) { reduceValue -= ReputationSystem.GetLevelThreshold((ReputationSystem.ReputationLevel)i); } ReputationSystem.Instance.ChangeReputationValue(casPlayerID, curPlayerID, reduceValue, true); } else { MonsterProtoDb.Item protoItem = MonsterProtoDb.Get(curAlive.Entity.entityProto.protoId); RepVal repVal; if (protoItem != null && s_dicRepVals.TryGetValue(protoItem.repValId, out repVal)) { int reduceValue = (int)(repVal._vals[casLvl] * ReputationSystem.ChangeValueProportion); //reduceValue = addvalue * ChangeValueProportion; ReputationSystem.Instance.ChangeReputationValue(casPlayerID, curPlayerID, reduceValue, true); // reudce self no mater other side would be add; } } } } }
void ApplyBeenHitSound(Transform trans) { if (!Entity.IsDeath()) { switch (Entity.proto) { case EEntityProto.Monster: MonsterProtoDb.Item monsterProto = MonsterProtoDb.Get(Entity.ProtoID); if (monsterProto.beHitSound[0] > 0 && Time.time - m_LastHitSoundTime >= monsterProto.beHitSound[monsterProto.beHitSound.Length - 1]) { m_LastHitSoundTime = Time.time; Vector3 pos = (null != trans)?trans.position:Entity.position; AudioManager.instance.Create(pos, monsterProto.beHitSound[0]); } break; case EEntityProto.Player: case EEntityProto.Npc: PlayMaleAudio(); break; } } }
// public override void OnPeMsg(EMsg msg, params object[] args) // { // switch (msg) // { // case EMsg.Lod_Collider_Destroying: // canGetAuth = false; // lastAuthId = authId; // if (hasOwnerAuth) // { //#if UNITY_EDITOR // Debug.LogFormat("<color=blue>you lost [{0}]'s authority.</color>", Id); //#endif // authId = -1; // RPCServer(EPacketType.PT_InGame_LostController); // } // ResetContorller(); // break; // case EMsg.Lod_Collider_Created: // canGetAuth = true; // if (!hasAuth) // { // RPCServer(EPacketType.PT_InGame_SetController); // } // else // { // ResetContorller(); //#if UNITY_EDITOR // PlayerNetwork p = PlayerNetwork.GetPlayer(authId); // if (null != p) // Debug.LogFormat("<color=blue>{0} got [{1}]'s authority.</color>", p.RoleName, Id); //#endif // } // break; // } // } internal void CreateAi() { _entity = PeEntityCreator.Instance.CreateMonsterNet(Id, ExternId, Vector3.zero, Quaternion.identity, Vector3.one, Scale, _buffId); if (null == _entity) { return; } if (_fixId != -1) { SceneEntityCreatorArchiver.Instance.SetEntityByFixedSpId(_fixId, _entity); // if (_entity.monster) _entity.monster.Ride(false); } _entity.monster.Ride(_canride); _viewTrans = _entity.GetCmpt <PeTrans>(); if (null == _viewTrans) { Debug.LogError("entity has no ViewCmpt"); return; } _viewTrans.position = transform.position; _move = _entity.GetCmpt <Motion_Move>(); NetCmpt net = _entity.GetCmpt <NetCmpt>(); if (null == net) { net = _entity.Add <NetCmpt>(); } net.network = this; MonsterProtoDb.Item data = MonsterProtoDb.Get(ExternId); if (null == data) { gameObject.name = string.Format("TemplateId:{0}, Id:{1}", ExternId, Id); } else { gameObject.name = string.Format("{0}, TemplateId:{1}, Id:{2}", data.name, ExternId, Id); } if (-1 != _groupId) { AIGroupNetWork.OnMonsterAdd(_groupId, this, _entity); } if (-1 != _tdId) { AiTowerDefense.OnMonsterAdd(_tdId, this, _entity); if (_entity.monster) { _entity.monster.Ride(false); } } if (-1 != _dungeonId) { _entity.SetAttribute(AttribType.CampID, DungeonMonster.CAMP_ID); _entity.SetAttribute(AttribType.DamageID, DungeonMonster.DAMAGE_ID); if (_entity.monster) { _entity.monster.Ride(false); } } if (-1 != _colorType) { PeEntityCreator.InitMonsterSkinRandomNet(_entity, _colorType); } if (-1 != _playerId) { _entity.SetAttribute(AttribType.DefaultPlayerID, _playerId); } OnSpawned(_entity.GetGameObject()); if (_entity.Race == ERace.Mankind && _entity.proto == EEntityProto.Monster) { _move.AddNetTransInfo(transform.position, rot.eulerAngles, _move.speed, GameTime.Timer.Second); } else { _move.NetMoveTo(transform.position, Vector3.zero); } // if (_move is Motion_Move_Motor) //(_move as Motion_Move_Motor).NetMoveTo( transform.position,Vector3.zero); }
public static void CreateMonster(SceneEntityPosAgent agent) // treat proid as type in monsterBesiegeSpawn { agent.entity = null; // Compute agent.protoId EntityGrp grp; EntityMonsterBeacon bcn; float exScale = -1.0f; int colorType = -1; int playerId = -1; int buffId = 0; if (!ParseAgentInfo(agent, out grp, out bcn, ref exScale, ref colorType, ref playerId, ref buffId)) { return; } if (NetworkInterface.IsClient) { NetworkManager.WaitCoroutine(PlayerNetwork.RequestCreateAi(agent.protoId, agent.Pos, null == grp ? -1 : grp.Id, null == bcn ? -1 : bcn.Id, -1, colorType, playerId, buffId)); return; } // If grp need network sync, put this statement down if ((agent.protoId & EntityProto.IdGrpMask) != 0) { agent.entity = EntityGrp.CreateMonsterGroup(agent.protoId & ~EntityProto.IdGrpMask, agent.Pos, colorType, playerId, -1, buffId); return; } Vector3 pos = new Vector3(agent.Pos.x, agent.Pos.y, agent.Pos.z); MonsterProtoDb.Item protoData = MonsterProtoDb.Get(agent.protoId); if (protoData != null && bcn == null && !agent.FixPos) // exclude fixpos { float hOffset = protoData.hOffset; if (hOffset < 0.0f) { float depth = VFVoxelWater.self.UpToWaterSurface(agent.Pos.x, agent.Pos.y, agent.Pos.z); if (depth <= 0) { Debug.LogError("[SceneEntityCreator]Failed to create water monster becasue not in water:" + agent.protoId); return; } pos.y += depth + hOffset; } else if (hOffset > 2.0f) { float depth = VFVoxelWater.self.UpToWaterSurface(agent.Pos.x, agent.Pos.y, agent.Pos.z); if (depth <= 0) { RaycastHit hitinfo; float rayLen = 128.0f; if (Physics.Raycast(pos + rayLen * Vector3.up, Vector3.down, out hitinfo, rayLen, SceneMan.DependenceLayer)) // avoid from birds genterating in cave { pos.y = hitinfo.point.y; } pos.y += hOffset; } else { pos.y += depth + hOffset; } } else { float depth = VFVoxelWater.self.UpToWaterSurface(agent.Pos.x, agent.Pos.y, agent.Pos.z); if (depth <= 0) { pos.y += hOffset; } else { Debug.LogError("[SceneEntityCreator]Failed to create land monster becasue in water:" + agent.protoId); return; } } } int id = Pathea.WorldInfoMgr.Instance.FetchNonRecordAutoId(); // not save agent.entity = PeEntityCreator.Instance.CreateMonster(id, agent.protoId, pos, agent.Rot, agent.Scl, exScale, colorType, buffId); if (null == agent.entity) { Debug.LogError("[SceneEntityCreator]Failed to create monster:" + agent.protoId); return; } agent.entity.monster.Ride(agent.canRide); //colorType,playerId //if(colorType>=0) // PeEntityCreator.InitMonsterSkinRandom(agent.entity,colorType); if (playerId >= 0) { agent.entity.SetAttribute(AttribType.DefaultPlayerID, playerId); } if (commonCreateEvent != null) { commonCreateEvent(agent.entity); } if (grp != null) { grp.OnMemberCreated(agent.entity); } if (bcn != null) { bcn.OnMonsterCreated(agent.entity); } return; }
//build outcol for can't be pushed entites void BuildOutCollider(GameObject obj) { if (null == monoModelCtrlr) { return; } List <Collider> selfCols = new List <Collider>(); List <Collider> outCols = new List <Collider>(); m_IsNPCOutCol = false; if (Entity.commonCmpt.entityProto.proto == EEntityProto.Monster) { MonsterProtoDb.Item monsterProto = MonsterProtoDb.Get(Entity.commonCmpt.entityProto.protoId); if (null == monsterProto || monsterProto.canBePush) { return; } } else if (Entity.commonCmpt.entityProto.proto != EEntityProto.Npc && Entity.commonCmpt.entityProto.proto != EEntityProto.Player && Entity.commonCmpt.entityProto.proto != EEntityProto.RandomNpc) { return; } else { m_IsNPCOutCol = true; } Collider[] colliders; if (null != monoModelCtrlr.colliders && monoModelCtrlr.colliders.Length > 0) { colliders = monoModelCtrlr.colliders; } else { colliders = monoModelCtrlr.GetComponentsInChildren <Collider>(true); } if (null == colliders) { Debug.LogError(name + " don't has cols."); return; } for (int i = 0; i < colliders.Length; ++i) { if (colliders[i] == null) { Debug.LogError("[BView]Colliders have empty element:" + name); continue; } if (!colliders[i].isTrigger) { Collider addCol = null; GameObject newObj = new GameObject("OutCollider" + i); newObj.layer = Layer.ShowModel; newObj.transform.parent = obj.transform; newObj.transform.localScale = Vector3.one; PEFollowSimple follow = newObj.AddComponent <PEFollowSimple>(); follow.master = colliders[i].transform; if (colliders[i] is BoxCollider) { BoxCollider modelCol = colliders[i] as BoxCollider; BoxCollider newCol = newObj.AddComponent <BoxCollider>(); addCol = newCol; newCol.center = modelCol.center; newCol.size = modelCol.size + 0.2f * Vector3.one; } else if (colliders[i] is SphereCollider) { SphereCollider modelCol = colliders[i] as SphereCollider; SphereCollider newCol = newObj.AddComponent <SphereCollider>(); addCol = newCol; newCol.center = modelCol.center; newCol.radius = modelCol.radius + 0.1f; } else if (colliders[i] is CapsuleCollider) { CapsuleCollider modelCol = colliders[i] as CapsuleCollider; CapsuleCollider newCol = newObj.AddComponent <CapsuleCollider>(); addCol = newCol; newCol.center = modelCol.center; newCol.radius = modelCol.radius + 0.1f; newCol.height = modelCol.height + 0.2f; newCol.direction = modelCol.direction; } if (m_IsNPCOutCol) { g_NPCOutColliders.Add(addCol); g_NPCModelColliders.Add(colliders[i]); } selfCols.Add(colliders[i]); outCols.Add(addCol); } } m_SelfCols = selfCols.ToArray(); m_OutCols = outCols.ToArray(); selfCols.Clear(); outCols.Clear(); selfCols = null; outCols = null; ResetOutCollider(); }
string GetModelName() { MonsterProtoDb.Item item = MonsterProtoDb.Get(Entity.ProtoID); return(item != null ? item.modelName : null); }
public void OnDeathProcessBuff(SkEntity cur, SkEntity caster) { if (caster == null || cur == null) { return; } SkAliveEntity killer = caster as SkAliveEntity; if (killer == null) { if (caster is SkProjectile) { killer = (caster as SkProjectile).GetSkEntityCaster() as SkAliveEntity; } if (killer == null) { return; } } SkAliveEntity victem = cur as SkAliveEntity; if (victem == null) { return; } MonsterProtoDb.Item protoItem = MonsterProtoDb.Get(victem.Entity.entityProto.protoId); if (protoItem == null || protoItem.deathBuff.Length == 0) { return; } if (killer.Entity.NpcCmpt != null) { if (killer.Entity.NpcCmpt.Master != null && killer.Entity.NpcCmpt.Master.Entity != null && killer.Entity.NpcCmpt.Master.Entity.aliveEntity != null) { killer = killer.Entity.NpcCmpt.Master.Entity.aliveEntity; } } if (PeGameMgr.IsMulti) { if (killer.IsController()) { string[] args1 = protoItem.deathBuff.Split(','); int buffid = Convert.ToInt32(args1[0]); List <int> atrtype = new List <int>(); List <float> atrvalue = new List <float>(); for (int i = 1; i < args1.Length; i = i + 2) { atrtype.Add(Convert.ToInt32(args1[i])); atrvalue.Add(Convert.ToSingle(args1[i + 1])); } if (atrtype.Count > 0 && atrvalue.Count > 0) { //remove old buff SkEntity.UnmountBuff(killer, buffid); //add buff SkEntity.MountBuff(killer, buffid, atrtype, atrvalue); } } } else { string[] args1 = protoItem.deathBuff.Split(','); int buffid = Convert.ToInt32(args1[0]); List <int> atrtype = new List <int>(); List <float> atrvalue = new List <float>(); for (int i = 1; i < args1.Length; i = i + 2) { atrtype.Add(Convert.ToInt32(args1[i])); atrvalue.Add(Convert.ToSingle(args1[i + 1])); } if (atrtype.Count > 0 && atrvalue.Count > 0) { //remove old buff SkEntity.UnmountBuff(killer, buffid); //add buff SkEntity.MountBuff(killer, buffid, atrtype, atrvalue); } } victem.deathEvent -= OnDeathProcessBuff; }
public virtual void Deserialize(BinaryReader r) { if (!m_Init) { InitSkEntity(); } int readVersion = r.ReadInt32(); if (readVersion == 2) { _attribs.DisableNumAttribsEvent(); for (int i = 0; i < (int)AttribType.HPRecover; i++) { _attribs.sums[i] = _attribs.raws[i] = r.ReadSingle(); } _attribs.EnableNumAttribsEvent(); SetAttribute(AttribType.HPRecover, 0.01f); } else { _attribs.Deserialize(r); } if (1 == readVersion) { int buffLength = r.ReadInt32(); m_InitBuffList = new int[buffLength]; for (int i = 0; i < buffLength; i++) { m_InitBuffList[i] = r.ReadInt32(); } } EntityProto entityProto = Entity.entityProto; if (null != entityProto) { switch (entityProto.proto) { case EEntityProto.Monster: MonsterProtoDb.Item monsterPDB = MonsterProtoDb.Get(entityProto.protoId); if (null != monsterPDB) { m_InitBuffList = monsterPDB.initBuff; } break; case EEntityProto.Npc: NpcProtoDb.Item npcPDB = NpcProtoDb.Get(entityProto.protoId); if (null != npcPDB) { m_InitBuffList = npcPDB.InFeildBuff; } break; case EEntityProto.Player: PlayerProtoDb.Item playerPDB = PlayerProtoDb.Get(); if (null != playerPDB) { m_InitBuffList = playerPDB.initBuff; } break; case EEntityProto.RandomNpc: PlayerProtoDb.Item RnpcPDB = PlayerProtoDb.GetRandomNpc(); if (null != RnpcPDB) { m_InitBuffList = RnpcPDB.InFeildBuff; } break; } } }
void OnSetGoalItemContent(UIMissionGoalItem item) { MissionGoal mg = _goals[item.index]; if (!mg.achieved) { item.textColor = Color.white; } else { item.textColor = Color.green; } if (mg as MissionGoal_Bool != null) { MissionGoal_Bool mgb = mg as MissionGoal_Bool; item.SetBoolContent(mgb.text, mgb.achieved); } else if (mg as MissionGoal_Item != null) { MissionGoal_Item mgi = mg as MissionGoal_Item; string text = mgi.text + " " + mgi.current.ToString() + "/" + mgi.target.ToString(); item.value0 = mgi.current; item.value1 = mgi.target; if (mgi.item.isSpecificPrototype) { string[] sprites = ItemAsset.ItemProto.GetIconName(mgi.item.Id); if (sprites != null) { item.SetItemContent(text, sprites[0]); } else { item.SetItemContent(text); } } else { item.SetItemContent(text); } } else if (mg as MissionGoal_Kill != null) { MissionGoal_Kill mgk = mg as MissionGoal_Kill; string text = mgk.text + " " + mgk.current.ToString() + "/" + mgk.target.ToString(); MissionGoal_Kill mgi = mg as MissionGoal_Kill; item.value0 = mgi.current; item.value1 = mgi.target; if (item != null) { if (mgi.monster.isSpecificEntity) { SpawnPoint sp = PeCustomScene.Self.spawnData.GetSpawnPoint(mgi.id); if (sp as MonsterSpawnPoint != null) { MonsterProtoDb.Item proto = MonsterProtoDb.Get(sp.ID); item.SetItemContent(text, proto.icon); } else if (sp as NPCSpawnPoint != null) { NpcProtoDb.Item proto = NpcProtoDb.Get(sp.ID); item.SetItemContent(text, proto.icon); } else { item.SetItemContent(text); } } else if (mgi.monster.isSpecificPrototype) { MonsterProtoDb.Item proto = MonsterProtoDb.Get(mgi.monster.Id); if (proto != null) { item.SetItemContent(text, proto.icon); } else { item.SetItemContent(text); } } else { item.SetItemContent(text); } } else { item.SetItemContent(text); } } }
void OnMissionNodeClick(int type, UIMissionGoalNode node) { RefreshNodeSelected(); DetachGoalEvent(); MissionProperty mp = null; if (type == 0) { mp = PeCustomScene.Self.scenario.missionMgr.GetMissionProperty(m_MainStoryIds[node.index]); _currentGoals = PeCustomScene.Self.scenario.missionMgr.GetGoals(m_MainStoryIds[node.index]); if (_currentGoals != null) { _goals = _currentGoals.Values; } _currentMissionId = m_MainStoryIds[node.index]; } else if (type == 1) { mp = PeCustomScene.Self.scenario.missionMgr.GetMissionProperty(m_SideQuestIdes[node.index]); _currentGoals = PeCustomScene.Self.scenario.missionMgr.GetGoals(m_SideQuestIdes[node.index]); if (_currentGoals != null) { _goals = _currentGoals.Values; } _currentMissionId = m_SideQuestIdes[node.index]; } else { _currentMissionId = -1; _currentGoals = null; _goals = null; _rewardItemIds = null; _rewardItemCount = null; } if (mp != null) { // Begin Npc if (CustomGameData.Mgr.Instance != null && CustomGameData.Mgr.Instance.curGameData.WorldIndex == mp.beginNpcWorldIndex) { SpawnPoint sp = PeCustomScene.Self.spawnData.GetSpawnPoint(mp.beginNpcId); if (sp as NPCSpawnPoint != null) { NpcProtoDb.Item proto = NpcProtoDb.Get(sp.Prototype); missionWnd.SetMissionAbout(sp.Name, proto.iconBig, mp.objective); } else if (sp as MonsterSpawnPoint != null) { MonsterProtoDb.Item proto_mst = MonsterProtoDb.Get(sp.Prototype); missionWnd.SetMissionAbout(sp.Name, proto_mst.icon, mp.objective); } else { missionWnd.SetMissionAbout("None", "npc_big_Unknown", mp.objective); //Debug.LogWarning("The Npc Id [" + mp.beginNpcId.ToString() + "] spawn point is not exist"); } } else { missionWnd.SetMissionAbout("None", "npc_big_Unknown", mp.objective); } // End Npc if (CustomGameData.Mgr.Instance != null && CustomGameData.Mgr.Instance.curGameData.WorldIndex == mp.endNpcWorldIndex) { SpawnPoint sp = PeCustomScene.Self.spawnData.GetSpawnPoint(mp.endNpcId); if (sp as NPCSpawnPoint != null) { NpcProtoDb.Item proto = NpcProtoDb.Get(sp.Prototype); missionWnd.SetRewardInfo(sp.Name, proto.iconBig); } else if (sp as MonsterSpawnPoint != null) { MonsterProtoDb.Item proto_mst = MonsterProtoDb.Get(sp.Prototype); missionWnd.SetRewardInfo(sp.Name, proto_mst.icon); } else { missionWnd.SetRewardInfo("None", "npc_big_Unknown"); Debug.LogWarning("The Npc Id [" + mp.endNpcId.ToString() + "] spawn point is not exist"); } } else { missionWnd.SetRewardInfo("None", "npc_big_Unknown"); } // Reward if (mp.rewardDesc != null) { missionWnd.SetRewardDesc(mp.rewardDesc); } else { _rewardItemIds = mp.rewardItemIds; _rewardItemCount = mp.rewardItemCount; missionWnd.UpdateRewardItem(mp.rewardItemIds.Count); } } // goal if (_currentGoals != null) { AttachGoalEvent(); missionWnd.UpdateGoalItem(_currentGoals.Count); } }