void Start() { onBeat = false; clicked = false; onePerBeat = false; scriptMaster = GameObject.FindGameObjectWithTag("GameController").GetComponent<GridManager>(); }
// Use this for initialization void OnTriggerEnter() { GameManager = GameObject.FindGameObjectWithTag ("Manager"); Grid = GameManager.GetComponent<GridManager> (); Donjon = GameManager.GetComponent<DungeonGenerator> (); foreach (GameObject room in Grid._Dungeon) { Destroy (room); } GameObject[] endroom = GameObject.FindGameObjectsWithTag ("End"); foreach (GameObject item in endroom) { if (item == gameObject) { } else { Destroy (item); } } GameObject[] coins = GameObject.FindGameObjectsWithTag ("Coin"); foreach (GameObject coin in coins) { Destroy (coin); } Donjon.NextLevel (); Destroy (gameObject); }
void Awake() { instance = this; //ICI: modifier cette affectation pour s'ajuster au personnage actuel player = GameObject.Find ("Player").transform.GetChild(actualPlayer).gameObject; }
//The grid should be generated on game start void Awake() { instance = this; setSizes(); createGrid(); generateAndShowPath(); }
/// <summary> /// class manages all mountain peaks /// </summary> public MountainPeaksManager(GridManager gridManager) { this.gridManager = gridManager; mountainPeaks = new MountainPeaksCoordinates(20, gridManager, this); mountainPeaks.InitializePeaks(20); //Debug.Log(mountainPeaks); }
void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>(); if (!player) Debug.Log("EndControll.cs: Player not Found!"); playerAnimator = player.GetComponentInChildren<PlayerAnimator>(); if (!playerAnimator) Debug.Log("EndControll.cs: PlayerAnimator not Found!"); gridManager = GameObject.FindObjectOfType<GridManager>(); if (!gridManager) Debug.Log("EndControll.cs: Grid Manager not Found!"); ui = GameObject.FindObjectOfType<UICollectionItems>(); if (!ui) Debug.Log("EndControll.cs: ui not Found!"); data = GameObject.FindObjectOfType<ParkourData>(); if (!data) Debug.Log("EndControll.cs: ParkourData not Found!"); mainParkour = GameObject.FindObjectOfType<MainParkour>(); if (!mainParkour) Debug.Log("EndControll.cs: MainParkour not Found!"); }
public void Start() { Floor floor = Helper.Find<Floor>("Floor"); gridManager = floor.GridManager; unit = GetComponent<BaseUnit>(); soundEffectPLayer = GetComponentInChildren<SoundEffectPlayer>(); LeaveSound = unit.GetComponent<BaseUnit>().LeaveSound; ArriveSound = unit.GetComponent<BaseUnit>().ArriveSound; if (LeaveSound.Any() || ArriveSound.Any()) { AudioSource audioSrc = gameObject.AddComponent<AudioSource>(); LeaveArriveEffectPlayer = gameObject.GetComponent<AudioSource>(); } if (unit is AvatarUnit) { isAvatarMover = true; currentAvatarUnit = (AvatarUnit)unit; } else { isAvatarMover = false; } }
// track the game state // track score // track money // track lives // Use this for initialization void Start() { curGameState = GameState.NotInGame; gameMenu = gameObject.GetComponent<GameMenu>(); enemyManager = gameObject.GetComponent < EnemyManager> (); gridManager = gameObject.GetComponent<GridManager> (); }
// Use this for initialization public override void Init() { CombatMoveEvent moveEvent = new CombatMoveEvent(); moveEvent.Character = Character; m_GridManager = GameObject.FindObjectOfType<GridManager>(); GridHex targetHex = m_GridManager.UniversalNPCTarget; GridHex currentHex = Character.transform.parent.gameObject.GetComponent<GridHex>(); if (currentHex != targetHex && targetHex.AvailableSpace >= 2) { moveEvent.FinalTarget = Pathfinding.PathToHex(currentHex, targetHex)[1]; OnQueueEvent(moveEvent); } /* // Random hex movement GridHex currentHex = Character.transform.parent.gameObject.GetComponent<GridHex>(); List<GridHex> availableHexes = new List<GridHex>(); for (int i = 0; i < 6; i++) { if (currentHex.AdjacentHexes[i] != null) availableHexes.Add(currentHex.AdjacentHexes[i]); } int targetHexIndex = Random.Range(0, availableHexes.Count - 1); moveEvent.FinalTarget = availableHexes[targetHexIndex]; */ }
void Awake() { instance = this; setSizes(); createGrid(); generateAndShowPath(); Messenger.AddListener("characterMoved", switchOriginAndDestTiles); }
void Start () { //Dependancy "GridManager" gridManagerObject = GameObject.FindGameObjectWithTag("GridManager"); gridManager = gridManagerObject.GetComponent<GridManager>(); //Dependancy "GridVariables" gridVar = GetComponent<GridVariables>(); UpdateLayer(); }
void Start() { gridManager = GameObject.FindObjectOfType<GridManager>(); worldPlacer = GameObject.FindObjectOfType<WorldPlacer>(); itemMenu = GameObject.FindObjectsOfType<ItemMenu>(); moneyManager = GameObject.FindObjectOfType<MoneyManager>(); importMenu = GameObject.FindObjectOfType<ImportMenu>(); }
// Use this for initialization void Start() { squarePixelWidth = MapInfo.squarePixelWidth; borderPixelWidth = MapInfo.borderPixelWidth; gridPixelWidth = MapInfo.gridPixelWidth; draggingTower = false; gridManager = gameObject.GetComponent<GridManager> (); inputHandler = gameObject.GetComponent<InputHandler> (); }
void Awake() { _instance = this; if( gridController == null ) { Debug.LogError("No IGridController assigned or found in scene."); } }
public static List<Tile> GenerateHexGrid(GridManager gm) { if(gm.hexTilePrefab==null) gm.hexTilePrefab=Resources.Load("HexTile", typeof(GameObject)) as GameObject; Transform parentTransform=gm.transform; float ratio=0.745f/0.86f; //0.86628f float hR=gm.gridToTileSizeRatio*gm.gridSize; float wR=hR*ratio; int counter=0; float highestY=-Mathf.Infinity; float lowestY=Mathf.Infinity; float highestX=-Mathf.Infinity; float lowestX=Mathf.Infinity; List<Tile> tileList=new List<Tile>(); for(int x=0; x<gm.width; x++){ float offset=0.5f*(x%2); int limit=0; if(x%2==1) limit=(int)(gm.length/2); else limit=(int)(gm.length/2+gm.length%2); for(int y=0; y<limit; y++){ float posX=x*wR;//-widthOffset; float posY=y*hR+hR*offset;//-lengthOffset; if(posY>highestY) highestY=posY; if(posY<lowestY) lowestY=posY; if(posX>highestX) highestX=posX; if(posX<lowestX) lowestX=posX; Vector3 pos=new Vector3(posX, gm.baseHeight, posY); GameObject obj=(GameObject)PrefabUtility.InstantiatePrefab(gm.hexTilePrefab); obj.name="Tile"+counter.ToString(); Transform objT=obj.transform; objT.parent=parentTransform; objT.localPosition=pos; objT.localRotation=Quaternion.Euler(-90, 0, 0); objT.localScale*=gm.gridSize*1.1628f; Tile hTile=obj.GetComponent<Tile>(); tileList.Add(hTile); counter+=1; } } float disY=(Mathf.Abs(highestY)-Mathf.Abs(lowestY))/2; float disX=(Mathf.Abs(highestX)-Mathf.Abs(lowestX))/2; foreach(Tile hTile in tileList){ Transform tileT=hTile.transform; tileT.position+=new Vector3(-disX, 0, -disY); hTile.pos=tileT.position; } return tileList; }
public PatchManager(int patchSize) { this.patchSize = patchSize; rMin = new GlobalCoordinates(100); rMax = new GlobalCoordinates(100); noise = new GlobalCoordinates(100); patchLevel = new GlobalCoordinates(100);//-1 = random,0=low,1=medium,2=high gm = new GridManager(new Vector3(0, 0, 0), patchSize, patchSize); SetPatchOrder(PatchOrder.LMH); }
// Use this for initialization public void Fill() { cible.Clear (); ratioMax = 0; ratioX = 0; ratioY = 0; ratio = 0; GameManager = GameObject.FindGameObjectWithTag ("Manager"); Grid = GameManager.GetComponent<GridManager> (); RoomLists = GameManager.GetComponent<RoomManager> (); for (int x = 0; x < Grid.DungeonLength; x++) { for (int y = 0; y < Grid.DungeonWidth; y++) { if (Grid._Dungeon [x, y] != null) { ratioX = 11 - x; ratioY = 11 - y; ratio = ratioX + ratioY; if (ratio < 0) { ratioX = x-11; ratioY = y-11; ratio = ratioX + ratioY; } if (ratio == ratioMax) { cible.Add(Grid._Dungeon[x,y]); } else { if (ratio > ratioMax) { ratioMax = ratio; cible.Clear(); cible.Add(Grid._Dungeon[x,y]); } } } } } foreach (GameObject room in cible) { GameObject EndRoom = Instantiate (End) as GameObject; EndRoom.transform.position = room.transform.position; } }
void Start () { currentLines = new int[lines.Length]; currentObjects = new MovableItemOnStage[lines.Length]; dirtyFlags = new bool[lines.Length]; gridManager = GameObject.FindObjectOfType<GridManager>(); for (int i = 0; i < currentLines.Length; i++) currentLines[i] = 0; }
//to grab four edges: //whoever wants to do this should just convert ij positions in grid to Vector3 positions public void Awake() { Instance = this; // Start with size of block, determine size of grid if (baseSize == null) { Debug.Log("Please assign a transform to grid's base size."); } BoxCollider2D box = baseSize.GetComponent<BoxCollider2D>(); xGridSize = box.size.x*xBuffer; yGridSize = box.size.y*yBuffer; //Doesn't really matter if collider or collider2D used //Just select a bounds Bounds bounds; if(GetComponent<Collider>()!=null) { bounds = GetComponent<Collider>().bounds; } else if (GetComponent<Collider2D>()!=null) { bounds = GetComponent<Collider2D>().bounds; } else { Debug.LogError("ERROR! no collider attached to grid!"); bounds = new Bounds(); } center = bounds.center; ext = new Vector3(0, 0, 0); float w; //width of entire grid float h; w = xGridSize * numColumns; h = yGridSize * numRows; ext.x = w / 2f; ext.y = h / 2f; //position of first block is at xOffset, yOffset xOffset = (center.x - ext.x + xGridSize / 2); yOffset = (center.y - ext.y + yGridSize / 2); //resize grid so it matches new ext values Vector3 newScale = new Vector3(ext.x / bounds.extents.x, ext.y / bounds.extents.y, 1f); float extraScale = 1.1f; transform.localScale = new Vector3(newScale.x * transform.localScale.x, newScale.y * transform.localScale.y, newScale.z * transform.localScale.z); transform.localScale *= extraScale; }
void Start () { //Dependancy "GridManager" gridManagerObject = GameObject.FindGameObjectWithTag("GridManager"); gridManager = gridManagerObject.GetComponent<GridManager>(); //Dependancy "GridVariables", "PlayerVariables" gridVar = GetComponent<GridVariables>(); playerVar = GetComponent<PlayerVariables>(); //Dependancy "GridLayer" gridLayer = GetComponent<GridLayer>(); //Set position of object based on current layer transform.position = new Vector3(transform.position.x, gridVar.gridLayer * gridManager.tileSize); }
static void GenerateHexGrid(GridManager gm, _TileType tileType) { if(tileType==_TileType.Square){ gm.width=8; gm.length=8; } //clear previous tile Tile[] allTilesInScene=(Tile[])FindObjectsOfType(typeof(Tile)); foreach(Tile tile in allTilesInScene){ if(tile.unit!=null) DestroyImmediate(tile.unit.gameObject); DestroyImmediate(tile); } /* for(int i=0; i<gm.allTiles.Count; i++){ if(gm.allTiles[i]!=null){ if(gm.allTiles[i].unit!=null) DestroyImmediate(gm.allTiles[i].unit.gameObject); DestroyImmediate(gm.allTiles[i].gameObject); } } gm.allTiles=new List<Tile>(); */ gm.type=tileType; if(gm.type==_TileType.Square) GridManagerEditor.GenerateSquareGrid(gm); else if(gm.type==_TileType.Hex) GridManagerEditor.GenerateHexGrid(gm); allTilesInScene=(Tile[])FindObjectsOfType(typeof(Tile)); List<Tile> tileList=new List<Tile>(); foreach(Tile tile in allTilesInScene){ tileList.Add(tile); } for(int i=0; i<tileList.Count; i++) tileList[i].gameObject.layer=8; //set neighbour for(int i=0; i<tileList.Count; i++){ Tile hT=tileList[i]; Vector3 pos=hT.transform.position; Collider[] cols=Physics.OverlapSphere(pos, gm.gridSize*gm.gridToTileSizeRatio*0.6f); List<Tile> neighbour=new List<Tile>(); foreach(Collider col in cols){ Tile hTile=col.gameObject.GetComponent<Tile>(); if(hTile!=null && hT!=hTile){ neighbour.Add(hTile); } } hT.SetNeighbours(neighbour); } gm.GenerateGrid(false); }
void Start () { floorTransform = gameObject.transform.GetChild(0); if (!floorTransform) Debug.Log("Floor not Found."); player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>(); if (!player) Debug.Log("Player not Found!"); gridManager = GameObject.FindObjectOfType<GridManager>(); if (!gridManager) Debug.Log("Grid Manager not Found!"); }
void Awake() { //Debug.Log("CombatManager::Start()"); m_CombatCharacters = new List<CombatCharacterController>(); for (int i = 0; i < ManualCharacterArray.Length; i++) { m_CombatCharacters.Add(ManualCharacterArray[i]); } CalculateTurnOrder(); m_GridManager = gameObject.GetComponent<GridManager>(); }
//Pause function added to the move (ends) public void Start() { try { _pauseMenuPanel = Helper.Find<RectTransform>("PauseMenuPanel"); _pauseMenuStartLocation = _pauseMenuPanel.rect.yMin; } catch (Exception) { //Continue with bussiness as usual... //Detta händer om det inte finns någon paus-meny och knapp } _mover = GetComponent<Mover>(); _rotation = GetComponentInChildren<Rotation>(); Floor floor = Helper.Find<Floor>("Floor"); _gridManager = floor.GridManager; _pathFinder = new PathFinder(_gridManager); //Audio related _lockAudioSourceLocation = this.gameObject.transform.rotation; _audioComponent = this.gameObject.transform.FindChild("AudioComponent").gameObject; _avatarSoul = GameObject.Find("AvatarSoul"); if (_avatarSoul != null) //ADD soul if it is multiple characters { _soulMover = _avatarSoul.GetComponentInChildren<SoulMover>(); //Om det finns en soul ta bort audio listener och ljus på avatar AudioListener audioList = GetComponent<AudioListener>(); Light lightOnChar = GetComponentInChildren<Light>(); if (audioList != null) { audioList.enabled = false; } if (lightOnChar != null) { lightOnChar.enabled = false; } } _soundEffectPlayer = GetComponentInChildren<SoundEffectPlayer>(); AvatarStates avatarStates = new AvatarStates(gameObject); _stateMachine = avatarStates.GetStateMachine(); }
public void ReceiveEventMethod(StaticEventMethods eventMessage, GridManager gridmanager) { gridManager = gridmanager; switch (eventMessage) { case StaticEventMethods.None: break; case StaticEventMethods.HideAndDisableObject: HideAndDisableObject(); break; case StaticEventMethods.ToggleHideDisableAndActiveVisibleObject: ToggleHideAndDisableObject(); break; case StaticEventMethods.TurnOffProjectileAndMedusa: TurnOffProjectileAndMedusa(); break; case StaticEventMethods.ToggleTurnOffProjectileAndMedusa: ToggleTurnOffProjectileAndMedusa(); break; case StaticEventMethods.MakeVisibleAndActive: MakeVisibleAndActive(); break; case StaticEventMethods.TurnOnProjectileAndMedusa: TurnOnProjectileAndMedusa(); break; case StaticEventMethods.PortalActivateAndMakeTileActive: PortalActivateAndMakeTileActive(); break; case StaticEventMethods.PortalDeactivate: PortalDeactivate(); break; case StaticEventMethods.PortalToggleActivate: PortalToggleActivate(); break; } }
public MountainPeaksCoordinates(int quadrantSize, GridManager gridManager, MountainPeaksManager mountainPeaksManager) { gm = gridManager; mpm = mountainPeaksManager; globalCenter = new MountainPeaks(0,0, gm.GetPointArea(0,0), mpm); quadrant1 = new MountainPeaks[quadrantSize, quadrantSize]; quadrant2 = new MountainPeaks[quadrantSize, quadrantSize]; quadrant3 = new MountainPeaks[quadrantSize, quadrantSize]; quadrant4 = new MountainPeaks[quadrantSize, quadrantSize]; InitialiseQuadrant(quadrant1, 1); InitialiseQuadrant(quadrant2, 2); InitialiseQuadrant(quadrant3, 3); InitialiseQuadrant(quadrant4, 4); }
public void setup(int _x, int _y, GridManager _manager){ xPos = _x; yPos = _y; manager = _manager; gameObject.name = "room_" + xPos + "_" + yPos; float offset = (float)gridSize / 2.0f; //Debug.Log ("offset: " + offset); transform.position = new Vector3 (xPos * gridSize - offset, yPos * gridSize - offset); grid = new Tile[gridSize, gridSize]; indicators = new GameObject[gridSize, gridSize]; if (isFirstRoom) { firstRoomRevealTiles = new List<RevealTile>(); } //add the grid indicators and default the grid to null for (int x=0; x<gridSize; x++) { for (int y=0; y<gridSize; y++) { GameObject newIndicator = Instantiate(gridIndicatorPrefab, Vector3.zero, new Quaternion(0,0,0,0)) as GameObject; newIndicator.transform.parent = transform; newIndicator.transform.localPosition = new Vector3 (x, y, 1); indicators[x,y] = newIndicator; grid[x,y] = null; //put a reveal tile here GameObject revealObj = Instantiate(revealTilePrefab, newIndicator.transform.position, Quaternion.identity) as GameObject; if (isFirstRoom) { RevealTile thisReveal = revealObj.GetComponent<RevealTile> (); if (x < 1 || x > 2 || y < 1 || y > 2) { thisReveal.isFrozen = true; } else { thisReveal.isFrozen = false; } firstRoomRevealTiles.Add (thisReveal); } } } }
public Controller() { _viewerServer = new Server(); _backboneServers = new BackboneServers(); _agentManager = new AgentManager(_viewerServer); _gridManager = new GridManager(_viewerServer, _agentManager); _scene = new SceneGraph(_viewerServer, _agentManager); ClientConnection.Grid = _gridManager; ClientConnection.Scene = _scene; ClientConnection.AgentManager = _agentManager; _viewerServer.Startup(); if(Globals.Instance.StartLoginServer) { _loginServer = new LoginServer(); _loginServer.Startup(); } }
public override void OnInspectorGUI() { GM = (GridManager)target; EditorGUILayout.LabelField("Scanning: " + GridManager.isScanning); GM.DebugLvl = (GridManager.DebugLevel)EditorGUILayout.EnumPopup("Debug Level: ", GM.DebugLvl); GUILayout.Space(10f); GM.grid.name = EditorGUILayout.TextField("Name: ", GM.grid.name); GM.grid.center = EditorGUILayout.Vector3Field("Center", GM.grid.center); GM.grid.WorldSize = EditorGUILayout.Vector2Field("World Size", GM.grid.WorldSize); GM.grid.NodeRadius = EditorGUILayout.FloatField("Node Radius", GM.grid.NodeRadius); GM.grid.angleLimit = EditorGUILayout.IntSlider("Max Angle", GM.grid.angleLimit, 0, 90); GM.grid.WalkableMask = LayerMaskField("Walkable Layer(s):", GM.grid.WalkableMask, true); GUILayout.Space(10); if (GUILayout.Button("Scan Grid")) { GridManager.ScanGrid(); } GUI.backgroundColor = Color.red; GUI.backgroundColor = Color.white; GUILayout.Space(10); }
public void SetToCellPosition(GridCell gc) { currentCell = gc; transform.position = GridManager.CellToWorldPos(currentCell); }
//Snap to current cell public virtual void Start() { currentCell = GridManager.Instance.WorldPosToGridCell(transform.position); transform.position = GridManager.CellToWorldPos(currentCell); }
public static List <Tile> GenerateHexGrid(GridManager gm) { if (gm.hexTilePrefab == null) { gm.hexTilePrefab = Resources.Load("HexTile", typeof(GameObject)) as GameObject; } Transform parentTransform = gm.transform; float ratio = 0.745f / 0.86f; //0.86628f float hR = gm.gridToTileSizeRatio * gm.gridSize; float wR = hR * ratio; int counter = 0; float highestY = -Mathf.Infinity; float lowestY = Mathf.Infinity; float highestX = -Mathf.Infinity; float lowestX = Mathf.Infinity; List <Tile> tileList = new List <Tile>(); for (int x = 0; x < gm.width; x++) { float offset = 0.5f * (x % 2); int limit = 0; if (x % 2 == 1) { limit = (int)(gm.length / 2); } else { limit = (int)(gm.length / 2 + gm.length % 2); } for (int y = 0; y < limit; y++) { float posX = x * wR; //-widthOffset; float posY = y * hR + hR * offset; //-lengthOffset; if (posY > highestY) { highestY = posY; } if (posY < lowestY) { lowestY = posY; } if (posX > highestX) { highestX = posX; } if (posX < lowestX) { lowestX = posX; } Vector3 pos = new Vector3(posX, gm.baseHeight, posY); GameObject obj = (GameObject)PrefabUtility.InstantiatePrefab(gm.hexTilePrefab); obj.name = "Tile" + counter.ToString(); Transform objT = obj.transform; objT.parent = parentTransform; objT.localPosition = pos; objT.localRotation = Quaternion.Euler(-90, 0, 0); objT.localScale *= gm.gridSize * 1.1628f; Tile hTile = obj.GetComponent <Tile>(); tileList.Add(hTile); counter += 1; } } float disY = (Mathf.Abs(highestY) - Mathf.Abs(lowestY)) / 2; float disX = (Mathf.Abs(highestX) - Mathf.Abs(lowestX)) / 2; foreach (Tile hTile in tileList) { Transform tileT = hTile.transform; tileT.position += new Vector3(-disX, 0, -disY); hTile.pos = tileT.position; } return(tileList); }
public void Outboundwormhole(string ip, string outfile, double xgate, double ygate, double zgate) { BoundingSphereD gate = new BoundingSphereD(new Vector3D(xgate, ygate, zgate), Config.InRadiusGate); foreach (var entity in MyAPIGateway.Entities.GetTopMostEntitiesInSphere(ref gate)) { var grid = (entity as VRage.Game.ModAPI.IMyCubeGrid); if (grid != null) { var playerInCharge = MyAPIGateway.Players.GetPlayerControllingEntity(entity); if (playerInCharge != null && OwnershipUtils.GetOwner(entity as MyCubeGrid) == playerInCharge.IdentityId)//hasrighttomove(playerInCharge, entity as MyCubeGrid)) { var WormholeDrives = new List <IMyJumpDrive>(); var gts = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(grid); gts.GetBlocksOfType(WormholeDrives); if (Config.DontNeedJD) { List <MyCubeGrid> grids = GridFinder.FindGridList(grid.EntityId.ToString(), playerInCharge as MyCharacter, Config.IncludeConnectedGrids); if (grids == null) { return; } if (grids.Count == 0) { return; } var filename = playerInCharge.SteamUserId.ToString() + "_" + grid.GetFriendlyName() + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"); Sandbox.Game.MyVisualScriptLogicProvider.CreateLightning(new Vector3D(xgate, ygate, zgate)); if (GridManager.SaveGrid(CreatePath(outfile, filename), filename, ip, Config.KeepOriginalOwner, Config.ExportProjectorBlueprints, grids)) { foreach (var delgrid in grids) { delgrid.Delete(); } } } else if (WormholeDrives.Count > 0) { foreach (var WormholeDrive in WormholeDrives) { if (WormholeDrive.OwnerId == playerInCharge.IdentityId && WormholeDrive.Enabled && WormholeDrive.CurrentStoredPower == WormholeDrive.MaxStoredPower && (WormholeDrive.BlockDefinition.SubtypeId.ToString() == Config.JumpDriveSubid || Config.WorkWithAllJD)) { WormholeDrive.CurrentStoredPower = 0; if (Config.DisableJD) { foreach (var jd in WormholeDrives) { jd.Enabled = false; } } List <MyCubeGrid> grids = GridFinder.FindGridList(grid.EntityId.ToString(), playerInCharge as MyCharacter, Config.IncludeConnectedGrids); if (grids == null) { return; } if (grids.Count == 0) { return; } var filename = playerInCharge.SteamUserId.ToString() + "_" + playerInCharge.DisplayName + "_" + grid.DisplayName + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"); Sandbox.Game.MyVisualScriptLogicProvider.CreateLightning(new Vector3D(xgate, ygate, zgate)); if (GridManager.SaveGrid(CreatePath(outfile, filename), filename, ip, Config.KeepOriginalOwner, Config.ExportProjectorBlueprints, grids)) { foreach (var delgrid in grids) { delgrid.Delete(); } } } } } } } } }
public void StartSimulation(List <Cell> inPath) { startCell = GridManager.GetCellAt(transform.position); path.AddRange(inPath); enabled = true; }
public static GridItem BelongsTo(Weapon wep) { return(GridManager.SnapToGrid(wep.transform.position)); }
public void FindSelectableTiles() { ComputeAdjacencyList(null); GetCurrentTile(); Queue <Tile> process = new Queue <Tile>(); process.Enqueue(currentTile); //add first tile to queue currentTile.visited = true; //currentTile.parent = null; while (process.Count > 0) { Tile t = process.Dequeue(); var enemy = t.CheckEnemyOccupied(t.gridCoord); if (enemy != null) { t.enemyOccupied = true; } //selectableTiles.Add(t); if (t.distance <= remainingMove) { if (t.blocked) { return; } if (!t.occupied) { t.selectable = true; } } else { if (t.blocked) { return; } t.inAttackRange = true; } if (t.distance < remainingMove + Range) { foreach (Tile tile in t.adjacencyList) { if (t.blocked) { return; } if (!tile.visited) { tile.parent = t; tile.visited = true; tile.distance = 1 + t.distance; process.Enqueue(tile); } } } //double check if (t.occupied) { enemy = t.CheckEnemyOccupied(t.gridCoord); if (enemy != null) { t.enemyOccupied = true; } } } GridManager.UpdateTilesGrid(); }
private void Start() { gm = GetComponent <GridManager>(); // Setup level characteristics for GridManager if (currentLevel == 0) { currentLevel = 1; } if (overrideLevelData) { LevelData newLevelData = new LevelData(inspectorGridWidth, inspectorGridHeight, 4, 0); gm.ReceiveLevelData(newLevelData.LevelTable[0]); } else { gm.ReceiveLevelData(levelData.LevelTable[LevelDataIndex]); } gm.Init(); // Setup GridObjectManager gom = GetComponent <GridObjectManager>(); if (overrideSpawnSequence.Length > 0) { for (int i = 0; i < overrideSpawnSequence.Length; i++) { gom.insertSpawnSequences.Add(overrideSpawnSequence[i].Clone()); } } if (VerboseConsole) { debugHUD = GameObject.FindGameObjectWithTag("Debug HUD").GetComponent <DebugHUD>(); } display = GameObject.FindGameObjectWithTag("Game Display").GetComponent <GameDisplay>(); // Setup Player Vector2Int startLocation = new Vector2Int(0, 0); if (overrideSpawnSequence.Length > 0) { startLocation = overrideSpawnSequence[0].playerSpawnLocation; } GameObject player = Instantiate(gom.playerPrefab, gm.GridToWorld(startLocation), Quaternion.identity); if (VerboseConsole) { Debug.Log(player.name + " has been instantiated."); } if (VerboseConsole) { Debug.Log("Adding Player to Grid."); } gm.AddObjectToGrid(player, startLocation); this.player = player.GetComponent <Player>(); this.player.currentWorldLocation = gm.GridToWorld(startLocation); this.player.targetWorldLocation = gm.GridToWorld(startLocation); if (VerboseConsole) { Debug.Log("Player successfully added to Grid."); } this.player.NextLevel(levelData.LevelTable[LevelDataIndex].jumpFuelAmount); // Initialize Game Object Manager now that player exists gom.Init(); this.player.OnPlayerAdvance += OnTick; }
private void btn_salva_Click(object sender, System.EventArgs e) { DocsPAWA.DocsPaWR.InfoUtente infoUtente = new DocsPAWA.DocsPaWR.InfoUtente(); infoUtente = UserManager.getInfoUtente(this.Page); if (txt_titolo.Text == null || txt_titolo.Text == "") { MessageBox1.Alert("Indicare un nome per il salvataggio del criterio di ricerca"); } else { if (schedaRicerca != null && schedaRicerca.ProprietaNuovaRicerca != null) { schedaRicerca.ProprietaNuovaRicerca.Id = Int32.Parse(this.idRicercaSalvata); schedaRicerca.ProprietaNuovaRicerca.Titolo = txt_titolo.Text; if (rbl_share.Items[0].Selected) { schedaRicerca.ProprietaNuovaRicerca.Condivisione = DocsPAWA.ricercaDoc.SchedaRicerca.NuovaRicerca.ModoCondivisione.Utente; } else if (rbl_share.Items[1].Selected) { schedaRicerca.ProprietaNuovaRicerca.Condivisione = DocsPAWA.ricercaDoc.SchedaRicerca.NuovaRicerca.ModoCondivisione.Ruolo; } try { string msg = string.Empty; string pagina = string.Empty; string _searchKey = schedaRicerca.getSearchKey(); System.Web.UI.Page currentPg = schedaRicerca.Pagina; if (string.IsNullOrEmpty(_searchKey)) { pagina = currentPg.ToString(); } else { pagina = _searchKey; } //Verifico se salvare anche la griglia string idGriglia = string.Empty; Grid tempGrid = new Grid(); if (ddl_ric_griglie.Visible) { idGriglia = ddl_ric_griglie.SelectedValue; if (!string.IsNullOrEmpty(idGriglia) && idGriglia.Equals("-2")) { tempGrid = GridManager.CloneGrid(GridManager.SelectedGrid); } } if (!schedaRicerca.verificaNomeModifica(txt_titolo.Text, infoUtente, pagina, this.idRicercaSalvata)) { schedaRicerca.Modifica(null, this.showGridPersonalization, idGriglia, tempGrid, GridManager.SelectedGrid.GridType); msg = "Il criterio di ricerca è stato modificato con nome '" + txt_titolo.Text + "'"; msg = msg.Replace("\"", "\\\""); DropDownList ddl = (DropDownList)schedaRicerca.Pagina.FindControl("ddl_Ric_Salvate"); Session["idRicSalvata"] = schedaRicerca.ProprietaNuovaRicerca.Id.ToString(); schedaRicerca.ProprietaNuovaRicerca = null; } else { msg = "Esiste già una ricerca salvata con questo nome!"; } CloseAndPostback(msg); } catch (Exception ex) { MessageBox1.Alert("Errore nel salvataggio della ricerca. Verificare i dati inseriti."); } } } }
protected void loadFields() { InfoUtente infoUtente = UserManager.getInfoUtente(this); DocsPaWR.DocsPaWebService docspaws = ProxyManager.getWS(); DocsPAWA.DocsPaWR.SearchItem itemOld = docspaws.RecuperaRicerca(Int32.Parse(idRicercaSalvata)); txt_titolo.Text = itemOld.descrizione; schedaRicerca.Tipo = itemOld.tipo; if (!string.IsNullOrEmpty(itemOld.owner_idPeople.ToString())) { this.rbl_share.SelectedValue = "usr"; } else { this.rbl_share.SelectedValue = "grp"; } DocsPAWA.DocsPaWR.Utente userHome = (DocsPAWA.DocsPaWR.Utente)Session["userData"]; DocsPAWA.DocsPaWR.Ruolo userRuolo = (DocsPAWA.DocsPaWR.Ruolo)Session["userRuolo"]; rbl_share.Items[0].Text = rbl_share.Items[0].Text.Replace("@[email protected]", userHome.descrizione); rbl_share.Items[1].Text = rbl_share.Items[1].Text.Replace("@[email protected]", userRuolo.descrizione); if (schedaRicerca.ProprietaNuovaRicerca.Condivisione == SchedaRicerca.NuovaRicerca.ModoCondivisione.Utente) { rbl_share.Items[0].Selected = true; rbl_share.Items[1].Selected = false; } else { rbl_share.Items[0].Selected = false; rbl_share.Items[1].Selected = true; } this.pnl_griglie_custom.Visible = this.showGridPersonalization; if (!IsPostBack && this.showGridPersonalization) { this.ddl_ric_griglie.Items.Clear(); //Vuol dire c'è una griglia temporanea if (GridManager.SelectedGrid != null && string.IsNullOrEmpty(GridManager.SelectedGrid.GridId)) { ListItem it = new ListItem("Griglia temporanea", "-2"); this.ddl_ric_griglie.Items.Add(it); } string visibility = rbl_share.SelectedValue; bool allGrids = true; if (visibility.Equals("grp")) { allGrids = false; } GridBaseInfo[] listGrid = GridManager.GetGridsBaseInfo(infoUtente, GridManager.SelectedGrid.GridType, allGrids); Dictionary <string, GridBaseInfo> tempIdGrid = new Dictionary <string, GridBaseInfo>(); if (listGrid != null && listGrid.Length > 0) { foreach (GridBaseInfo gb in listGrid) { ListItem it = new ListItem(gb.GridName, gb.GridId); this.ddl_ric_griglie.Items.Add(it); tempIdGrid.Add(gb.GridId, gb); } if (!string.IsNullOrEmpty(schedaRicerca.gridId) && tempIdGrid != null && tempIdGrid.Count > 0) { if (tempIdGrid.ContainsKey(schedaRicerca.gridId)) { this.ddl_ric_griglie.SelectedValue = schedaRicerca.gridId; } } } } }
void Start() { GridManagerObject = GridManager.instance; lerp = false; }
public override void execute() { GridManager.MoveDown(); }
public override void execute() { GridManager.MoveRight(); }
public void Start() { grid = FindObjectOfType <GridManager>(); }
public ShapeMovement(GridManager gridManager) { _gridManager = gridManager; }
protected void Page_Load(object sender, System.EventArgs e) { Utils.startUp(this); if (!IsPostBack) { this.listGrid = null; this.gridIdPreferred = string.Empty; SetTema(); SetUserRole(); InfoUtente infoUtente = UserManager.getInfoUtente(this); this.ddl_ric_griglie.Items.Clear(); if (GridManager.SelectedGrid != null) { this.listGrid = GridManager.GetGridsBaseInfo(infoUtente, GridManager.SelectedGrid.GridType, true); } else { this.listGrid = GridManager.GetGridsBaseInfo(infoUtente, GridTypeEnumeration.Document, true); } if (this.listGrid != null && this.listGrid.Length > 0) { int count = 0; foreach (GridBaseInfo gb in this.listGrid) { if (!gb.IsSearchGrid && !gb.GridId.Equals("-1")) { ListItem it = new ListItem(gb.GridName, gb.GridId); this.ddl_ric_griglie.Items.Add(it); if (gb.IsPreferred) { this.gridIdPreferred = gb.GridId; } count++; } } if (count > 0) { this.pnl_scelta.Visible = false; this.nuova_g.Visible = true; } else { //Ho solo la griglia standard quindi non posso modificare nulla devo per forza crearne una nuova this.pnl_scelta.Visible = false; this.nuova_g.Visible = true; this.rbl_save.Items[0].Selected = true; this.rbl_save.Items[1].Enabled = false; } } string result = string.Empty; if (Request.QueryString["tabRes"] != string.Empty && Request.QueryString["tabRes"] != null) { result = Request.QueryString["tabRes"].ToString(); } this.hid_tab_est.Value = result; this.bDeleteExtender.Enabled = false; // SetFocus(); } }
void Awake() { gridManager = GetComponent(); }
public void Initialize(GridManager owner, Vector2Int originalTileIndex) { TileOwner = owner; SetTileIndex(originalTileIndex, true); }
//private bool test = false; // Start is called before the first frame update void Start() { gridManager = GameObject.FindGameObjectWithTag("Grid Holder").GetComponent <GridManager>(); }
private void Awake() { gridReference = GetComponent <GridManager>(); }
void Start() { gridManager = GetComponentInParent <GridManager>(); }
void Start() { initObject(); loadPosition(); GridManager.loadGrid(sih); }
protected override void UnitUpdate() { //Do your stuff here //First combat (part of move timer?) Tile tile = GetComponentInParent <Tile>(); if (terrified) { if (this.hometile.coord == tile.coord) { terrified = false; } else { MoveUnit(this.hometile.coord - tile.coord); } return; } GridManager grid = this.transform.root.GetComponent <GridManager>(); Cultist cultist = tile.GetComponentInChildren <Cultist>(); Zombie zombie = tile.GetComponentInChildren <Zombie>(); Victim victim = tile.GetComponentInChildren <Victim>(); if (cultist != null) { Debug.Log("MORTAL COMMBAAAAT C"); //MORTAL COMBAAAAT cultist.LoseHealth(1); LoseHealth(1); } else if (zombie != null) { Debug.Log("MORTAL COMMBAAAAT Z"); //MORTAL COMBAAAAT zombie.LoseHealth(1); LoseHealth(1); } else if (victim != null) { //Free the victims from their oppressors! victim.LoseHealth(1); } else { //No combat or victims to save. //First: Think with your pants. Succubus foundSuccubus = LocateClosestGridEntity <Succubus>(1); if (foundSuccubus != null) { //Hey there cute stuff MoveUnit(foundSuccubus.GetComponentInParent <Tile>().coord - tile.coord); } else if (grid.IsValidTile(enemyLocation)) { //Check if we have an alert if (enemyLocation == tile.coord) { //Set it to null, we got to the point. enemyLocation.Set(-1, -1); } else { MoveUnit(enemyLocation - tile.coord); } } else { Cultist foundCultist = LocateClosestGridEntity <Cultist>(1); if (foundCultist != null) { //WE FOUND A CULTIST, FUCK EM UP Debug.Log("FOUND A CULTIST, GET EM"); MoveUnit(foundCultist.GetComponentInParent <Tile>().coord - tile.coord); } else if (!(tile is Castle)) { //We arn't on a castle, and there is nothing else to do. //Go home MoveUnit(this.hometile.coord - tile.coord); } } } }
// Use this for initialization void Start() { Vector2 v = GridManager.V2round(transform.position); GridManager.grid[(int)v.x, (int)v.y] = transform; }
void Start() { gridManager = GameObject.Find("Grid").GetComponent <GridManager>(); item = GetComponent <Item>(); }
public override void OnInspectorGUI() { gm = (GridManager)target; //DrawDefaultInspector(); EditorGUILayout.Space(); cont = new GUIContent("Randomize Grid On Start", "check to regenerate the tiles when the scene is loaded\nthis will generate all the units as well"); gm.randomizeGridUponStart = EditorGUILayout.Toggle(cont, gm.randomizeGridUponStart); cont = new GUIContent("Randomize Unit On Start", "check to regenerate the units on the grid when the scene is loaded\nexisting unit will be removed"); gm.randomizeUnitUponStart = EditorGUILayout.Toggle(cont, gm.randomizeUnitUponStart); cont = new GUIContent("Show Gizmo", "check to show gizmos on scene view"); gm.showGizmo = EditorGUILayout.Toggle(cont, gm.showGizmo); EditorGUILayout.Space(); int type = (int)gm.type; cont = new GUIContent("Grid Type:", "Turn mode to be used in this scene"); contL = new GUIContent[tileTypeLabel.Length]; for (int i = 0; i < contL.Length; i++) { contL[i] = new GUIContent(tileTypeLabel[i], tileTypeTooltip[i]); } type = EditorGUILayout.IntPopup(cont, type, contL, intVal); gm.type = (_TileType)type; cont = new GUIContent("Grid Size:", "The size of a single tile of the grid"); gm.gridSize = EditorGUILayout.FloatField(cont, gm.gridSize); EditorGUILayout.BeginHorizontal(); cont = new GUIContent("Num of Column:", "the width(x-axis) of the area to cover for the whole grid"); gm.width = EditorGUILayout.FloatField(cont, gm.width, GUILayout.ExpandWidth(true)); //~ gm.width=EditorGUILayout.FloatField(cont, gm.width, GUILayout.MinWidth(160)); //~ gm.width=Mathf.Round(Mathf.Clamp(gm.width, 0, 50)); //~ cont=new GUIContent("Actual:"+(gm.width*gm.gridSize).ToString("f2"), "after multiply the GridSize"); //~ EditorGUILayout.LabelField(cont, GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); cont = new GUIContent("Num of Row:", "the length(z-axis) of the area to cover for the whole grid"); gm.length = EditorGUILayout.FloatField(cont, gm.length, GUILayout.ExpandWidth(true)); //~ gm.length=EditorGUILayout.FloatField(cont, gm.length, GUILayout.MinWidth(160)); //~ gm.length=Mathf.Round(Mathf.Clamp(gm.length, 0, 50)); //~ cont=new GUIContent("Actual:"+(gm.length*gm.gridSize).ToString("f2"), "after multiply the GridSize"); //~ EditorGUILayout.LabelField(cont, GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); cont = new GUIContent("Area Height:", "the position of the grid on y-axis\nThis is a relative value from the GridManager's transform"); gm.baseHeight = EditorGUILayout.FloatField(cont, gm.baseHeight); //cont=new GUIContent("Max Height:", "the position of the grid on y-axis\nThis is a relative value from the GridManager's transform"); //gm.maxHeight=EditorGUILayout.FloatField(cont, gm.maxHeight); cont = new GUIContent("GridToTileSizeRatio:", "the size ratio of a single unit in the grid with respect to an individual tile"); gm.gridToTileSizeRatio = EditorGUILayout.FloatField(cont, gm.gridToTileSizeRatio); gm.gridToTileSizeRatio = Mathf.Max(0, gm.gridToTileSizeRatio); cont = new GUIContent("UnwalkableTileRate:", "the percentage of the unwalkable tile of the whole grid"); gm.unwalkableRate = EditorGUILayout.FloatField(cont, gm.unwalkableRate); gm.unwalkableRate = Mathf.Clamp(gm.unwalkableRate, 0f, 1f); if (gm.unwalkableRate > 0) { cont = new GUIContent("UseObstacle:", "the percentage of the unwalkable tile of the whole grid"); gm.useObstacle = EditorGUILayout.Toggle(cont, gm.useObstacle); bool changedFlag = GUI.changed; if (gm.useObstacle) { for (int n = 0; n < obstacleList.Count; n++) { GUI.changed = false; bool flag = false; if (n == 0) { flag = gm.enableInvUnwalkable; } else if (n == 1) { flag = gm.enableVUnwalkable; } else { if (gm.obstaclePrefabList.Contains(obstacleList[n])) { flag = true; } } cont = new GUIContent(" - " + obstacleNameList[n] + ":", ""); flag = EditorGUILayout.Toggle(cont, flag); if (n == 0) { gm.enableInvUnwalkable = flag; } else if (n == 1) { gm.enableVUnwalkable = flag; } else { if (GUI.changed) { if (gm.obstaclePrefabList.Contains(obstacleList[n])) { gm.obstaclePrefabList.Remove(obstacleList[n]); } else { gm.obstaclePrefabList.Add(obstacleList[n]); } GUI.changed = false; } } } } if (gm.obstaclePrefabList.Count == 0) { if (!gm.enableInvUnwalkable && !gm.enableVUnwalkable) { gm.enableVUnwalkable = true; } } EditorGUILayout.Space(); if (!GUI.changed) { GUI.changed = changedFlag; } } else { EditorGUILayout.Space(); } cont = new GUIContent("AddCollectible:", "check to add collectible items to the grid when generating the grid"); gm.addColletible = EditorGUILayout.Toggle(cont, gm.addColletible); if (gm.addColletible) { EditorGUILayout.BeginHorizontal(); cont = new GUIContent("CollectibleCount (min/max):", "The number of collectible to be spawned on the grid"); EditorGUILayout.LabelField(cont, GUILayout.MinWidth(170), GUILayout.MaxWidth(170)); gm.minCollectibleCount = EditorGUILayout.IntField(gm.minCollectibleCount, GUILayout.MaxWidth(30)); gm.maxCollectibleCount = EditorGUILayout.IntField(gm.maxCollectibleCount, GUILayout.MaxWidth(30)); EditorGUILayout.EndHorizontal(); bool changedFlag = GUI.changed; if (collectibleList.Count > 0) { for (int n = 0; n < collectibleList.Count; n++) { GUI.changed = false; bool flag = false; if (gm.collectiblePrefabList.Contains(collectibleList[n])) { flag = true; } cont = new GUIContent(" - " + collectibleNameList[n] + ":", ""); flag = EditorGUILayout.Toggle(cont, flag); if (GUI.changed) { if (gm.collectiblePrefabList.Contains(collectibleList[n])) { gm.collectiblePrefabList.Remove(collectibleList[n]); } else { gm.collectiblePrefabList.Add(collectibleList[n]); } GUI.changed = false; } } } else { EditorGUILayout.LabelField("- No collectible in CollectibleManager -"); } EditorGUILayout.Space(); if (!GUI.changed) { GUI.changed = changedFlag; } } else { EditorGUILayout.Space(); } //cont=new GUIContent("Tile Prefab:", "the gameObject prefab to be used as the tile"); //gm.tilePrefab=(GameObject)EditorGUILayout.ObjectField(cont, gm.tilePrefab, typeof(GameObject), false); if (gm.type == _TileType.Hex) { cont = new GUIContent("HexTile Prefab:", "the gameObject prefab to be used as the tile"); gm.hexTilePrefab = (GameObject)EditorGUILayout.ObjectField(cont, gm.hexTilePrefab, typeof(GameObject), false); } else if (gm.type == _TileType.Square) { cont = new GUIContent("SquareTile Prefab:", "the gameObject prefab to be used as the tile"); gm.squareTilePrefab = (GameObject)EditorGUILayout.ObjectField(cont, gm.squareTilePrefab, typeof(GameObject), false); } if (gc != null) { if (gc.playerFactionID.Count != gm.playerPlacementAreas.Count) { gm.playerPlacementAreas = MatchRectListLength(gm.playerPlacementAreas, gc.playerFactionID.Count); } for (int i = 0; i < gc.playerFactionID.Count; i++) { EditorGUILayout.Space(); cont = new GUIContent("Player (ID:" + gc.playerFactionID[i] + ") Placement Area:", "The area on the grid which player will be able to place the starting unit, as shown as the green colored square on the gizmo"); gm.playerPlacementAreas[i] = EditorGUILayout.RectField(cont, gm.playerPlacementAreas[i]); } if (gc.playerFactionID.Count == 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField("No player faction set in GameControl"); } } else { gc = (GameControlTB)FindObjectOfType(typeof(GameControlTB)); } EditorGUILayout.Space(); //cont=new GUIContent("Player Placement Area:", "The area on the grid which player will be able to place the starting unit, as shown as the green colored square on the gizmo"); //gm.playerPlacementArea=EditorGUILayout.RectField(cont, gm.playerPlacementArea); //~ showIndicatorList string label = "Indicators (Show)"; if (showIndicatorList) { label = "Indicators (Hide)"; } cont = new GUIContent(label, "list of various indicators used in run time. Optional. If left empty the defaults will be loaded"); showIndicatorList = EditorGUILayout.Foldout(showIndicatorList, cont); if (showIndicatorList) { gm.indicatorSelect = (Transform)EditorGUILayout.ObjectField("IndicatorSelect:", gm.indicatorSelect, typeof(Transform), false); gm.indicatorCursor = (Transform)EditorGUILayout.ObjectField("IndicatorCursor:", gm.indicatorCursor, typeof(Transform), false); gm.indicatorHostile = (Transform)EditorGUILayout.ObjectField("IndicatorHostile:", gm.indicatorHostile, typeof(Transform), false); } //~ gm.playerPlacementArea=EditorGUILayout.RectField("Player Placement Area:", gm.playerPlacementArea); int num; label = "Faction (Show)"; if (showFactionList) { label = "Faction (Hide)"; } cont = new GUIContent(label, "list of factions in this scene."); showFactionList = EditorGUILayout.Foldout(showFactionList, cont); if (showFactionList) { GUILayout.BeginHorizontal(); GUILayout.Space(15); GUILayout.BeginVertical(); cont = new GUIContent("Add Faction", "add a new faction to the list"); if (GUILayout.Button(cont)) { Faction fac = new Faction(); fac.factionID = gm.factionList.Count; fac.color = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), 1); gm.factionList.Add(fac); } for (int i = 0; i < gm.factionList.Count; i++) { Rect rectBase = EditorGUILayout.BeginVertical(); GUILayout.Space(5); rectBase.width += 5; rectBase.height += 0; GUI.Box(rectBase, ""); Faction fac = gm.factionList[i]; cont = new GUIContent("ID:", "The ID of the faction. 2 factions entry will the same ID will be recognised as 1 faction in runtime. Player's faction's ID is 0 by default"); fac.factionID = EditorGUILayout.IntField(cont, fac.factionID); cont = new GUIContent("Color:", "Color of the faction. This is simply for gizmo purpose to identify different spawn area in SceneView"); fac.color = EditorGUILayout.ColorField(cont, fac.color); cont = new GUIContent("Add Area", "add an additional spawn area for the faction"); if (GUILayout.Button(cont)) { FactionSpawnInfo sInfo = new FactionSpawnInfo(); if (fac.spawnInfo.Count > 0) { sInfo.area.x = fac.spawnInfo[fac.spawnInfo.Count - 1].area.x; sInfo.area.y = fac.spawnInfo[fac.spawnInfo.Count - 1].area.y; sInfo.area.width = fac.spawnInfo[fac.spawnInfo.Count - 1].area.width; sInfo.area.height = fac.spawnInfo[fac.spawnInfo.Count - 1].area.height; } fac.spawnInfo.Add(sInfo); } GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical(); for (int nn = 0; nn < fac.spawnInfo.Count; nn++) { FactionSpawnInfo sInfo = fac.spawnInfo[nn]; Rect rectSub = EditorGUILayout.BeginVertical(); rectSub.x -= 5; rectSub.width += 10; rectSub.height += 5; GUI.Box(rectSub, ""); int spawnQuota = (int)sInfo.spawnQuota; cont = new GUIContent("SpawnQuota:", "type of spawning algorithm to be used"); contL = new GUIContent[spawnQuotaLabel.Length]; for (int n = 0; n < contL.Length; n++) { contL[n] = new GUIContent(spawnQuotaLabel[n], spawnQuotaTooltip[n]); } spawnQuota = EditorGUILayout.IntPopup(cont, spawnQuota, contL, intVal); sInfo.spawnQuota = (_SpawnQuota)spawnQuota; if (sInfo.spawnQuota == _SpawnQuota.UnitBased) { cont = new GUIContent("Number to Spawn:", "number of unit to spawn for this spawn area"); sInfo.unitCount = EditorGUILayout.IntField(cont, sInfo.unitCount, GUILayout.MaxHeight(14)); } else if (sInfo.spawnQuota == _SpawnQuota.BudgetBased) { cont = new GUIContent("Spawn Budget:", "Point budget allocated for the units to be spawned"); sInfo.budget = EditorGUILayout.IntField(cont, sInfo.budget, GUILayout.MaxHeight(14)); } cont = new GUIContent("Spawn Area:", "The area covered in which the units will be spawned in"); sInfo.area = EditorGUILayout.RectField(cont, sInfo.area); cont = new GUIContent("Rotation:", "The direction which the unit spawned in this area will be facing"); contL = new GUIContent[rotationLabel.Length]; for (int n = 0; n < contL.Length; n++) { contL[n] = new GUIContent(rotationLabel[n], ""); } sInfo.unitRotation = EditorGUILayout.IntPopup(cont, sInfo.unitRotation, contL, intVal); label = "Unit Prefab Pool (Show)"; if (sInfo.showUnitPrefabList) { label = "Unit Prefab Pool (Hide)"; } cont = new GUIContent(label, "the list possible unit to be spawned in the area specified"); sInfo.showUnitPrefabList = EditorGUILayout.Foldout(sInfo.showUnitPrefabList, label); if (sInfo.showUnitPrefabList) { num = sInfo.unitPrefabs.Length; num = EditorGUILayout.IntField(" num of prefab:", num, GUILayout.MaxHeight(14)); if (num != sInfo.unitPrefabs.Length) { sInfo.unitPrefabs = MatchUnitPrefabListLength(sInfo.unitPrefabs, num); } if (num != sInfo.unitPrefabsMax.Length) { sInfo.unitPrefabsMax = MatchUnitPrefabMaxListLength(sInfo.unitPrefabsMax, num); } for (int n = 0; n < num; n++) { int unitID = -1; for (int m = 0; m < unitList.Count; m++) { if (unitList[m] == sInfo.unitPrefabs[n]) { unitID = m; break; } } EditorGUILayout.BeginHorizontal(); if (sInfo.spawnQuota == _SpawnQuota.UnitBased) { unitID = EditorGUILayout.IntPopup(" - unit" + n + "(max): ", unitID, unitNameList, intVal, GUILayout.MaxHeight(13)); sInfo.unitPrefabsMax[n] = EditorGUILayout.IntField(sInfo.unitPrefabsMax[n], GUILayout.MaxWidth(25)); } else if (sInfo.spawnQuota == _SpawnQuota.BudgetBased) { unitID = EditorGUILayout.IntPopup(" - unit" + n + "(max): ", unitID, unitNameList, intVal); } EditorGUILayout.EndHorizontal(); if (unitID >= 0) { sInfo.unitPrefabs[n] = unitList[unitID]; } else { sInfo.unitPrefabs[n] = null; } } } int totalUnitCount = 0; for (int n = 0; n < sInfo.unitPrefabsMax.Length; n++) { totalUnitCount += sInfo.unitPrefabsMax[n]; } sInfo.unitCount = Mathf.Min(totalUnitCount, sInfo.unitCount); cont = new GUIContent("Remove area", "remove this spawn area"); if (GUILayout.Button(cont)) { fac.spawnInfo.Remove(sInfo); } EditorGUILayout.EndVertical(); } GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.EndHorizontal(); GUILayout.Space(5); if (GUILayout.Button("Remove Faction")) { gm.factionList.Remove(fac); } GUILayout.Space(5); EditorGUILayout.EndVertical(); GUILayout.Space(5); } GUILayout.Space(10); GUILayout.EndVertical(); //~ GUILayout.Space (5); GUILayout.EndHorizontal(); } EditorGUILayout.Space(); cont = new GUIContent("Generate Grid", "Procedurally generate a new grid with the configured setting\nPlease note that generate a large map (30x30 and above) might take a while"); if (GUILayout.Button(cont)) { GenerateGrid(); } cont = new GUIContent("Generate Unit", "Procedurally place unit on the grid with the configured setting"); if (GUILayout.Button(cont)) { GenerateUnit(); } //~ if(GUILayout.Button("testGenerate")) TestGenerate(); //~ if(GUILayout.Button("testDestroy")) TestDestroy(); EditorGUILayout.Space(); if (GUI.changed) { EditorUtility.SetDirty(gm); } }
public static List <Tile> GenerateSquareGrid(GridManager gm) { if (gm.squareTilePrefab == null) { gm.squareTilePrefab = Resources.Load("SquareTile", typeof(GameObject)) as GameObject; } Transform parentTransform = gm.transform; int counter = 0; float highestY = -Mathf.Infinity; float lowestY = Mathf.Infinity; float highestX = -Mathf.Infinity; float lowestX = Mathf.Infinity; float gridSizeFactor = gm.gridToTileSizeRatio * gm.gridSize; List <Tile> tileList = new List <Tile>(); for (int x = 0; x < gm.width; x++) { for (int y = 0; y < gm.length; y++) { float posX = x * gridSizeFactor; float posY = y * gridSizeFactor; if (posY > highestY) { highestY = posY; } if (posY < lowestY) { lowestY = posY; } if (posX > highestX) { highestX = posX; } if (posX < lowestX) { lowestX = posX; } Vector3 pos = new Vector3(posX, gm.baseHeight, posY); GameObject obj = (GameObject)PrefabUtility.InstantiatePrefab(gm.squareTilePrefab); obj.name = "Tile" + counter.ToString(); Transform objT = obj.transform; objT.parent = parentTransform; objT.localPosition = pos; objT.localRotation = Quaternion.Euler(-90, 0, 0); objT.localScale *= gm.gridSize; Tile hTile = obj.GetComponent <Tile>(); tileList.Add(hTile); counter += 1; } } float disY = (Mathf.Abs(highestY) - Mathf.Abs(lowestY)) / 2; float disX = (Mathf.Abs(highestX) - Mathf.Abs(lowestX)) / 2; foreach (Tile hTile in tileList) { Transform tileT = hTile.transform; tileT.position += new Vector3(-disX, 0, -disY); hTile.pos = tileT.position; } return(tileList); }
public override void IterateOpenSet() { //Track how many iterations have taken place to find this pathway OpenSetIterations++; //Once the openset has been exhausted its time to complete the pathway if (OpenSet.Count <= 0) { //Get the completed pathway List <Node> Pathway = GridManager.Instance.GetCompletedPathway(PathStart, PathEnd); //If the path is empty, then no pathway was able to be found between the target nodes if (Pathway == null) { //Print a failure message and reset the grid Log.Print("Unable to find a valid pathway using Dijkstras algorithm."); FindingPathway = false; GridManager.Instance.HideAllParentIndicators(); return; } //Announce the pathway has been found Log.Print("Dijkstras pathfinding completed after " + OpenSetIterations + " iterations."); //Hide all the neighbour indicators GridManager.Instance.HideAllParentIndicators(); //Change the type of all nodes in the pathway to display it in the game foreach (Node PathStep in Pathway) { PathStep.SetType(NodeType.Pathway); } //Complete the process FindingPathway = false; return; } //Find the new current node, then iterate through all its neighbours Node Current = GridManager.Instance.FindCheapestNode(OpenSet); OpenSet.Remove(Current); foreach (Node Neighbour in GridManager.Instance.GetTraversableNeighbours(Current)) { //Ignore nodes not listed in the open set if (!OpenSet.Contains(Neighbour)) { continue; } //check if its cheaper to travel over this neighbour float NeighbourCost = Current.FScore + GridManager.FindHeuristic(Current, Neighbour); if (NeighbourCost < Neighbour.FScore) { //update this neighbour as the best way to travel Neighbour.FScore = NeighbourCost; Neighbour.Parent = Current; Neighbour.ToggleParentIndicator(true); Neighbour.PointIndicator(Neighbour.GetDirection(Current)); } } }
private void Start() { gridManager = GridManager.instance; outlineController = OutlineController.instance; }
public void CleanUp() { if (names != null) { names.Dispose(); names = null; } if (gridManager != null) { gridManager.Dispose(); gridManager = null; } if (rlv != null) { rlv.Dispose(); rlv = null; } if (client != null) { UnregisterClientEvents(client); } if (pluginManager != null) { pluginManager.Dispose(); pluginManager = null; } if (movement != null) { movement.Dispose(); movement = null; } if (commandsManager != null) { commandsManager.Dispose(); commandsManager = null; } if (ContextActionManager != null) { ContextActionManager.Dispose(); ContextActionManager = null; } if (mediaManager != null) { mediaManager.Dispose(); mediaManager = null; } if (state != null) { state.Dispose(); state = null; } if (netcom != null) { netcom.Dispose(); netcom = null; } if (mainForm != null) { mainForm.Load -= new EventHandler(mainForm_Load); } Logger.Log("RadegastInstance finished cleaning up.", Helpers.LogLevel.Debug); }
public override void execute() { GridManager.MoveLeft(); }