public override int OnExplode(int player_id, int parentNetworkId, int damage) { Log.Information($"OnExplode SButton {NetworkId}, {mapObjectId}, {damage}"); if (mapData.jMapSwitchData[0].coolTime > 0) { if (World.Instance(WorldId).GetNetGameObject(GameObjectClassId.PropCooldown, GetMapId()) != null) { Log.Information($"button cooldown... {GetMapId()}"); return(0); } } bool isDie = false; if (mapData.objectHP != 0) { PropHealth propHealth = (PropHealth)World.Instance(WorldId).GetNetGameObject(GameObjectClassId.PropHealth, mapObjectId); if (propHealth != null) { if (propHealth.mHealth == 0) { // 이미 hp가 0이면 이후 처리 하지 않는다. } else if (propHealth.OnExplode(player_id, parentNetworkId, damage) == 0) { isDie = true; // 스위치 오브젝트를 제거하면 이후 상태를 알수 없어서 스페셜 오브젝트 처리가 불가하다. //SetDoesWantToDie(true); } } } else { isDie = true; } if (isDie) { //SetDoesWantToDie(true); // 버튼(스위치) 상태 변경 mOnOff = !mOnOff; NetworkManagerServer.sInstance.SetStateDirty(GetNetworkId(), WorldId, (uint)ReplicationState.OnOff); if (mapData.objectHP != 0) { // hp가 있는 경우 쿨타임 적용하지 않는다. } else if (mapData.jMapSwitchData[0].coolTime > 0) { //set cooldown PropCooldown cooldown = (PropCooldown)GameObjectRegistry.sInstance.CreateGameObject((uint)GameObjectClassId.PropCooldown, true, WorldId); cooldown.InitFrom(GetMapId()); } } return(0); }
public override void TeleportServer(int map_uid) { if (StateServerSide != ActorState.Idle) { //Log.Information($"TeleportServer wrong state {StateServerSide}, networkID{GetNetworkId()}"); return; } JMapObjectData mapData; if (World.mapGameObject.TryGetValue(map_uid, out mapData) == false) { Debug.Log($"cannot find map object {map_uid}"); return; } var pos = mapData.jumpLandingPos; pos.y += 1; var duration = mapData.jumpDuration; var power = mapData.jumpPower; //Log.Information("TeleportServer old location {0} new location {1}", GetLocation(), pos); if (StateServerSide == ActorState.Teleport) { Log.Information($"already teleport pos {pos.ToString()}"); return; } // check cooldown if (World.Instance(WorldId).GetNetGameObject(GameObjectClassId.PropCooldown, map_uid) != null) { Log.Information($"cooldown... {map_uid}"); return; } mActorStateMachine.ChangeState(this, mActorStateMachine.UpdateTeleport, ActorState.Teleport, duration); TargetPos = pos; JumpPower = power; JumpDuration = duration; Vector2 direction = new Vector2(pos.x - GetLocation().x, pos.z - GetLocation().z); degree = direction.Angle(); lastVelocity = new Vector3(direction.x, 0, direction.y) * 0.1f; LogHelper.LogInfo($"start teleport pos {pos.ToString()}, power{power}, duration{duration}, degree{degree}, direction{direction}"); // 이후 인풋값은 무시 IsIgnoreInput = true; //set cooldown PropCooldown cooldown = (PropCooldown)GameObjectRegistry.sInstance.CreateGameObject((uint)GameObjectClassId.PropCooldown, true, WorldId); cooldown.InitFrom(map_uid); //InvokeClientRpc(TeleportClient, World.Instance(WorldId).playerList.Keys.ToList(), pos, power, duration); }