public override UnitPosition Select(IEventArgs args) { UnitPosition up = pos.Select(args); Vector3 position = UnityPositionUtil.ToVector3(up); RaycastHit hitInfo; if (SingletonManager.Get <MapConfigManager>().InWater(position)) { Ray ray = new Ray(position, Vector3.up); bool hit = Physics.Raycast(ray, out hitInfo, 10000, UnityLayerManager.GetLayerMask(EUnityLayerName.WaterTrigger)); if (hit) { return(UnityPositionUtil.FromVector(hitInfo.point - new Vector3(0, waterDelta, 0))); } } else { Ray ray = new Ray(position, Vector3.down); bool hit = Physics.Raycast(ray, out hitInfo, 10000, UnityLayers.SceneCollidableLayerMask | UnityLayerManager.GetLayerMask(EUnityLayerName.WaterTrigger)); if (hit) { if (hitInfo.collider.transform.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.WaterTrigger)) { return(UnityPositionUtil.FromVector(hitInfo.point - new Vector3(0, waterDelta, 0))); } else { return(UnityPositionUtil.FromVector(hitInfo.point)); } } } return(up); }
protected override void BuildMessage(IEventArgs args) { builder.Key = FreeMessageConstant.PlaySound; if (null == pos) { if (play) { builder.Ks.Add(2); builder.Ins.Add(sound); builder.Bs.Add(self); } else { } } else { UnitPosition up = pos.Select(args); if (up != null) { builder.Ks.Add(3); builder.Fs.Add(up.GetX()); builder.Fs.Add(up.GetY()); builder.Fs.Add(up.GetZ()); builder.Ins.Add(sound); } } }
public override UnitPosition Select(IEventArgs args) { UnitPosition up = pos.Select(args); Vector3 fromV = UnityPositionUtil.ToVector3(up); Vector3 toV = new Vector3(up.GetX(), -10000, up.GetZ()); Ray r = new Ray(fromV, new Vector3(toV.x - fromV.x, toV.y - fromV.y, toV.z - fromV.z)); RaycastHit hitInfo; bool hited = Physics.Raycast(r, out hitInfo); if (hited) { if (SingletonManager.Get <MapConfigManager>().InWater(new Vector3(hitInfo.point.x, hitInfo.point.y - 0.1f, hitInfo.point.z))) { hitInfo.point = new Vector3(fromV.x, hitInfo.point.y - waterDelta, fromV.z); } //Debug.LogFormat("hit {0},{1},{2}", hitInfo.point.x, hitInfo.point.y, hitInfo.point.z); return(UnityPositionUtil.FromVector(hitInfo.point)); } return(up); }
public override void DoAction(IEventArgs args) { int realType = args.GetInt(type); int dis = args.GetInt(distance); int i = 1; UnitPosition up = pos.Select(args); Vector3 target = new Vector3(up.GetX(), up.GetY(), up.GetZ()); foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(args.GameContext.session.commonSession.RoomInfo.MapId).IDPints) { if (p.ID == realType) { foreach (MapConfigPoints.SavedPointData v in p.points) { if (IsNear(v.pos, target, dis)) { TriggerArgs ta = new TriggerArgs(); ta.AddPara(new FloatPara("x", v.pos.x)); ta.AddPara(new FloatPara("y", v.pos.y)); ta.AddPara(new FloatPara("z", v.pos.z)); ta.AddPara(new FloatPara("index", i++)); args.Act(action, ta); } } } } }
public override bool InRectange(FreeUIUtil.Rectangle rec, IEventArgs args) { if (pos == null || change) { pos = selector.Select(args); } int px = (int)(pos.GetX()); int py = (int)(pos.GetY()); float r = 0f; try { r = float.Parse(radius); } catch (Exception) { r = FreeUtil.ReplaceFloat(radius, args); } float x1 = rec.x - r; float x2 = rec.x + rec.width + r; float y1 = rec.y - r; float y2 = rec.y + rec.height + r; // 圆心在矩形的加上圆半径的范围内 return(px >= x1 && px <= x2 && py >= y1 && py <= y2); }
public override bool IsIn(IEventArgs args, UnitPosition entity) { bool isIn = false; foreach (MapConfigPoints.ID_Point p in MapConfigPoints.current.IDPints) { if (p.ID == FreeUtil.ReplaceInt(type, args)) { foreach (MapConfigPoints.SavedPointData spd in p.points) { float dx = MyMath.Abs(entity.GetX() - spd.pos.x); float dz = MyMath.Abs(entity.GetZ() - spd.pos.z); float dy = MyMath.Abs(entity.GetY() - spd.pos.y); if (dx * dx + dz * dz <= spd.cylinderVolR * spd.cylinderVolR && dy <= spd.cylinderVolH) { isIn = true; break; } } if (isIn) { break; } } } if (useOut) { return(!isIn); } return(isIn); }
public override UnitPosition GetCenter(IEventArgs args) { if (pos == null || change) { pos = selector.Select(args); } return(pos); }
public override string GetStyle(IEventArgs args, string key) { UnitPosition fromUp = from.Select(args); UnitPosition toUp = to.Select(args); return(fromUp.GetX() + "_" + fromUp.GetY() + "_" + fromUp.GetZ() + SPLITER + toUp.GetX() + "_" + toUp.GetY() + "_" + toUp.GetZ() + SPLITER + FreeUtil.ReplaceVar(name, args) + SPLITER + FreeUtil.ReplaceFloat(scale, args) + SPLITER + FreeUtil. ReplaceFloat(adjust, args)); }
public static UnitPosition GetPlayerPosition(PlayerEntity player) { UnitPosition tempPosition = new UnitPosition(); SetPlayerToUnitPosition(player, tempPosition); return(tempPosition); }
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 GetEntityPosition(PositionComponent entity) { UnitPosition tempPosition = new UnitPosition(); SetEntityToUnitPosition(entity, tempPosition); return(tempPosition); }
public void addUnit(Unit toAdd, int position) { UnitPosition u = new UnitPosition(); u.position = position; u.unit = toAdd; unitList.Add(u); }
public override UnitPosition Select(IEventArgs args) { IniCon(); UnitPosition up = new UnitPosition(); FreeRuleEventArgs fr = (FreeRuleEventArgs)args; if (!string.IsNullOrEmpty(player)) { object obj = fr.GetEntity(player); if (obj != null) { if (obj is PlayerEntity) { PlayerEntity playerEntity = (PlayerEntity)obj; fr.TempUse("current", (FreeData)playerEntity.freeData.FreeData); UnityPositionUtil.SetPlayerToUnitPosition(playerEntity, up); if (fromEye) { up.SetY(up.GetY() + 1.7f); } fr.Resume("current"); } if (obj is FreeMoveEntity) { FreeMoveEntity playerEntity = (FreeMoveEntity)obj; fr.TempUse("current", (FreeEntityData)playerEntity.freeData.FreeData); UnityPositionUtil.SetEntityToUnitPosition(playerEntity.position, up); fr.Resume("current"); } } } else if (!string.IsNullOrEmpty(condition)) { if (con == null || con.Meet(args)) { foreach (PlayerEntity unit in args.GameContext.player.GetInitializedPlayerEntities()) { if (unit.hasFreeData) { fr.TempUse("current", (FreeData)unit.freeData.FreeData); UnityPositionUtil.SetPlayerToUnitPosition(unit, up); fr.Resume("current"); } } } } return(GetPosition(args, up, FreeUtil.ReplaceFloat(angle, args) + up.GetYaw())); }
private IPosSelector GetPos(UnitPosition up) { PosAssignSelector pas = new PosAssignSelector(); pas.SetX(up.GetX().ToString()); pas.SetY(up.GetY().ToString()); pas.SetZ(up.GetZ().ToString()); return(pas); }
public override bool Frame(FreeRuleEventArgs args, FreeMoveEntity entity, int interval) { if (dynamic) { tempPosition = targetPos.Select(args); } float speedMeter = GetSpeed(args, entity).GetSpeed(args, interval); float dis = speedMeter * (float)interval / 1000f; if (tempPosition.Distance(GetEntityPosition(entity)) < dis) { UnityPositionUtil.SetUnitPositionToEntity(entity.position, tempPosition); if (action != null && !firstTime) { args.TempUsePara(new FloatPara("x", entity.position.Value.x)); args.TempUsePara(new FloatPara("y", entity.position.Value.y)); args.TempUsePara(new FloatPara("z", entity.position.Value.z)); action.Act(args); args.ResumePara("x"); args.ResumePara("y"); args.ResumePara("z"); firstTime = true; } if (!stayTarget) { return(true); } } else { Vector3 from = entity.position.Value; UnitPosition ep = GetEntityPosition(entity); UnityPositionUtil.Move(ep, tempPosition, dis); entity.position.Value = new Vector3(ep.GetX(), ep.GetY(), ep.GetZ()); if (hitType > 0) { bool hit = CheckHit(args, (FreeEntityData)entity.freeData.FreeData, from, entity.position.Value, dis); if (hit) { return(true); } } } return(false); }
public virtual void Start(FreeRuleEventArgs args, FreeMoveEntity entity) { startTime = args.Rule.ServerTime; UnitPosition up = startPos.Select(args); entity.position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ()); StartMove(args, entity); }
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 void DoAction(IEventArgs args) { UnitPosition up = pos.Select(args); Contexts con = args.GameContext; VehicleEntityUtility.CreateNewVehicle(con.vehicle, FreeUtil.ReplaceInt(carId, args), con.session.commonSession.EntityIdGenerator.GetNextEntityId(), map.position.UnityPositionUtil.ToVector3(up)); }
public override void StartMove(FreeRuleEventArgs args, FreeMoveEntity entity) { tempPosition = targetPos.Select(args); if (!string.IsNullOrEmpty(useTime)) { realTime = FreeUtil.ReplaceFloat(useTime, args); } UnityPositionUtil.SetUnitPositionToEntity(entity.position, startPos.Select(args)); }
public virtual UnitPosition Select(IEventArgs args) { UnitPosition up = pos.Select(args); if (up != null) { Adjust(up, args); } return(up); }
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); }
public override UnitPosition Select(IEventArgs args) { UnitPosition up = pos.Select(args); if (up != null) { return(GetPosition(args, up, FreeUtil.ReplaceFloat(angle, args))); } return(null); }
public override bool IsIn(IEventArgs args, UnitPosition entity) { if (pos == null || change) { pos = selector.Select(args); } float r = 0f; try { r = float.Parse(radius); } catch (Exception) { r = FreeUtil.ReplaceFloat(radius, args); } double dx = MyMath.Abs(entity.GetX() - pos.GetX()); if (dx > r) { if (useOut) { return(true); } return(false); } double dz = MyMath.Abs(entity.GetZ() - pos.GetZ()); if (dz > r) { if (useOut) { return(true); } return(false); } double dy = MyMath.Abs(entity.GetY() - pos.GetY()); float zrange = FreeUtil.ReplaceFloat(zRange, args); if (zrange <= 0) { zrange = 170; } bool isIn = (dx * dx + dz * dz) <= r * r && (dy < zrange); if (useOut) { return(!isIn); } return(isIn); }
public override void OnNext(UnitInfo info) { switch (info.id) { case UnitDefId.Pacman: pacmanPosition = info.position; break; case UnitDefId.Blinky: blinkyPosition = info.position; break; } }
public virtual string GetXyz(IEventArgs args) { if (selector != null) { UnitPosition up = selector.Select(args); if (up != null) { return(up.GetX() + "," + up.GetY() + "," + up.GetZ()); } } return(string.Empty); }
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 override void BuildMessage(IEventArgs args) { this.scope = "4"; builder.Key = FreeMessageConstant.PoisonCircle; UnitPosition from = pos.Select(args); builder.Ks.Add(1); builder.Fs.Add(from.GetX()); builder.Fs.Add(from.GetZ()); builder.Ins.Add(FreeUtil.ReplaceInt(radius, args)); }
public void UpdateUnitPosition(UnitPosition unitPosition) { bool created; var unit = GetOrInstantiate(unitPosition.Id, out created); if (unit.Movement) { unit.Movement.Moving = unitPosition.Moving; unit.Movement.SetPosition( new Vector3(unitPosition.X, 0, unitPosition.Y), interpolate: !created); } }
// 一个位置向另外一个位置移动一段距离后的点位置, 修改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 bool Meet(IEventArgs args) { UnitPosition up = pos.Select(args); if (useOut) { return(!region.In(args, up)); } else { return(region.In(args, 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); }
public override UnitPosition GetNextMovePoint() { CurrentPosition = nextPosition; CollectDot(); CollectBonus(); CheckIsPortMovement(); var point = CurrentPosition.point; var direction = CurrentPosition.direction; if (maze.StepIsPossible(point, direction)) { nextPosition = new UnitPosition(point + steps[direction], direction); return nextPosition; } return CurrentPosition; }
public List<UnitPosition> GetDeployment() { List<UnitPosition> output = new List<UnitPosition>(); foreach (var unit in Units) { if (!unit.Deployed) continue; UnitPosition unitPosition = new UnitPosition(unit.Id, unit.Hex.Position); output.Add(unitPosition); } return output; }
public void SetCurrentPosition(UnitPosition position) { nextPosition = position; CurrentPosition = nextPosition; }