public static AnimationObject GenerateAnimationObject(string id, MapCoords source, MapCoords dest) { AnimationObject temp = Resources.Load <AnimationObject>("SkillAnimationControllers/" + id); MapCoords position; if (temp.startAtSource) { position = source; } else { position = dest; } AnimationObject obj = GameObject.Instantiate <AnimationObject>(temp, Globals.GridToWorld(position.X, position.Y), Quaternion.identity); /* * Debug.Log("attempt to load: " + "AnimationControllers/" + id); * obj.GetComponent<Animator>().runtimeAnimatorController = * Resources.Load<RuntimeAnimatorController>("AnimationControllers/" + id); */ return(obj); }
public void dig(GamePosition pos) { if (!isServer) { return; } MapCoords mapCoords = pos.toMapCoords(); Tile tile = mapData.getTile(mapCoords); if (tile.GetType().Equals(typeof(Wall))) { spawnManager.SpawnItemFromTile(new RockItem(), 1, mapCoords.toGamePosition()); spawnManager.SpawnItemFromTile(new DirtItem(), 1, mapCoords.toGamePosition()); if (Random.Range(1, 100) <= 25) { spawnManager.SpawnItemFromTile(new GrubItem(), 1, mapCoords.toGamePosition()); } if (Random.Range(1, 100) <= 50) { spawnManager.SpawnItemFromTile(new WormItem(), 1, mapCoords.toGamePosition()); } } RpcDig(pos.toStruct()); }
public int StartSurge(MapCoords startPoint, int startPower) { if (dirtyCache) { UpdatePowerStructureCaches(startPoint, startPower); dirtyCache = false; } int pollution = 0; foreach (PowerableStructure p in powerableCache) { pollution += p.Power(); } foreach (PowerCarrier p in powerCarrierCache) { if (p is Conduit) { Conduit c = p as Conduit; c.startSurge(); } } return(pollution); }
public void updateStructureTile(Structure s, MapCoords coords) { Structure toAdd = s; if (s == null) { toAdd = new EmptyTile(); } Structure toRemove = mapData.getStructure(coords); if (!(toRemove is EmptyTile)) { if (toRemove is PowerPlant) { game.LoseGame(); } GameObject.Destroy(toRemove.gameObject); toRemove.gameObject = null; } if (toRemove is PowerCarrier || s is PowerCarrier || toRemove is PowerableStructure || s is PowerableStructure) { powerHandler.dirtyCache = true; } mapData.setTile(coords.x, coords.y, toAdd); InstantiateStructureObject(coords, toAdd); }
public Vector2 getWorldCoordsFromMapCoords(MapCoords coords) { float worldRelX = (coords.x + 0.5f) * tileXLength; float worldRelY = (coords.y + 0.5f) * -tileYLength; return(new Vector2(worldRelX, worldRelY) + topLeftPoint); }
public void UploadCoords(MapCoords coords) { try { using (var db = GetContext()) { if (ValidateSessionId(db)) { db.InitMapSettings(coords); } else { throw new AuthenticationException("Couldn't validate the session"); } } } catch (Exception Exp) { string mapSettingsInput = "point1Longitude: " + coords.FirstLongitude + ", " + "point1Latitude: " + coords.FirstLatitude + ", " + "point1XLocation: " + coords.FirstX + ", " + "point1YLocation: " + coords.FirstY + ", " + "point2Longitude: " + coords.SecondLongitude + ", " + "point2Latitude: " + coords.SecondLatitude + ", " + "point2XLocation: " + coords.SecondX + ", " + "point2YLocation: " + coords.SecondY; Logger.GetInstance(isTesting).WriteLine(Exp.Message, Exp.StackTrace, "Map settings: " + mapSettingsInput); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public void InitLocationMenu(WorldMapLocationGameObject location, WorldMapManager wmm) { if (location == null) { // ToggleOff(); return; } missionInfoPanel.ToggleOff(); barPanel.ToggleOff(); ClearButtons(); pos = location.location.coords; this.wmm = wmm; missionButtons = new List <TextButton>(); text.text = location.location.AreaName; foreach (Mission mission in location.missions) { InstantiateMissionButton(mission); } foreach (LocationComponent loc in location.location.locationcomponents) { TextButton temp = Instantiate(MissionButtonPrefab, buttonContainer); missionButtons.Add(loc.GenerateButtion(temp, this)); } this.gameObject.SetActive(true); }
public CutsceneActionSkillAnimation(string uid, string skillEffect, MapCoords spawn, MapCoords dest, bool wait = true) { this.uid = uid; this.skillEffect = skillEffect; this.spawnPosition = spawn; this.destposition = dest; this.wait = wait; }
public void SetPosition(int x, int y) { position.X = x; position.Y = y; UpdateWorldMapPositionData(); this.transform.position = Globals.GridToWorld(x, y); }
public override bool Equals(object obj) { if (!(obj is MapCoords)) { return(false); } MapCoords other = obj as MapCoords; return(other.x == this.x && other.y == this.y); }
private void redrawNonaTile(MapCoords mapCoords) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { redrawTile(mapCoords.x - 1 + i, mapCoords.y - 1 + j, mapCoords.depth); } } }
public Tile getTileFromGamePosition(GamePosition pos) { MapCoords coords = pos.toMapCoords(); if (mapData == null) { return(new Wall(ConnectableVariant.All_Way)); } return(mapData.getTile(coords)); }
public LocationNode(string areaname, string mapkey, string filepath, int x, int y) { AreaName = areaname; MapKey = mapkey; this.filepath = filepath; coords = new MapCoords(x, y); neighbors = new List <MapCoords>(); locationcomponents = new List <LocationComponent>(); }
public void Deselect() { highlighter.GetComponent <SpriteRenderer>().enabled = false; destroyButton.enabled = false; destroyButton.image.enabled = false; destroyButton.GetComponentInChildren <Text> ().enabled = false; selected = null; selectedImage.sprite = transparent; detailsText.enabled = false; }
public static void SpawnMonster(string id, MapCoords pos) { if (GetBoardManager().pathfinding.HasActor(pos.X, pos.Y) == false) { ActorData temp = campaign.contentLibrary.actorDB.GetCopy(id); temp.gridPosX = pos.X; temp.gridPosY = pos.Y; SpawnMonster(temp); } }
void handleTileClick(MapCoords coords, TiledMap map) { Structure s = map.mapData.getStructure(coords); if (!(s is EmptyTile)) { selector.Select(coords); } if (s is PowerPlant) { PowerPlant p = s as PowerPlant; //show current power grid int newPollution = powerHandler.StartSurge(coords, p.powerRange); pollutionHandler.pollute(newPollution); } else if (s is EmptyTile && structureToPlace != null) { if (moneyHandler.buyStructure(structureToPlace, coords)) { selector.Select(coords); } } if (Input.GetKey(KeyCode.LeftShift)) { if (structureToPlace is Conduit) { structureToPlace = new Conduit(); } else if (structureToPlace is Miner) { structureToPlace = new Miner(); } else if (structureToPlace is HeatLaser) { structureToPlace = new HeatLaser(); } else if (structureToPlace is Surger) { structureToPlace = new Surger(); } else { Debug.LogWarning("COULD NOT RECOGNIZE TYPE " + structureToPlace); structureToPlace = null; } } else { structureToPlace = null; } }
public WorldMap(int x, int y) { sizeX = x; sizeY = y; worldMapDisplayData = new WorldMapTile[sizeX, sizeY]; locations = new LocationNode[sizeX, sizeY]; currentPos = new MapCoords(-1, -1); key = Globals.GenerateRandomHex(); }
private void buildPowerMap(MapCoords currentPoint, int currentPower, Dictionary <MapCoords, PowerableStructure> currentMap, Dictionary <MapCoords, PowerCarrier> carrierMap) { if (currentPower <= 0) { return; } if (data == null) { data = TiledMap.getInstance().mapData; } Structure structure = data.getStructure(currentPoint); if (structure == null) { return; } if (structure is PowerCarrier) { MapCoords[] adjacencies = new MapCoords[] { currentPoint, currentPoint.add(1, 0), currentPoint.add(-1, 0), currentPoint.add(0, 1), currentPoint.add(0, -1) }; foreach (MapCoords m in adjacencies) { Structure adjacent = data.getStructure(m); if (adjacent != null) { PowerCarrier carrier; if (adjacent is PowerCarrier && !carrierMap.TryGetValue(m, out carrier)) { carrierMap.Add(m, adjacent as PowerCarrier); buildPowerMap(m, currentPower - 1, currentMap, carrierMap); } PowerableStructure p; if (adjacent is PowerableStructure && !currentMap.TryGetValue(m, out p)) { currentMap.Add(m, adjacent as PowerableStructure); } } } } }
public void FillOutEVent(Actor source, TileNode target) { this.target = new MapCoords(target.data.posX, target.data.posY); if (addType == EffectToAddType.TargetActor) { if (target.HasActor()) { targetActor = target.actorOnTile.actorData; } } this.source = source.actorData; }
public override IEnumerator CalculateActions(List <AIAction> validActions, BoardManager bm, Actor ai) { MapCoords goal = PosOfClosestEnemy(ai, bm); //need to associate some kind of scoring for this // currently it's just going to be one so that it's alway valid for when there's not a target, but the // ai will always perform some action if it can MoveToPlayerAction move = new MoveToPlayerAction(ai, goal); move.SetScore(.2f); //should furth elaborate on this validActions.Add(move); yield return(null); }
public UploadingPointData ToUploadData() { var user = Membership.GetUser(); var myUID = user == null ? new Guid() : (Guid)user.ProviderUserKey; return(new UploadingPointData() { ID = ID, IsMyPoint = CreatorID == myUID || AccessHelper.IsMaster, IsRegion = MapCoords.Any(z => !z.IsMarker), PointPosition = MapCoords.First(z => z.IsMarker).ToCoordinate(), Description = Description, Name = Name, HeaderText = Address + " / " + (ObjectType == -1 ? " Зона «Не курят» / Курение запрещено" : (ObjectType == 0 ? " Зона «Спорная» / Курение разрешено" : " Зона «Курят» / Курение разрешено")), CommentsLink = CMSPage.Get("myobjects").FullUrl + "?oid=" + ID + "&uid=" + CreatorID, EditLink = CMSPage.Get("map").FullUrl + "#EditObj=" + ID, ImageLink = MapObjectPhoto == null ? "" : UniversalEditorPagedData.GetImageWrapper("MapObjectPhotos", "ObjectID", ID.ToString(), "RawData"), IsMyFavorite = false, //CreatorID == myUID, Address = Address, TypeID = TypeID, CommentCount = MapObjectComments.Count, SmokingType = ObjectType, RegionPosition = MapCoords.Where(z => !z.IsMarker) .OrderBy(x => x.OrderNum) .ToList() .Select(x => x.ToCoordinate()) .ToList(), IconNum = MapObjectType.Icon.Replace("icon-obj", ""), UserName = User.UserProfile.FullName, UserLink = User.UserProfile.EditProfilePage }); }
public bool buyStructure(Structure s, MapCoords coords) { if (!(map.mapData.getStructure(coords) is EmptyTile)) { return(false); } if (!(s is Purchasable)) { Debug.Log(s.ToString() + " is not purchasable!"); return(false); } Purchasable p = s as Purchasable; bool success = payMoney(p.price); if (success) { map.updateStructureTile(s, coords); } Debug.Log(s.ToString() + " purchased: " + success); return(success); }
private List <Structure> getAffectedStructures() { float damageRadius = spriteRenderer.bounds.extents.x; int maxTileXDamageLength = (int)System.Math.Ceiling(damageRadius / map.tileXLength); int maxTileYDamageLength = (int)System.Math.Ceiling(damageRadius / map.tileYLength); MapCoords location = map.getMapCoordsFromWorldCoords(trans.position); List <Structure> structures = new List <Structure> (); if (location == null) { return(structures); } for (int i = -maxTileXDamageLength; i <= maxTileXDamageLength; i++) { for (int j = -maxTileYDamageLength; j <= maxTileYDamageLength; j++) { Structure s = map.mapData.getStructure(location.add(i, j)); if (s is Destructable && s.gameObject != null) { Vector2 diffVector = s.gameObject.transform.position - trans.position; if (diffVector.magnitude < damageRadius) { structures.Add(s); } else { Vector2 furthestPoint = diffVector.normalized * damageRadius; if (s.gameObject.GetComponent <StructureObject>().spriteRenderer != null && s.gameObject.GetComponent <StructureObject>().spriteRenderer.bounds.Contains(furthestPoint)) { structures.Add(s); } } } } } return(structures); }
public void RpcDig(GamePosStruct posStruct) { GamePosition pos = GamePosition.ParseStruct(posStruct); MapCoords mapCoords = pos.toMapCoords(); Tile tile = mapData.getTile(mapCoords); bool redraw = false; if (tile.GetType().Equals(typeof(Wall))) { redraw = mapData.smartSet(mapCoords, new Dirt()); } else if (tile.GetType().Equals(typeof(Dirt))) { MapCoords lowerCoords = mapCoords.add(depth: 1); Tile lowTile = mapData.getTile(lowerCoords); if (lowTile != null && lowTile.GetType().Equals(typeof(Wall))) { bool redrawLower = mapData.smartSet(lowerCoords, new Dirt()); if (redrawLower) { redrawNonaTile(lowerCoords); } } if (lowTile != null) { redraw = mapData.smartSet(mapCoords, new Air(ConnectableVariant.None)); } } if (redraw) { redrawNonaTile(mapCoords); } }
private void InstantiateStructureObject(MapCoords coords, Structure s) { float xScaleFactor = tileXLength / structurePrefab.GetComponent <SpriteRenderer> ().sprite.bounds.size.x; float yScaleFactor = tileYLength / structurePrefab.GetComponent <SpriteRenderer> ().sprite.bounds.size.y; if (!(s is EmptyTile)) { Vector2 worldCoords = getWorldCoordsFromMapCoords(coords); GameObject sObj = GameObject.Instantiate(structurePrefab, worldCoords, Quaternion.identity); sObj.GetComponent <StructureObject> ().backingInfo = s; sObj.GetComponent <SpriteRenderer> ().sprite = s.sprite; sObj.transform.localScale = new Vector2(xScaleFactor, yScaleFactor); s.gameObject = sObj; } else { if (s.gameObject != null) { GameObject.Destroy(s.gameObject); } s.gameObject = null; } }
public void Select(MapCoords coords) { Structure s = map.mapData.getStructure(coords); if (s == null) { return; } highlighter.transform.position = map.getWorldCoordsFromMapCoords(coords); highlighter.GetComponent <SpriteRenderer>().enabled = true; destroyButton.enabled = true; destroyButton.image.enabled = true; destroyButton.GetComponentInChildren <Text> ().enabled = true; selected = coords; selectedImage.sprite = s.sprite; detailsText.enabled = true; detailsText.text = formatDetails(s.details); destroyButtonText.text = "(D) Destroy"; if (s is PowerPlant) { destroyButtonText.text = "(D) Lose Game"; } }
private void UpdatePowerStructureCaches(MapCoords startPoint, int startPower) { Dictionary <MapCoords, PowerableStructure> structuresToPower = new Dictionary <MapCoords, PowerableStructure>(); Dictionary <MapCoords, PowerCarrier> structuresToCarry = new Dictionary <MapCoords, PowerCarrier>(); buildPowerMap(startPoint, startPower, structuresToPower, structuresToCarry); List <PowerableStructure> structures = new List <PowerableStructure> (); foreach (PowerableStructure p in structuresToPower.Values) { structures.Add(p); } powerableCache = structures; List <PowerCarrier> carriers = new List <PowerCarrier> (); foreach (PowerCarrier p in structuresToCarry.Values) { carriers.Add(p); } powerCarrierCache = carriers; }
public CutsceneActionChangeCameraPosition(int x, int y) { this.newPos = new MapCoords(x, y); }
public CutsceneActionChangeCameraPosition(MapCoords newPos, bool snapCamera = false) { this.newPos = newPos; this.snapCamera = snapCamera; }
public override void ProcessInput() { //CameraControls(); selector.ProccessInput(inputHandler); if (Input.GetMouseButton(0) || inputHandler.IsKeyPressed(KeyBindingNames.Select)) { Vector2 pos = Globals.MouseToWorld(); TileNode currNode = selector.nodeSelected; MapCoords t = new MapCoords((int)pos.x, (int)pos.y); if (inputHandler.MouseButtonClicked() && (t.X == currNode.data.posX && t.Y == currNode.data.posY) == false) { selector.ProccessInput(inputHandler); return; } } else if (Input.GetMouseButton(1)) { Debug.Log("Right mouse clicked"); if (selector.nodeSelected.HasActor()) { //prebattle.partyEditPanel.PopulateCurrentDisplay(selector.nodeSelected.actorOnTile.actorData); } } else if (inputHandler.IsKeyPressed(KeyBindingNames.CycleRight)) { //down, increase index AdjustIndex(1); } else if (inputHandler.IsKeyPressed(KeyBindingNames.CycleLeft)) { //up the list, reduce index AdjustIndex(-1); } else if (inputHandler.IsKeyPressed(KeyBindingNames.PlaceUnit)) { TileNode currNode = selector.nodeSelected; //Checks to make sure there's a spawn point and that there's not a unit already there, it spawns it //If there is a unit there, remove it then place the new unit //If the unit is already on the field, remove it then place it if (vaidplacement.Contains(new MapCoords { X = currNode.data.posX, Y = currNode.data.posY })) { if (actorData.selected) { RemoveUnit(boardManager.pathfinding.GetTileNode(actorData.gridPosX, actorData.gridPosY)); } //There's a unit alrady here, replace it if (boardManager.pathfinding.tiles[currNode.data.posX, currNode.data.posY].actorOnTile != null) { RemoveUnit(currNode); } boardManager.spawner.GenerateActor(actorData, boardManager, currNode.data.posX, currNode.data.posY); actorData.selected = true; } } else if (inputHandler.IsKeyPressed(KeyBindingNames.RemoveUnit)) { if (vaidplacement.Contains(new MapCoords(selector.mapPosX, selector.mapPosY)) && selector.nodeSelected.HasActor()) { RemoveUnit(selector.nodeSelected); } } }