public static void SetPlayerToUnitPosition(PlayerEntity player, UnitPosition up) { up.SetX(player.position.Value.x); up.SetY(player.position.Value.y); up.SetZ(player.position.Value.z); up.SetYaw(player.orientation.Yaw); up.SetPitch(player.orientation.Pitch); }
public static UnitPosition FromVector(Vector3 v) { UnitPosition tempPosition = new UnitPosition(); tempPosition.SetX(v.x); tempPosition.SetY(v.y); tempPosition.SetZ(v.z); return(tempPosition); }
public override UnitPosition Select(IEventArgs args) { UnitPosition up = new UnitPosition(); up.SetX(FreeUtil.ReplaceFloat(x, args)); up.SetY(FreeUtil.ReplaceFloat(y, args)); up.SetZ(FreeUtil.ReplaceFloat(z, args)); up.SetYaw(FreeUtil.ReplaceFloat(yaw, args)); up.SetPitch(FreeUtil.ReplaceFloat(pitch, args)); return(up); }
private void RealEat(PlayerEntity player, ISkillArgs skill) { if (!this.disable && (bufCondition == null || bufCondition.Meet(skill))) { ShowEffect(skill, player); skill.TempUse("buf", this); if (creator != null) { skill.TempUse("creator", (FreeData)this.creator.freeData.FreeData); } pos.SetX(player.position.Value.x); pos.SetY(player.position.Value.y); pos.SetZ(player.position.Value.z); if (region.In(skill, pos)) { if (!ins.Contains(player.playerInfo.PlayerId)) { if (enterAction != null) { enterAction.Act(skill); } ins.Add(player.playerInfo.PlayerId); } if (trigger == null || trigger.Triggered(skill) == ISkillTrigger.TriggerStatus.Success) { if (eatAction != null) { eatAction.Act(skill); if (consume) { skill.FreeContext.Bufs.RemoveBuf(skill, this.realKey); } } } } else { if (ins.Contains(player.playerInfo.PlayerId)) { if (leaveAction != null) { leaveAction.Act(skill); } ins.Remove(player.playerInfo.PlayerId); } } if (creator != null) { skill.Resume("creator"); } skill.Resume("buf"); } }
// 一个位置向另外一个位置移动一段距离后的点位置, 修改from的值 public static void Move(UnitPosition from, UnitPosition target, float dis) { Vector3 v = new Vector3(target.GetX() - from.GetX(), target.GetY() - from.GetY(), target.GetZ() - from.GetZ()); if (v.magnitude != 0) { float scale = dis / v.magnitude; from.SetX(from.GetX() + v.x * scale); from.SetY(from.GetY() + v.y * scale); from.SetZ(from.GetZ() + v.z * scale); } }
public override UnitPosition Select(IEventArgs args) { UnitPosition up = new UnitPosition(); up.SetX(FreeUtil.ReplaceFloat(x, args)); up.SetY(FreeUtil.ReplaceFloat(y, args)); up.SetZ(FreeUtil.ReplaceFloat(z, args)); up.SetYaw(FreeUtil.ReplaceFloat(yaw, args)); up.SetPitch(FreeUtil.ReplaceFloat(pitch, args)); up.SetInvalid(FreeUtil.ReplaceBool(invalid, args)); up.SetRandomindex(FreeUtil.ReplaceInt(randomindex, args)); return(up); }
protected UnitPosition GetEntityPosition(FreeMoveEntity entity) { if (_entityPosition == null) { _entityPosition = new UnitPosition(); } _entityPosition.SetX(entity.position.Value.x); _entityPosition.SetY(entity.position.Value.y); _entityPosition.SetZ(entity.position.Value.z); return(_entityPosition); }
private void Adjust(UnitPosition up, IEventArgs args) { up.SetX(up.GetX() + FreeUtil.ReplaceInt(x, args)); up.SetY(up.GetY() + FreeUtil.ReplaceInt(y, args)); up.SetZ(up.GetZ() + FreeUtil.ReplaceInt(z, args)); if (!StringUtil.IsNullOrEmpty(pitch)) { up.SetPitch(FreeUtil.ReplaceFloat(pitch, args)); } if (!StringUtil.IsNullOrEmpty(yaw)) { up.SetYaw(FreeUtil.ReplaceFloat(yaw, args)); } }
private UnitPosition GetPosition(IEventArgs args, UnitPosition old, double angle) { Vector3 dir = new Vector3(); Vector3 end = new Vector3(); AnglesToVector(angle, FreeUtil.ReplaceFloat(pitch, args), ref dir); Vector3DMA(new Vector3(old.GetX(), old.GetY(), old.GetZ()), FreeUtil.ReplaceFloat(distance, args), dir, ref end); UnitPosition up = new UnitPosition(); up.SetX(end.x); up.SetY(end.y + FreeUtil.ReplaceFloat(height, args)); up.SetZ(end.z); up.SetYaw(old.GetYaw()); return(up); }
public static UnitPosition GetAnglePosition(UnitPosition old, double angle, float pitch, float distance, float height) { Vector3 dir = new Vector3(); Vector3 end = new Vector3(); AnglesToVector(angle, pitch, ref dir); Vector3DMA(new Vector3(old.GetX(), old.GetY(), old.GetZ()), distance, dir, ref end); UnitPosition up = new UnitPosition(); up.SetX(end.x); up.SetY(end.y + height); up.SetZ(end.z); up.SetYaw(old.GetYaw()); return(up); }
public override UnitPosition GetCenter(IEventArgs arg1) { foreach (MapConfigPoints.ID_Point p in MapConfigPoints.current.IDPints) { if (p.ID == FreeUtil.ReplaceInt(type, arg1)) { UnitPosition unitPosition = new UnitPosition(); if (p.points.Count > 0) { unitPosition.SetX(p.points[0].pos.x); unitPosition.SetY(p.points[0].pos.y); unitPosition.SetZ(p.points[0].pos.z); unitPosition.SetYaw(p.points[0].dir); unitPosition.SetCylinderVolR(p.points[0].cylinderVolR); unitPosition.SetCylinderVolH(p.points[0].cylinderVolH); return(unitPosition); } } } return(null); }
public override UnitPosition Select(IEventArgs args) { if (tempPosition == null) { tempPosition = new UnitPosition(); } if (MapConfigPoints.current != null) { int realType = FreeUtil.ReplaceInt(type, args); int mapId = args.GameContext.session.commonSession.RoomInfo.MapId; var poss = args.FreeContext.Poss; foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(mapId).IDPints) { if (p.ID == realType) { RandomBit randomBit = poss.AddRandomBit(p.ID, p.points.Count); Vector3 v = Vector3.zero; int index = -1; bool invalid = false; if (randomBit.index >= 0) { index = poss.GetRandomBit(p.ID, p.points.Count); v = p.points[index].pos; } else { invalid = true; } tempPosition.SetInvalid(invalid); tempPosition.SetX(v.x); tempPosition.SetY(v.y); tempPosition.SetZ(v.z); tempPosition.SetRandomindex(index); return(tempPosition); } } } return(tempPosition); }
public override UnitPosition Select(IEventArgs args) { if (tempPosition == null) { tempPosition = new UnitPosition(); bitDic = new Dictionary <int, RandomBit>(); } if (MapConfigPoints.current != null) { int realType = FreeUtil.ReplaceInt(type, args); int realIndex = FreeUtil.ReplaceInt(index, args); int mapId = args.GameContext.session.commonSession.RoomInfo.MapId; foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(mapId).IDPints) { if (p.ID == realType) { if (!bitDic.ContainsKey(p.ID)) { bitDic.Add(p.ID, new RandomBit(p.points.Count)); } Vector3 v = Vector3.zero; if (realIndex == 0) { v = p.points[Random(p.ID, p.points.Count)].pos; if (birth) { if (HasPlayerNearBy(v, args)) { for (int i = 0; i < p.points.Count; i++) { realIndex = Random(p.ID, p.points.Count); v = p.points[realIndex].pos; if (!HasPlayerNearBy(v, args)) { break; } } } } } else { if (realIndex < 0 || realIndex >= p.points.Count) { realIndex = Math.Min(0, p.points.Count - 1); } v = p.points[realIndex].pos; } tempPosition.SetX(v.x); tempPosition.SetY(v.y); tempPosition.SetZ(v.z); tempPosition.SetYaw(p.points[realIndex].dir); tempPosition.SetCylinderVolR(p.points[realIndex].cylinderVolR); tempPosition.SetCylinderVolH(p.points[realIndex].cylinderVolH); break; } } } return(tempPosition); }
public static void SetEntityToUnitPosition(PositionComponent position, UnitPosition up) { up.SetX(position.Value.x); up.SetY(position.Value.y); up.SetZ(position.Value.z); }
private void RealEat(PlayerEntity player, ISkillArgs skill) { if (!this.disable && (bufCondition == null || bufCondition.Meet(skill))) { ShowEffect(skill, player); skill.TempUse("buf", this); if (creator != null) { skill.TempUse("creator", (FreeData)this.creator.freeData.FreeData); } pos.SetX(player.position.Value.x); pos.SetY(player.position.Value.y); pos.SetZ(player.position.Value.z); if (region.In(skill, pos)) { if (!ins.Contains(player.playerInfo.PlayerId)) { if (enterAction != null) { enterAction.Act(skill); } ins.Add(player.playerInfo.PlayerId); } if (trigger == null || trigger.Triggered(skill) == ISkillTrigger.TriggerStatus.Success) { if (eatAction != null) { // record parentkey IPosSelector posCenter = GetPos(region.GetCenter(skill)); skill.GetDefault().GetParameters().TempUse(new IntPara("posindex", posCenter.Select(skill).GetRandomindex())); eatAction.Act(skill); skill.GetDefault().GetParameters().RemovePara("posindex"); // handle if (posindex >= 0) { skill.GetDefault().GetParameters().TempUse(new IntPara("resetpos", posindex)); skill.Triggers.Trigger(FreeTriggerConstant.PLAYER_EAT_BUF, skill); skill.GetDefault().GetParameters().RemovePara("resetpos"); } if (consume) { skill.FreeContext.Bufs.RemoveBuf(skill, this.realKey); } } } } else { if (ins.Contains(player.playerInfo.PlayerId)) { if (leaveAction != null) { leaveAction.Act(skill); } ins.Remove(player.playerInfo.PlayerId); } } if (creator != null) { skill.Resume("creator"); } skill.Resume("buf"); } }