protected override void OnGetObjectBounds( MapObject obj, List<Rect> rectangles ) { //RTSCharacter RTSCharacter character = obj as RTSCharacter; if( character != null ) { float radius = character.Type.Radius; rectangles.Add( new Rect( obj.Position.ToVec2() - new Vec2( radius, radius ), obj.Position.ToVec2() + new Vec2( radius, radius ) ) ); return; } //all other objects if( obj.PhysicsModel != null ) { foreach( Body body in obj.PhysicsModel.Bodies ) { foreach( Shape shape in body.Shapes ) { if( shape.ContactGroup == (int)ContactGroup.NoContact ) continue; Bounds bounds = shape.GetGlobalBounds(); rectangles.Add( new Rect( bounds.Minimum.ToVec2(), bounds.Maximum.ToVec2() ) ); } } return; } //base.OnGetObjectBounds( obj, rectangles ); }
internal static Rectangle UpdateCollision(this GameObject gameObject, Rectangle Destination, Rectangle old, MapObject currentMap) { foreach (GameTile tile in currentMap.Tiles) { if (tile.ValidTile && Destination.Intersects(tile.Destination)) { Rectangle newDestinationXOnly = new Rectangle(Destination.X, old.Y, gameObject.Width, gameObject.Height); Rectangle newDestinationYOnly = new Rectangle(old.X, Destination.Y, gameObject.Width, gameObject.Height); if (newDestinationXOnly.Intersects(tile.Destination)) { Destination.X = old.X; } if (newDestinationYOnly.Intersects(tile.Destination)) { Destination.Y = old.Y; if (gameObject.Center.Y < tile.Destination.Y) { gameObject.IsJumping = false; gameObject.CurrentSpeed = 0; } } } } return Destination; }
public void addMapObject(MapObject mapObject) { if (this.mapObjects == null) this.mapObjects = new List<MapObject>(); this.mapObjects.Add(mapObject); }
public void AddObjectClone(MapObject obj) { MapObject o = (MapObject)obj.Clone(); o.MapX %= 2 * (Config.BigTileEdgeSize + 1); o.MapY %= 2 * (Config.BigTileEdgeSize + 1); Objects.Add(o); }
public void AddObject(Point index, MapObject obj) { if (!_objects.ContainsKey(index)) _objects.Add(index, new List<MapObject>()); _objects[index].Add(obj); }
public void CreateGeometry(MapObject parent) { foreach (Aerofoil aerofoil in aerofoils) { aerofoil.CreateGeometry(parent, this); } }
protected override void Start() { base.Start(); mapObject = GetComponent<MapObject>(); movement = GetComponent<SimpleMovement>(); }
public ObjectWrapper(MapObject mapObject, Point index) { _object = mapObject; _index = index; DrawPrioirty = _index.X * 1000 + _index.Y; IsDrawable = true; }
protected override void OnDeleteSubscribedToDeletionEvent(Entity entity) { base.OnDeleteSubscribedToDeletionEvent(entity); //clear reference when entity was deleted if (exampleReferenceToObject == entity) exampleReferenceToObject = null; }
public void TestMoveUp() { var movableObject = new MapObject {Position = new MapPosition(5, 7)}; movableObject.Position = new MapPosition(movableObject.Position, new PositionChange {Y = 1}); Assert.AreEqual(new MapPosition(5, 8), movableObject.Position); }
public void TestMoveRight() { var movableObject = new MapObject {Position = new MapPosition(6, 2)}; movableObject.Position = new MapPosition(movableObject.Position, new PositionChange{X = 1}); Assert.AreEqual(new MapPosition(7, 2), movableObject.Position); }
public void TestMoveLeft() { var movableObject = new MapObject {Position = new MapPosition(4, 4)}; movableObject.Position = new MapPosition(movableObject.Position, new PositionChange {X = -1}); Assert.AreEqual(new MapPosition(3, 4), movableObject.Position); }
public void TestMoveDown() { var movableObject = new MapObject {Position = new MapPosition(8, 1)}; movableObject.Position = new MapPosition(movableObject.Position, new PositionChange{Y = -1}); Assert.AreEqual(new MapPosition(8, 0), movableObject.Position); }
public Map(int mapSize) { this.mapSize = mapSize; this.map = new MapObject [mapSize][]; for (int i = 0; i < map.Length; ++i) { map[i] = new MapObject[mapSize]; } }
public void TestAddOneMovableObject() { var map = new Map(); var movableObject = new MapObject(); map.AddObject(movableObject); Assert.AreEqual(1, map.GetNumDrawables()); Assert.AreEqual(movableObject, map.GetDrawable(0)); }
// Execute MainMenu functions void Start() { UpdateMenu(); previous = PlanetariumCamera.fetch.initialTarget; PlanetariumCamera.fetch.targets .Where(m => Templates.barycenters.Contains(m.GetName()) || Templates.notSelectable.Contains(m.GetName())) .ToList() .ForEach(map => PlanetariumCamera.fetch.targets.Remove(map)); }
protected override void Attack() { if (!Target.IsAttackTarget(this) || NoAttack) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !InAttackRange(); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (!ranged && Envir.Random.Next(5) > 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); if (damage == 0) return; Target.Attacked(this, damage, DefenceType.MACAgility); } else { AttackTime = Envir.Time + AttackSpeed + 500; if (damage == 0) return; if (InRangedAttackRange(PoisonAttackRange) && Envir.Random.Next(6) == 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); if (Envir.Random.Next(Settings.PoisonResistWeight) >= Target.PoisonResist) { Target.ApplyPoison(new Poison { Owner = this, Duration = 6, PType = PoisonType.Red, TickSpeed = 2000 }, this); } } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } } if (Target.Dead) FindTarget(); }
void MapChangeRegion_ObjectIn( Entity entity, MapObject obj ) { if( PlayerIntellect.Instance != null && PlayerIntellect.Instance.ControlledObject == obj ) { PlayerCharacter.ChangeMapInformation playerCharacterInformation = ( (PlayerCharacter)PlayerIntellect.Instance.ControlledObject ).GetChangeMapInformation( this ); GameWorld.Instance.SetShouldChangeMap( mapName, spawnPointName, playerCharacterInformation ); } }
// Use this for initialization void Start () { _instance = this; //address = "https://navalapi.rozumgames.com/"; address = "http://www.naval-battle2.somee.com/"; //address = "http://localhost:58885/"; transform.FindChild ("Dialog_yes_no").gameObject.SetActive (false); transform.FindChild ("Dialog_yes_no_fake").gameObject.SetActive (false); transform.FindChild("stop_btn").GetComponent<Button>().onClick.AddListener(StopClick); transform.FindChild("start_btn").GetComponent<Button>().onClick.AddListener(SendRequest); transform.FindChild("back_btn").GetComponent<Button>().onClick.AddListener(BackClick); transform.FindChild("search_btn").GetComponent<Button> ().onClick.AddListener (Search); selected_map_index = 0; selected_map = maps[selected_map_index]; transform.FindChild("map").FindChild("left_btn").GetComponent<Button>().onClick.AddListener(SetPreviousMap); transform.FindChild("map").FindChild("right_btn").GetComponent<Button>().onClick.AddListener(SetNextMap); //transform.FindChild ("info_btn").GetComponent<Button> ().onClick.AddListener (OpenInfo); transform.FindChild ("Item_description").GetComponent<Button> ().onClick.AddListener (CloseInfo); transform.FindChild("background").GetComponent<Button> ().onClick.AddListener (Untarget); transform.FindChild("WaitingPlayersBackground").FindChild("WaitingPlayers").GetComponent<Button> ().onClick.AddListener (Untarget); isShip = true; //ToggleSide(); transform.FindChild("ship_btn").GetComponent<Button>().onClick.AddListener(delegate { isShip = true; SoundScript.Instance.PlaySound(SoundTitle.btn_click_snd); ToggleSide(); }); transform.FindChild ("submarine_off").GetComponent<Button> ().onClick.AddListener (HideSubmarineBanned); // transform.FindChild("u_ship_slot1_blocker").GetComponent<Button>().onClick.AddListener(OpenShop); // transform.FindChild("u_ship_slot2_blocker").GetComponent<Button>().onClick.AddListener(OpenShop); // transform.FindChild("u_ship_slot3_blocker").GetComponent<Button>().onClick.AddListener(OpenShop); // transform.FindChild("u_submarine_slot1_blocker").GetComponent<Button>().onClick.AddListener(OpenShop); // transform.FindChild("u_submarine_slot2_blocker").GetComponent<Button>().onClick.AddListener(OpenShop); //transform.FindChild("u_submarine_slot3_blocker").GetComponent<Button>().onClick.AddListener(OpenShop); instantRefresh = false; isStarting = false; waitingTime = null; transform.FindChild ("Dialog_yes_no").FindChild ("Yes_btn").GetComponent<Button> ().onClick.AddListener (delegate { SoundScript.Instance.PlaySound(SoundTitle.btn_click_snd); SayAnswer ("yes");}); transform.FindChild ("Dialog_yes_no").FindChild ("No_btn").GetComponent<Button> ().onClick.AddListener (delegate { SoundScript.Instance.PlaySound(SoundTitle.btn_click_snd); SayAnswer ("no");}); transform.FindChild ("Dialog_yes_no_fake").FindChild ("Yes_btn").GetComponent<Button> ().onClick.AddListener (delegate { SoundScript.Instance.PlaySound(SoundTitle.btn_click_snd); SayAnswer_fake ("yes");}); transform.FindChild ("Dialog_yes_no_fake").FindChild ("No_btn").GetComponent<Button> ().onClick.AddListener (delegate { SoundScript.Instance.PlaySound(SoundTitle.btn_click_snd); SayAnswer_fake ("no");}); WaitingWindowSetActive (false); ingameTime = DateTime.Now; GetRandomBots (); }
public override int Pushed(MapObject pusher, MirDirection dir, int distance) { int result = base.Pushed(pusher, dir, distance); if (result > 0) { if (pusher is PlayerObject) Attacked((PlayerObject)pusher, Math.Max(50, Envir.Random.Next((int)MaxHP)), DefenceType.Repulsion); else if (pusher is MonsterObject) Attacked((MonsterObject)pusher, Math.Max(50, Envir.Random.Next((int)MaxHP)), DefenceType.Repulsion); } return result; }
public static bool HitsMapObject(this Ray ray, MapObject obj, float maxDistance = 2048) { ray.Direction = ray.Direction.GetNormalize() * maxDistance; RayCastResult[] piercingResult = PhysicsWorld.Instance.RayCastPiercing(ray, (int)ContactGroup.CastAll); foreach (var res in piercingResult) { if (res.Distance < maxDistance && res.Shape.Body._InternalUserData != null && res.Shape.Body._InternalUserData == obj) return true; } return false; }
public void TestAddTwoMovableObjects() { var map = new Map(); var movableObject1 = new MapObject(); map.AddObject(movableObject1); var movableObject2 = new MapObject(); map.AddObject(movableObject2); Assert.AreEqual(2, map.GetNumDrawables()); Assert.AreEqual(movableObject1, map.GetDrawable(0)); Assert.AreEqual(movableObject2, map.GetDrawable(1)); }
public void TestBlockingObjectCanShareCoordinateWithNonBlocking() { var map = new Map(); var blockingObject = new MapObject {Position = new MapPosition(4, 4)}; var nonBlockingObject = new MapObject {Position = new MapPosition(4, 3), Blocking = false}; map.AddObject(blockingObject); map.AddObject(nonBlockingObject); map.Move(blockingObject, new PositionChange {Y = -1}); Assert.AreEqual(new MapPosition(4, 3), blockingObject.Position); }
public void registerNewLocation(Vector2 coords, int number, string objType) { switch (objType) { case "City": if (cities[number] == null) cities[number] = new MapObject(coords, number, objType); break; case "Lab": if (labs[number] == null) labs[number] = new MapObject(coords, number, objType); break; } }
public MapManager() { enemySet = new List<EnemyObject>(); Map = HardCoded.GenerateMapObject(); player = XmlObject<PlayerObject>.Load(@"PlayerBase.xml");//HardCode.HardCoded.GeneratePlayerObject(); //player.Destination = new Rectangle(32, 32, 32, 32); //Set when loading Map player.Destination = new Rectangle(Map.StartLocation.ToPoint(), new Point(player.Width, player.Height)); EnemyObject enemy2 = XmlObject<EnemyObject>.Load(@"EnemyBase.xml"); enemy2.SetScreenLocation(100, 300); enemySet.Add(enemy2); enemySet.Add(HardCoded.GenerateEnemyObject()); }
public void Init( DecalCreator creator, Vertex[] vertices, int[] indices, string materialName, MapObject parentMapObject) { this.creator = creator; this.vertices = vertices; this.indices = indices; this.sourceMaterialName = materialName; this.parentMapObject = parentMapObject; if( parentMapObject != null ) AddRelationship( parentMapObject ); CreateDecal(); }
public void SetObject(MapObject mapObject) { this.mapObject = mapObject; if(mapObject == MapObject.EMPTY) { objectImage.enabled = false; } else { objectImage.enabled = true; objectImage.sprite = GetSprite(mapObject); } }
//This method is called when the entity receives damages protected override void OnDamage( MapObject prejudicial, Vec3 pos, Shape shape, float damage, bool allowMoveDamageToParent) { base.OnDamage( prejudicial, pos, shape, damage, allowMoveDamageToParent ); if( blinkMeshObject != null ) { //To change a material if( blinkMeshObject.SubObjects[0].MaterialName == originalMaterialName ) blinkMeshObject.SetMaterialNameForAllSubObjects( Type.BlinkMaterialName ); else blinkMeshObject.SetMaterialNameForAllSubObjects( originalMaterialName ); } }
// Barycenter-Utils public void onPlanetariumTargetChanged(MapObject map) { // If we switched to a barycenter.. if (map != null && previousMap != null) { if (Templates.barycenters.Contains(map.GetName())) { // Don't center the barycenter int nextIndex = previousMap.celestialBody.flightGlobalsIndex < map.celestialBody.flightGlobalsIndex ? map.celestialBody.flightGlobalsIndex + 1 : map.celestialBody.flightGlobalsIndex - 1; CelestialBody body = PSystemManager.Instance.localBodies.Find(b => b.flightGlobalsIndex == nextIndex); PlanetariumCamera.fetch.SetTarget(body); previousMap = Resources.FindObjectsOfTypeAll<MapObject>().First(m => m.celestialBody.flightGlobalsIndex == nextIndex); } } }
// Barycenter-Utils public void onPlanetariumTargetChanged(MapObject map) { // If we switched to a barycenter.. if (map != null && previousMap != null) { if (Templates.barycenters.Contains(map.GetName()) || additions.Contains(map.GetName())) { // Don't center the barycenter List<MapObject> objects = PlanetariumCamera.fetch.targets; int nextIndex = objects.IndexOf(previousMap) < objects.IndexOf(map) ? (objects.IndexOf(map) + 1) % objects.Count : objects.IndexOf(map) - 1 + (objects.IndexOf(map) - 1 >= 0 ? 0 : objects.Count); PlanetariumCamera.fetch.SetTarget(objects[nextIndex]); previousMap = objects[nextIndex]; } } }
private static List <Face> CalculateDecalGeometry(Entity entity, ITexture decal) { var decalGeometry = new List <Face>(); if (decal == null || entity.Parent == null) { return(decalGeometry); // Texture not found } var boxRadius = Coordinate.One * 4; // Decals apply to all faces that intersect within an 8x8x8 bounding box // centered at the origin of the decal var box = new Box(entity.Origin - boxRadius, entity.Origin + boxRadius); var root = MapObject.GetRoot(entity.Parent); // Get the faces that intersect with the decal's radius var faces = root.GetAllNodesIntersectingWith(box).OfType <Solid>() .SelectMany(x => x.Faces).Where(x => x.IntersectsWithBox(box)); var idg = new IDGenerator(); // Dummy generator foreach (var face in faces) { // Project the decal onto the face var center = face.Plane.Project(entity.Origin); var texture = face.Texture.Clone(); texture.Name = decal.Name; texture.Texture = decal; texture.XShift = -decal.Width / 2m; texture.YShift = -decal.Height / 2m; var decalFace = new Face(idg.GetNextFaceID()) { Colour = entity.Colour, IsSelected = entity.IsSelected, IsHidden = entity.IsCodeHidden, Plane = face.Plane, Texture = texture }; // Re-project the vertices in case the texture axes are not on the face plane var xShift = face.Texture.UAxis * face.Texture.XScale * decal.Width / 2; var yShift = face.Texture.VAxis * face.Texture.YScale * decal.Height / 2; var verts = new[] { new Vertex(face.Plane.Project(center + xShift - yShift), decalFace), // Bottom Right new Vertex(face.Plane.Project(center + xShift + yShift), decalFace), // Top Right new Vertex(face.Plane.Project(center - xShift + yShift), decalFace), // Top Left new Vertex(face.Plane.Project(center - xShift - yShift), decalFace) // Bottom Left }; // Because the texture axes don't have to align to the face, we might have a reversed face here // If so, reverse the points to get a valid face for the plane. // TODO: Is there a better way to do this? var vertPlane = new Plane(verts[0].Location, verts[1].Location, verts[2].Location); if (!face.Plane.Normal.EquivalentTo(vertPlane.Normal)) { Array.Reverse(verts); } decalFace.Vertices.AddRange(verts); decalFace.UpdateBoundingBox(); // Calculate the X and Y shift bases on the first vertex location (assuming U/V of first vertex is zero) - we dont want these to change var vtx = decalFace.Vertices[0]; decalFace.Texture.XShift = -(vtx.Location.Dot(decalFace.Texture.UAxis)) / decalFace.Texture.XScale; decalFace.Texture.YShift = -(vtx.Location.Dot(decalFace.Texture.VAxis)) / decalFace.Texture.YScale; decalFace.CalculateTextureCoordinates(true); // Next, the decal geometry needs to be clipped to the face so it doesn't spill into the void // Create a fake solid out of the decal geometry and clip it against all the brush planes var fake = CreateFakeDecalSolid(decalFace); foreach (var f in face.Parent.Faces.Except(new[] { face })) { Solid back, front; fake.Split(f.Plane, out back, out front, idg); fake = back ?? fake; } // Extract out the original face decalFace = fake.Faces.First(x => x.Plane.EquivalentTo(face.Plane, 0.05m)); // Add a tiny bit to the normal axis to ensure the decal is rendered in front of the face var normalAdd = face.Plane.Normal * 0.2m; decalFace.Transform(new UnitTranslate(normalAdd), TransformFlags.TextureLock); decalFace.IsSelected = entity.IsSelected; decalGeometry.Add(decalFace); } return(decalGeometry); }
public MapTile() { tileX = 0; tileY = 0; waterCur = 0; waterMax = 10; m_object = null; }
private void Admin_List_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { MapObject thisMapObject = (sender as ListBox).SelectedItem as MapObject; }
public Face GetFace(MapObject root) { var obj = root.FindByID(ParentID) as Solid; return(obj == null ? null : obj.Faces.FirstOrDefault(x => x.ID == ID)); }
public void drawTrackingStations(MapObject target) { displayingTooltip2 = false; // Do tracking stations first foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics()) { if (!MiscUtils.isCareerGame()) { break; } bool display2 = false; string openclosed3 = "Closed"; if ((string)obj.getSetting("FacilityType") != "TrackingStation") { continue; } if (isOccluded(obj.gameObject.transform.position, target.celestialBody)) { if (KerbalKonstructs.instance.mapHideIconsBehindBody) { continue; } } openclosed3 = (string)obj.getSetting("OpenCloseState"); if ((float)obj.getSetting("OpenCost") == 0) { openclosed3 = "Open"; } if (KerbalKonstructs.instance.mapShowOpenT) { display2 = true; } if (!KerbalKonstructs.instance.mapShowClosed && openclosed3 == "Closed") { display2 = false; } if (!KerbalKonstructs.instance.mapShowOpen && openclosed3 == "Open") { display2 = false; } if (!display2) { continue; } Vector3 pos = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(obj.gameObject.transform.position)); Rect screenRect6 = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16); // Distance between camera and spawnpoint sort of float fPosZ = pos.z; float fRadarRadius = 12800 / fPosZ; if (fRadarRadius > 15) { Graphics.DrawTexture(screenRect6, UIMain.TrackingStationIcon); } string sTarget = (string)obj.getSetting("TargetID"); float fStRange = (float)obj.getSetting("TrackingShort"); float fStAngle = (float)obj.getSetting("TrackingAngle"); if (openclosed3 == "Open" && KerbalKonstructs.instance.mapShowGroundComms) { drawGroundComms(obj); } if ((string)obj.getSetting("TargetType") == "Craft" && sTarget != "None") { Vessel vTargetVessel = TrackingStationGUI.GetTargetVessel(sTarget); if (vTargetVessel == null) { } else { if (vTargetVessel.state == Vessel.State.DEAD) { } else { CelestialBody cbTStation = (CelestialBody)obj.getSetting("CelestialBody"); CelestialBody cbTCraft = vTargetVessel.mainBody; if (cbTStation == cbTCraft && openclosed3 == "Open" && KerbalKonstructs.instance.mapShowUplinks) { Vector3 vCraftPos = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(vTargetVessel.gameObject.transform.position)); float fRangeToTarget = TrackingStationGUI.GetRangeToCraft(obj, vTargetVessel); int iUplink = TrackingStationGUI.GetUplinkQuality(fStRange, fRangeToTarget); float fUplink = (float)iUplink / 100; float fRed = 1f; float fGreen = 0f; float fBlue = fUplink; float fAlpha = 1f; if (iUplink > 45) { fRed = 1f; fGreen = 0.65f + (fUplink / 10); fBlue = 0f; } if (iUplink > 85) { fRed = 0f; fGreen = fUplink; fBlue = 0f; } float fStationLOS = TrackingStationGUI.StationHasLOS(obj, vTargetVessel); if (fStationLOS > fStAngle) { fRed = 1f; fGreen = 0f; fBlue = 0f; fAlpha = 0.5f; } NavUtils.CreateLineMaterial(3); GL.Begin(GL.LINES); NavUtils.lineMaterial3.SetPass(0); GL.Color(new Color(fRed, fGreen, fBlue, fAlpha)); GL.Vertex3(pos.x - Screen.width / 2, pos.y - Screen.height / 2, pos.z); GL.Vertex3(vCraftPos.x - Screen.width / 2, vCraftPos.y - Screen.height / 2, vCraftPos.z); GL.End(); } } } } if (screenRect6.Contains(Event.current.mousePosition) && !displayingTooltip2) { CelestialBody cPlanetoid = (CelestialBody)obj.getSetting("CelestialBody"); var objectpos2 = cPlanetoid.transform.InverseTransformPoint(obj.gameObject.transform.position); var dObjectLat2 = NavUtils.GetLatitude(objectpos2); var dObjectLon2 = NavUtils.GetLongitude(objectpos2); var disObjectLat2 = dObjectLat2 * 180 / Math.PI; var disObjectLon2 = dObjectLon2 * 180 / Math.PI; if (disObjectLon2 < 0) { disObjectLon2 = disObjectLon2 + 360; } //Only display one tooltip at a time displayMapIconToolTip("Tracking Station " + "\n(Lat." + disObjectLat2.ToString("#0.00") + "/ Lon." + disObjectLon2.ToString("#0.00") + ")", pos); if (Event.current.type == EventType.mouseDown && Event.current.button == 0) { float sTrackAngle = (float)obj.getSetting("TrackingAngle"); float sTrackRange = (float)obj.getSetting("TrackingShort"); PersistenceUtils.loadStaticPersistence(obj); float sTrackAngle2 = (float)obj.getSetting("TrackingAngle"); float sTrackRange2 = (float)obj.getSetting("TrackingShort"); selectedFacility = obj; FacilityManager.setSelectedFacility(obj); KerbalKonstructs.instance.showFacilityManager = true; } } } }
private void MouseDown(Viewport3D vp, ViewportEvent e) { if (!_currentTool.NoSelection()) { var vtxs = _currentTool.GetVerticesAtPoint(e.X, vp.Height - e.Y, vp); if (vtxs.Any()) { // Use the topmost vertex as the control point var vtx = vtxs.First(); // Mouse down on a point if (vtx.IsSelected && KeyboardState.Ctrl && _currentTool.ShouldDeselect(vtxs)) { // If the vertex is selected and ctrl is down, deselect the vertices vtxs.ForEach(x => x.IsSelected = false); } else { if (!vtx.IsSelected && !KeyboardState.Ctrl && _currentTool.ShouldDeselect(vtxs)) { // If we aren't clicking on a selected point and ctrl is not down, deselect the others Points.ForEach(x => x.IsSelected = false); // If this point is already selected, don't deselect others. This is the same behaviour as 2D selection. } vtxs.ForEach(x => x.IsSelected = true); } VertexSelectionChanged(); // Don't do other click operations return; } // Nothing clicked if (!KeyboardState.Ctrl) { // Deselect all the points if not ctrl-ing Points.ForEach(x => x.IsSelected = false); } } if (!_currentTool.No3DSelection()) { // Do selection var ray = vp.CastRayFromScreen(e.X, e.Y); var hits = Document.Map.WorldSpawn.GetAllNodesIntersectingWith(ray, true); var solid = hits .OfType <Solid>() .Select(x => new { Item = x, Intersection = GetIntersectionPoint(x, ray) }) .Where(x => x.Intersection != null) .OrderBy(x => (x.Intersection - ray.Start).VectorMagnitude()) .Select(x => x.Item) .FirstOrDefault(); if (solid != null) { if (solid.IsSelected && KeyboardState.Ctrl) { // deselect solid var select = new MapObject[0]; var deselect = new[] { solid }; Document.PerformAction("Deselect VM solid", new ChangeSelection(select, deselect)); } else if (!solid.IsSelected) { // select solid var select = new[] { solid }; var deselect = !KeyboardState.Ctrl ? Document.Selection.GetSelectedObjects() : new MapObject[0]; Document.PerformAction("Select VM solid", new ChangeSelection(select, deselect)); } // Don't do other click operations return; } } base.MouseDown(vp, e); }
/// <summary> /// Checks if the passed MapObject is within the passed units to this task's unit. /// </summary> protected bool inRange(MapObject target, float maxDistance) { return(this.getDistance(target) <= maxDistance); }
public void Select(MapObject obj) { Select(new[] { obj }); }
public void Deselect(MapObject obj) { Deselect(new[] { obj }); }
public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false, bool ignoreDefence = true) { }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); int damage = GetAttackPower(MinDC, MaxDC); int distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); int delay = distance * 50 + 500; //50 MS per Step DelayedAction action = null; if (RandomUtils.Next(100) < 65 && distance < 3) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); List <MapObject> listtargets = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 2); for (int o = 0; o < listtargets.Count; o++) { MapObject ob = listtargets[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { continue; } if (!ob.IsAttackTarget(this)) { continue; } action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MAC); ActionList.Add(action); if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist && RandomUtils.Next(100) < 40) { ob.ApplyPoison(new Poison { Owner = this, Duration = damage / 10, PType = PoisonType.Green, Value = damage / 10, TickSpeed = 2000 }, this); } } } else { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); List <MapObject> listtargets = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 3); for (int o = 0; o < listtargets.Count; o++) { MapObject ob = listtargets[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { continue; } if (!ob.IsAttackTarget(this)) { continue; } action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 3 / 2, DefenceType.MAC); ActionList.Add(action); if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist && RandomUtils.Next(100) < 40) { ob.ApplyPoison(new Poison { Owner = this, Duration = damage / 10, PType = PoisonType.Green, Value = damage / 5, TickSpeed = 2000 }, this); } } } ShockTime = 0; ActionTime = Envir.Time + 500; AttackTime = Envir.Time + (AttackSpeed); }
/// <summary> /// Is a given object heading approximately towards this target location? /// </summary> /// <param name="gameObject"></param> /// <param name="target"></param> /// <returns></returns> public static bool IsHeadingTowards(GameObject gameObject, MapObject target) { return(IsHeadingTowards(gameObject, target, 0.9f)); }
/// <summary> /// Returns the distance between this unit and the passed MapObject. /// </summary> protected float getDistance(MapObject other) { return(Vector3.Distance(this.unit.getFootPos(), other.getPos())); }
/// <summary> /// Called when the unit is damaged. /// </summary> public virtual void onDamage(MapObject dealer) { // There is no implementation, so there is no need to call super from implementations. }
public void set(MapObject obj, int x, int y) { map[x][y] = obj; }
/** * Process the turn by firing off scout ships */ public new void process() { List <Planet> colonisablePlanets = new List <Planet>(); List <Planet> buildablePlanets = new List <Planet>(); foreach (Planet planet in game.getPlanets()) { if (isColonisablePlanet(planet)) { colonisablePlanets.Add(planet); } if (isBuildablePlanet(planet, DOCK_SIZE_REQUIRED) && planet.getPopulationDensity() > POP_DENSITY_REQUIRED) { buildablePlanets.Add(planet); } } List <Fleet> coloniserFleets = new List <Fleet>(); foreach (Fleet fleet in game.getFleets()) { if (isColoniserFleet(fleet)) { if (fleet.getWaypoints().Count == 1) { if (fleet.getOrbiting() != null && fleet.getOrbiting().getOwner() != null && fleet.getOrbiting().getOwner().getID() == fleet.getOwner().getID() && fleet.getOrbiting().getPopulationDensity() > POP_DENSITY_REQUIRED) { coloniserFleets.Add(fleet); } } else { MapObject target = fleet.getWaypoints()[1].getTarget(); if (target != null && target is Planet) { colonisablePlanets.Remove((Planet)target); } if (target == null) { Debug.Log(string.Format("Found a coloniser {0} going to a destination with no target!", fleet.getName())); } } } } foreach (Fleet fleet in coloniserFleets) { Planet planetToColonise = closestPlanet(fleet, colonisablePlanets); if (planetToColonise != null) { Debug.Log(string.Format("{0} is targeting {1} for colonizing", fleet.getName(), planetToColonise.getName())); fleet.getCargo().setColonists(fleet.getAggregate().getCargoCapacity()); fleet.getOrbiting().setPopulation(fleet.getOrbiting().getPopulation() - fleet.getAggregate().getCargoCapacity() * 100); fleet.addWaypoint(planetToColonise.getX(), planetToColonise.getY(), 5, WaypointTask.Colonise, planetToColonise); colonisablePlanets.Remove(planetToColonise); } } buildFleets(buildablePlanets, colonisablePlanets.Count); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); MirDirection dir = Functions.PreviousDir(Direction); Point target; Cell cell; for (int i = 0; i < 4; i++) { target = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (target == Front) { continue; } if (!CurrentMap.ValidPoint(target)) { continue; } cell = CurrentMap.GetCell(target); if (cell.Objects == null) { continue; } for (int o = 0; o < cell.Objects.Count; o++) { MapObject ob = cell.Objects[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { continue; } if (!ob.IsAttackTarget(this)) { continue; } ob.Attacked(this, MinDC, DefenceType.Agility); break; } } ShockTime = 0; ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) { return; } Target.Attacked(this, damage, DefenceType.ACAgility); }
protected override void Attack() { if (!Target.IsAttackTarget(this) || NoAttack) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !InAttackRange(); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (!ranged && Envir.Random.Next(5) > 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility); ActionList.Add(action); } else { AttackTime = Envir.Time + AttackSpeed + 500; if (damage == 0) { return; } if (InRangedAttackRange(PoisonAttackRange) && Envir.Random.Next(6) == 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); PoisonTarget(Target, 1, 6, PoisonType.Red, 2000); } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } } if (Target.Dead) { FindTarget(); } }
public void drawLaunchsites(MapObject target) { displayingTooltip = false; int iPulseRate = 180; iRadarCounter = iRadarCounter + 1; if (iRadarCounter > iPulseRate) { iRadarCounter = 0; } // Then do launchsites List <LaunchSite> sites = LaunchSiteManager.getLaunchSites(); for (int index = 0; index < sites.Count; index++) { LaunchSite site = sites[index]; PSystemSetup.SpaceCenterFacility facility = PSystemSetup.Instance.GetSpaceCenterFacility(site.name); if (facility == null) { continue; } PSystemSetup.SpaceCenterFacility.SpawnPoint sp = facility.GetSpawnPoint(site.name); if (sp == null) { continue; } if (facility.facilityPQS != target.celestialBody.pqsController) { continue; } Transform spawnPointTransform = sp.GetSpawnPointTransform(); if (spawnPointTransform == null) { continue; } if (isOccluded(spawnPointTransform.position, target.celestialBody)) { if (KerbalKonstructs.instance.mapHideIconsBehindBody) { continue; } } Vector3 pos = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(spawnPointTransform.position)); Rect screenRect = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16); // Distance between camera and spawnpoint sort of float fPosZ = pos.z; float fRadarRadius = 12800 / fPosZ; float fRadarOffset = fRadarRadius / 2; string openclosed = site.openclosestate; string category = site.category; bool display = true; if (!KerbalKonstructs.instance.mapShowHelipads && category == "Helipad") { display = false; } if (!KerbalKonstructs.instance.mapShowOther && category == "Other") { display = false; } if (!KerbalKonstructs.instance.mapShowRocketbases && category == "RocketPad") { display = false; } if (!KerbalKonstructs.instance.mapShowRunways && category == "Runway") { display = false; } if (display && MiscUtils.isCareerGame()) { if (!KerbalKonstructs.instance.mapShowOpen && openclosed == "Open") { display = false; } if (!KerbalKonstructs.instance.mapShowClosed && openclosed == "Closed") { display = false; } if (KerbalKonstructs.instance.disableDisplayClosed && openclosed == "Closed") { display = false; } if (openclosed == "OpenLocked" || openclosed == "ClosedLocked") { display = false; } } if (!display) { continue; } if (KerbalKonstructs.instance.mapShowRadar) { drawRadar(pos, category, openclosed); } if (openclosed == "Open" && KerbalKonstructs.instance.mapShowGroundComms) { drawGroundComms(null, site); } if (site.icon != null) { if (fRadarRadius > 15) { Graphics.DrawTexture(screenRect, site.icon); } } else { if (fRadarRadius > 15) { switch (site.type) { case SiteType.VAB: Graphics.DrawTexture(screenRect, UIMain.VABIcon); break; case SiteType.SPH: Graphics.DrawTexture(screenRect, UIMain.SPHIcon); break; default: Graphics.DrawTexture(screenRect, UIMain.ANYIcon); break; } } } // Tooltip if (screenRect.Contains(Event.current.mousePosition) && !displayingTooltip) { //Only display one tooltip at a time string sToolTip = ""; sToolTip = site.name; if (site.name == "Runway") { sToolTip = "KSC Runway"; } if (site.name == "LaunchPad") { sToolTip = "KSC LaunchPad"; } displayMapIconToolTip(sToolTip, pos); // Select a base by clicking on the icon if (Event.current.type == EventType.mouseDown && Event.current.button == 0) { MiscUtils.HUDMessage("Selected base is " + sToolTip + ".", 5f, 3); BaseManager.setSelectedSite(site); selectedSite = site; NavGuidanceSystem.setTargetSite(selectedSite); KerbalKonstructs.instance.showBaseManager = true; } } } }
private void PlanetariumTargetChanged(MapObject mapObject) { CustomWaypointGUI.MapObject = mapObject; }
/// <summary> /// Spawns an instance of an item /// </summary> /// <param name="id">Id of the npc id</param> /// <param name="position">Position of the npc</param> /// <param name="yaw">Yaw of the npc</param> /// <param name="zone">Zone where to register the npc</param> /// <param name="regionObject">returned object</param> /// <returns>Returns true if the object doesn't fail</returns> public bool SpawnItemInstance(uint id, Point position, Rotator yaw, Zone zone, out MapObject regionObject) { if (CreateInstance(id, 1, out regionObject)) { regionObject.Position = position; regionObject.Yaw = yaw; regionObject.currentzone = zone; regionObject.OnInitialize(position); regionObject.OnLoad(); regionObject.OnSpawn(); regionObject.OnRegister(); if (regionObject.id > 0) { Regiontree tree = regionObject.currentzone.Regiontree; foreach (Character regionCharacter in tree.SearchActors(regionObject, Saga.Enumarations.SearchFlags.Characters)) { try { if (regionCharacter.client.isloaded == false) { continue; } if (Point.IsInSightRangeByRadius(regionCharacter.Position, regionObject.Position)) { regionObject.ShowObject(regionCharacter); } } catch (SocketException) { //Do nothing } } return(true); } else { return(false); } } return(false); }
private void OnObjectBecameInvisibe(MapObject mapObject) { mapObject.BecameInvisible -= OnObjectBecameInvisibe; BecameInvisible?.Invoke(this); }
public override bool OnMouseUp(Point mouseCurPos, MouseButtons button, BaseViewport viewport) { if (viewport.ViewportType != BaseViewport.ViewportTypes.PERSPECTIVE && button == MouseButtons.Left) { RubberBand rubberBand = controller.RubberBand; MapObject selectionGroup = controller.Selection; SolidGrabHandles handles = rubberBand.Handles; Matrix4 fromGridSpaceMatrix = viewport.Camera.GetViewMatrix().ClearTranslation(); // check for the program to decide if it needs to go the next grab handle mode bool isHoveringSelectedSolid = IsSelectedSolidAabbHit(mouseCurPos.X, mouseCurPos.Y, viewport); bool hasNoNewSelection = currentAction != SolidToolActionType.Select; Vector3 snappedDownMousePosition = GeneralUtility.SnapToGrid( new Vector3(mouseDownPos.X, mouseDownPos.Y, 0), viewport.GridSize); Vector3 snappedCurMousePosition = GeneralUtility.SnapToGrid(new Vector3(mouseCurPos.X, mouseCurPos.Y, 0), viewport.GridSize); bool mouseHasNotMoved = snappedDownMousePosition == snappedCurMousePosition; if (isHoveringSelectedSolid && mouseHasNotMoved && hasNoNewSelection) { handles.NextMode(); } else { switch (currentAction) { case SolidToolActionType.Create: controller.CreateSolid(fromGridSpaceMatrix); break; case SolidToolActionType.Drag: // set new position Vector3 displacement = rubberBand.Bounds.Center - selectionGroup.Bounds.Center; controller.Selection.PerformOperation(new TranslateOperation(displacement)); break; case SolidToolActionType.Transform: Vector3 oldBoundVector = selectionGroup.Bounds.Max - selectionGroup.Bounds.Min; Vector3 newBoundVector = rubberBand.Bounds.Max - rubberBand.Bounds.Min; IMapObjectOperation operation = null; switch (handles.Mode) { case SolidGrabHandles.HandleMode.Resize: operation = new ResizeTransformation(fromGridSpaceMatrix, oldBoundVector, newBoundVector, handles.LastHitStatus, viewport.GridSize); break; case SolidGrabHandles.HandleMode.Rotate: operation = new RotateTransformation(fromGridSpaceMatrix, Vector3.Zero, Vector3.Zero, rubberBand.Transformation); break; case SolidGrabHandles.HandleMode.Skew: operation = new SkewTransformation(fromGridSpaceMatrix, Vector3.Zero, Vector3.Zero, rubberBand.Transformation, handles.LastHitStatus); break; } if (operation != null) { controller.Selection.PerformOperation(operation); } break; } controller.UpdateUserInterface(); } rubberBand.SetToZeroVolume(); rubberBand.ShowGrabhandles = true; currentAction = SolidToolActionType.None; } return(true); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } int rd = RandomUtils.Next(10); byte attckType = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); int damage = GetAttackPower(MinDC, MaxDC); int distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); int delay = distance * 50 + 750; //50 MS per Step DelayedAction action = null; if (distance > 1)//这条线上没有人,才拉,否则不拉 { if (RevivalCount >= LifeCount) { if (rd < 7) { attckType = 2; } else { attckType = 3; } } else { if (rd < 7) { attckType = 2; } else { attckType = 1; } } } else { if (RevivalCount >= LifeCount) { if (rd < 7) { attckType = 2; } else { attckType = 3; } } else { if (rd < 7) { attckType = 0; } else { attckType = 1; } } } switch (attckType) { case 0: //拳击 Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility); ActionList.Add(action); break; case 1: //拍击 Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility); ActionList.Add(action); if (RandomUtils.Next(Settings.PoisonResistWeight) >= Target.PoisonResist) { if (RandomUtils.Next(2) == 0) { Target.ApplyPoison(new Poison { PType = PoisonType.Stun, Duration = 8, TickSpeed = 2000 }, this); } } break; case 2: //仗击(半月的范围攻击,1.5倍伤害) // Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); List <MapObject> list = CurrentMap.getMapObjects(Target.CurrentLocation.X, Target.CurrentLocation.Y, 1); for (int o = 0; o < list.Count; o++) { MapObject ob = list[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { continue; } if (!ob.IsAttackTarget(this)) { continue; } action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 14 / 10, DefenceType.None); ActionList.Add(action); } break; case 3: //唱歌,释放魔法,范围禁锢,麻痹 Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); List <MapObject> list2 = CurrentMap.getMapObjects(Target.CurrentLocation.X, Target.CurrentLocation.Y, 2); for (int o = 0; o < list2.Count; o++) { MapObject ob = list2[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { continue; } if (!ob.IsAttackTarget(this)) { continue; } action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 18 / 10, DefenceType.MAC); ActionList.Add(action); if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist) { if (RandomUtils.Next(10) < 7) { ob.ApplyPoison(new Poison { PType = PoisonType.Paralysis, Duration = 6, TickSpeed = 1000 }, this); } } } break; } ShockTime = 0; ActionTime = Envir.Time + 500; AttackTime = Envir.Time + (AttackSpeed); }
/** * Compute the distance between two map objects, without the square root applied */ public int dist(MapObject other) { return((x - other.x) * (x - other.x) + (y - other.y) * (y - other.y)); }
public override bool Walk(MirDirection dir) { if (!CanMove) { return(false); } Point location = Functions.PointMove(CurrentLocation, dir, 1); if (!CurrentMap.ValidPoint(location)) { return(false); } Cell cell = CurrentMap.GetCell(location); if (cell.Objects != null) { for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (AvoidFireWall && ob.Race == ObjectType.Spell) { if (((SpellObject)ob).Spell == Spell.FireWall) { return(false); } } if (!ob.Blocking) { continue; } return(false); } } CurrentMap.GetCell(CurrentLocation).Remove(this); Direction = dir; RemoveObjects(dir, 1); CurrentLocation = location; CurrentMap.GetCell(CurrentLocation).Add(this); AddObjects(dir, 1); if (Hidden) { RemoveBuff(BuffType.Hiding); } CellTime = Envir.Time + 500; ActionTime = Envir.Time + 300; MoveTime = Envir.Time + MoveSpeed; InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null; Broadcast(new S.ObjectWalk { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); cell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < cell.Objects.Count; i++) { if (cell.Objects[i].Race != ObjectType.Spell) { continue; } SpellObject ob = (SpellObject)cell.Objects[i]; ob.ProcessSpell(this); //break; } return(true); }
public bool Equals(MapObject obj) { return(this.Guid == obj.Guid); }
public override void ProjectileAction(AnimatedSprite source, MapObject target) { throw new NotImplementedException(); }
public override int Pushed(MapObject pusher, MirDirection dir, int distance) { return(Stoned ? 0 : base.Pushed(pusher, dir, distance)); }
private void LineAttack(int distance, byte AttackType) { int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) { return; } for (int i = 1; i <= distance; i++) { Point target = Functions.PointMove(CurrentLocation, Direction, i); if (target == Target.CurrentLocation) { Target.Attacked(this, damage, DefenceType.MACAgility); } else { if (!CurrentMap.ValidPoint(target)) { continue; } //Cell cell = CurrentMap.GetCell(target); if (CurrentMap.Objects[target.X, target.Y] == null) { continue; } for (int o = 0; o < CurrentMap.Objects[target.X, target.Y].Count; o++) { MapObject ob = CurrentMap.Objects[target.X, target.Y][o]; if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player) { if (!ob.IsAttackTarget(this)) { continue; } ob.Attacked(this, damage, DefenceType.MACAgility); //禁魔 if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist) { ob.ApplyPoison(new Poison { Owner = this, Duration = RandomUtils.Next(6, 12), PType = PoisonType.Stun, Value = damage, TickSpeed = 1000 }, this); } } else { continue; } break; } } } }