protected void PlaceObjects(GameObject[] listOfObjects, int objectsCount, List <Vector2> positions, bool alignToGround = false) { for (int i = 0; i < objectsCount; i++) { Vector3 centralPosition = transform.position; // Pick one type of building - some buildings could be placed only once in the village! GameObject objectToPlace = listOfObjects[UnityEngine.Random.Range(0, listOfObjects.Length)]; // Set position and rotation of the building in three steps: // get one position in x, and y dimensions: Vector2 position2D = positions[i]; int currentTerrainIndex = MapScript.GetTerrainForCoordinates(position2D.x, position2D.y); float objectToPlaceY = Terrain.activeTerrains[currentTerrainIndex].SampleHeight(new Vector3(centralPosition.x + position2D.x, 0, centralPosition.z + position2D.y)); objectToPlaceY += Terrain.activeTerrain.GetPosition().y; objectToPlaceY += 0.01f * i; // set position of the new object relative to the group center (parent transform): Vector3 desiredPosition = new Vector3(centralPosition.x + position2D.x, objectToPlaceY, centralPosition.z + position2D.y); // first, set random horizontal rotation along Y axis, then rotate verticaly acording to the ground: GameObject newObject = Instantiate(objectToPlace, desiredPosition, Quaternion.identity, transform); newObject.transform.Rotate(0f, UnityEngine.Random.Range(0, 350), 0f); if (alignToGround) { newObject.transform.rotation = AlignToGround.Align(newObject.transform); } } }
public void loadScene(string scene) { MapScript map = GameObject.FindGameObjectWithTag("Map").GetComponent("MapScript") as MapScript; map.changeToWhite(); SceneManager.LoadScene(scene); }
void Start() { gscript = GameObject.Find("Global").GetComponent <GlobalScript>(); mscript = GameObject.Find("Global").GetComponent <MapScript>(); idleAnimation = "look"; result = new float[3]; targetPos = new float[3]; startPos = new float[3]; oldTargetPos = new Vector3(0, 0, 0); target = GameObject.Find("Target"); player = GameObject.Find("Player"); behavior = (int)Behaviors.followpath; hidingLoc = new float[3]; frozen = false; rescueMission = false; wake = false; gangup = false; timer = 0; bullettimer = 0.0f; wakeupPeriod = 30.0f; gangupPeriod = 45.0f; hidingPeriod = 10.0f; }
private void Awake() { Mapping = new MapScript(Line, Min, Max); Maps = Mapping.Init(); do { x = Random.Range(0, Line); y = Random.Range(0, Line); NowMap = Maps[y, x]; } while (!NowMap.isLive); NowEnemy = NowMap.NowEnemy; foreach (MapScript.Map map in Maps) { if (map.isLive) { for (int i = 0; i < 5; i++) { map.Enemy[i] = Instantiate(Enemys[Random.Range(0, 3)], new Vector3(-8 + 4 * i, 10, 0), new Quaternion(0, 0, 0, 0), EnemyParent.transform); if (map != NowMap) { map.Enemy[i].SetActive(false); } } } } Enemy.OnEnemyDead += EnemyDead; }
void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>(); map = GetComponent<MapScript>(); delayBunnyTimer = new Timer(); }
public Map(int[] generatorSettings, MapScript mapScript) { metroStation = Resources.Load <Transform>("Prefabs/Infrastructure/MetroStation"); this.mapScript = mapScript; this.generatorSettings = generatorSettings; mapHeight = generatorSettings[(int)GeneratorSettings.MapHeight]; mapWidth = generatorSettings[(int)GeneratorSettings.MapWidth]; nPlayers = generatorSettings[(int)GeneratorSettings.BigDistricts]; initialDistrictSize = generatorSettings[(int)GeneratorSettings.DistrictSize]; nFacilities = generatorSettings[(int)GeneratorSettings.ResourceAmount];; District.SetNameArrayToFalse(); districts = new District[nPlayers]; facilities = new Facility[nFacilities]; backgroundTiles = new Tile[mapWidth, mapHeight]; roadTiles = new Tile[mapWidth, mapHeight]; houseTiles = new Tile[mapWidth, mapHeight]; resourceTiles = new Tile[mapWidth, mapHeight]; tileToRedraw = new bool[mapWidth, mapHeight]; GenerateMap(); }
private void Awake() { transform_ = transform; baseScale_ = transform.localScale; playerLayer_ = SceneGlobals.Instance.PlayerLayer; map_ = SceneGlobals.Instance.MapScript; }
public void blockPathPosition(Position pos) { bool positionIsInPath = false; int i = this._pathPositionIndex; while (!positionIsInPath && i < this._pathPositions.Count) { Position p = (Position)this._pathPositions[i]; positionIsInPath = (pos.isEqualTo(p)); i++; } if (positionIsInPath) { Position startPos = (Position)this._pathPositions[this._pathPositionIndex - 1]; Position endPos = MapScript.sharedInstance().getHomePosition(); ArrayList positions; if (PathScript.sharedInstance().existsPathFromPosToPos(startPos, endPos, out positions)) { PathScript.sharedInstance().addSegmentsFromPositions(positions); PathScript.sharedInstance().removeSegmentsFromPositions(this._pathPositions); this._pathPositions = positions; this._pathPositionIndex = 0; this.getNextPosition(); } } }
private bool shortestCurrentPath(out ArrayList checkpointsPositions) { Position doorPos = MapScript.sharedInstance().getDoorPosition(); Position homePos = MapScript.sharedInstance().getHomePosition(); return(this.existsPathFromPosToPos(doorPos, homePos, out checkpointsPositions)); }
void Start() { map = MapScript.current; mainCharTransform = MainCharacter.current.transform; ApplyPos(ClampPos(mainCharTransform.position)); }
private void Awake() { // gCost = Distance fromn starting node // hCost = How far away from target node // fCost = gCost + hCost map = GetComponent <MapScript>(); }
void Start() { gscript = GameObject.Find("Global").GetComponent <GlobalScript>(); mscript = GameObject.Find("Global").GetComponent <MapScript>(); idleAnimation = "look"; result = new float[3]; targetPos = new float[3]; startPos = new float[3]; oldTargetPos = new Vector3(0, 0, 0); seekTarget = GameObject.Find("Target"); target = seekTarget; occupyingSpot = null; occupying = false; seen = false; //GameObject hidingSpot = GameObject.Find("HidingSpot(Clone)"); //if (hidingSpot != null) { // target = hidingSpot; //} player = GameObject.Find("Player"); behavior = (int)Behaviors.followpath; InvokeRepeating("moveTargetAround", 1, 1); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { if (this._defenseInstanceToAdd != null || this._deleting) { MapScript mapScript = MapScript.sharedInstance(); if (mapScript.selectionIsVisible()) { if (this._defenseInstanceToAdd != null) { DefenseScript def = this._defenseInstanceToAdd.GetComponent <DefenseScript> (); if (PlayerScript.sharedInstance().getMoney() >= def.price) { Position selectionPos = mapScript.getSelectionPosition(); if (mapScript.tryToBlockPosition(selectionPos)) { Vector3 position = mapScript.getPointForMapCoordinates(selectionPos); this._defenseInstanceToAdd.transform.position = position; DefenseScript defenseScript = this._defenseInstanceToAdd.GetComponent <DefenseScript> (); defenseScript.setPosition(selectionPos); defenseScript.setUsable(true); defenseScript.showRadius(false); this._allDefenses.Add(defenseScript); BroadcastMessage("defenseWasAdded", defenseScript); this._defenseInstanceToAdd = (GameObject)Instantiate(this._defenseInstanceToAdd, MapScript.sharedInstance().hiddenPosition(), Quaternion.identity); } } } else { DefenseScript def; if (this.anyDefenseAtPosition(mapScript.getSelectionPosition(), out def)) { BroadcastMessage("defenseWasRemoved", def); this._allDefenses.Remove(def); GameObject defGO = def.gameObject; Destroy(defGO); } } } } } if (this._defenseInstanceToAdd != null) { MapScript mapScript = MapScript.sharedInstance(); DefenseScript ds = this._defenseInstanceToAdd.GetComponent <DefenseScript> (); if (mapScript.selectionIsVisible()) { Position selectionPos = mapScript.getSelectionPosition(); ds.setPosition(selectionPos); } else { ds.setPosition(new Position(-1, -1)); } } }
public void LoadMap(bool BackgroundOnly = false) { //Clear everything. ListTileSet = new List <Texture2D>(); FileStream FS = new FileStream("Content/Maps/Sorcerer Street/" + BattleMapPath + ".pem", FileMode.Open, FileAccess.Read); BinaryReader BR = new BinaryReader(FS, Encoding.UTF8); BR.BaseStream.Seek(0, SeekOrigin.Begin); //Map parameters. MapName = Path.GetFileNameWithoutExtension(BattleMapPath); LoadProperties(BR); LoadSpawns(BR); ListMapScript = MapScript.LoadMapScripts(BR, DicMapEvent, DicMapCondition, DicMapTrigger, out ListMapEvent); LoadTilesets(BR); LoadMapGrid(BR); BR.Close(); FS.Close(); TogglePreview(BackgroundOnly); }
private void Awake() { System.GC.Collect(0, System.GCCollectionMode.Forced, blocking: true, compacting: true); Instance = this; GameEvents.ClearListeners(); GameEvents.OnEnemyKilled += OnEnemyKilled; GameEvents.OnEnemySpawned += OnEnemySpawned; GameEvents.OnPlayerDamaged += OnPlayerDamaged; GameEvents.OnAutoPickUp += OnAutoPickUp; GameEvents.OnAmmoChanged += OnAmmoChanged; GameEvents.OnQuestCompleted += GameEvents_OnQuestCompleted; GameProgressData.CurrentProgress.QuestProgress.BeginQuestTracking(); map_ = SceneGlobals.Instance.MapScript; NextLevelPortal = GameObject.FindWithTag("PurplePortal").GetComponent <PortalScript>(); NextLevelPortal.gameObject.SetActive(false); NextLevelPortal.OnPlayerEnter.AddListener(OnPlayerEnterNextLevelPortal); BossPortal = GameObject.FindWithTag("GreenPortal").GetComponent <PortalScript>(); BossPortal.gameObject.SetActive(false); BossPortal.OnPlayerEnter.AddListener(OnPlayerEnterBossPortal); }
public Map(Game game) { Record = MapRecord.GetMap((int)Id); Script = CreateScript(game); Game = game; Units = new List <Unit>(); }
private void Awake() { transform_ = transform; baseScale_ = transform.localScale; enemyLayerMask_ = SceneGlobals.Instance.EnemyAliveMask; map_ = SceneGlobals.Instance.MapScript; }
void Start() { rigidBody = GetComponent <Rigidbody>(); tankAudio = GetComponents <AudioSource>(); mapGO = GameObject.Find("Map"); tankGO = GameObject.Find("Tank"); thisTransform = GetComponent <Transform>(); setEnemyResp(); enemyID = nextID; if (nextID < 2) { nextID++; } ammo = 100; ammoReloaded = true; agent = GetComponent <NavMeshAgent>(); r = getrandom.Next(6); setTarget(); mainThrust = 80f; torch = transform.Find("Light").GetComponent <Light>(); nightModeOn = MapScript.isNightModeOn(); torchManage(); gm = GameObject.Find("GameManager").GetComponent <GameManagerSc>(); }
private void LoadMap() { //Clear everything. ListBackgroundsPath = new List <string>(); ListForegroundsPath = new List <string>(); FileStream FS = new FileStream("Content/Maps/Deathmatch Maps/" + BattleMapPath + ".pem", FileMode.Open, FileAccess.Read); BinaryReader BR = new BinaryReader(FS, Encoding.UTF8); BR.BaseStream.Seek(0, SeekOrigin.Begin); //Map parameters. MapName = Path.GetFileNameWithoutExtension(BattleMapPath); LoadProperties(BR); LoadSpawns(BR); ListMapScript = MapScript.LoadMapScripts(BR, DicMapEvent, DicMapCondition, DicMapTrigger, out ListMapEvent); LoadTilesets(BR); LoadMapGrid(BR); BR.Close(); FS.Close(); }
public void levelLoad() { mapScript = GameObject.Find("MapAdmin").GetComponent <MapScript> (); startLoc = mapScript.getStartLoc(); enemyCounter = enemySpawnDelay = numEnemiesDestroyed = 0; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); MapScript map = target as MapScript; // map.GenerateMap(); }
private void Awake() { transform_ = transform; sqrPickupDistance_ = PickupDistance * PickupDistance; map_ = SceneGlobals.Instance.MapScript; renderer_ = GetComponent <SpriteRenderer>(); renderMaterial_ = renderer_.material; }
public void RegenMap() { GameObject mapScript = GameObject.FindGameObjectWithTag("MapTiles"); ms = mapScript.GetComponent <MapScript>(); ms.generatorSettings = this.generatorSettings; ms.ResetMap(); }
void Start() { topCam = GameObject.Find("Top Camera").GetComponent <Camera>(); perspCam = GameObject.Find("Persp Camera").GetComponent <Camera>(); marioCam = GameObject.Find("Mario Camera").GetComponent <Camera>(); mscript = GameObject.Find("Global").GetComponent <MapScript>(); gscript = GameObject.Find("Global").GetComponent <GlobalScript>(); }
public void levelLoad() { mapScript = GameObject.Find ("MapAdmin").GetComponent<MapScript> (); inputHandler = gameObject.GetComponent<InputHandler> (); startLoc = mapScript.getStartLoc(); enemyCounter = enemySpawnDelay = numEnemiesDestroyed = 0; }
void Start() { topCam = GameObject.Find("Top Camera").GetComponent<Camera>(); perspCam = GameObject.Find("Persp Camera").GetComponent<Camera>(); marioCam = GameObject.Find("Mario Camera").GetComponent<Camera>(); mscript = GameObject.Find("Global").GetComponent<MapScript>(); gscript = GameObject.Find("Global").GetComponent<GlobalScript>(); }
public StageCompleteTextOverlay(Texture2D sprWaveComplete, SpriteFont fntWaveNumber, int WaveNumber, FightingZone Map, MapScript Owner) { this.sprWaveComplete = sprWaveComplete; this.fntWaveNumber = fntWaveNumber; this.WaveNumber = WaveNumber; this.Map = Map; this.Owner = Owner; AnimationState = AnimationStates.Visible; }
void Start() { GameObject gm = GameObject.FindGameObjectWithTag("Game Manager"); map = gm.GetComponent<MapScript>(); gms = gm.GetComponent<GameManagerScript>(); Init(); jumpTimer = new Timer(jumpTime, () => FinishJump()); digTimer = new Timer(digTime, () => FinishDig()); movePositionTimer = new Timer(movePositionTime, () => SetPosition()); }
/// <summary> /// 卸载地图 /// </summary> public void Unload() { UnloadBgms(); m_script = null; if (m_view != null) { GameObject.Destroy(m_view); m_view = null; } }
private Vector3 GetRandomLandsCenter() { float x = Random.Range(100, 11900); float z = Random.Range(100, 11900); float y = MapScript.GetTerrainForCoordinates(x, z); Vector3 newCenter = new Vector3(x, y, z); return(newCenter); }
public static void setEnemyResp() { MapScript mapScript = mapGO.GetComponent <MapScript>(); int mapSize = mapScript.getMapSize(); int mapCenter = mapSize / 2; enemyRespawn[1] = new Vector3(mapCenter, 0.5f, mapSize - 2); enemyRespawn[0] = new Vector3(1f, 0.5f, mapSize - 2); enemyRespawn[2] = new Vector3(mapSize - 2, 0.5f, mapSize - 2); }
IEnumerator Start() { LoadingCanvas.gameObject.SetActive(true); ShowPlayerName(false); HumanPlayerController.CanShoot = false; ControlsText.gameObject.SetActive(GameProgressData.CurrentProgress.NumberOfDeaths == 0); while (!PlayFabFacade.Instance.LoginProcessComplete) { yield return(null); } Weapons.LoadWeaponsFromResources(); Enemies.LoadEnemiesFromResources(); QuestPortal.SetActive(false); LoadingCanvas.gameObject.SetActive(false); IntroCanvas.gameObject.SetActive(true); string ghostPath = PlayerPrefs.GetString("LatestCampPath"); try { if (string.IsNullOrWhiteSpace(ghostPath)) { PlayFabFacade.AllData.InfoResultPayload.TitleData.TryGetValue("DefaultCampGhost", out ghostPath); } GhostPath.FromString(ghostPath); if (GhostPath.HasPath) { var ghost = Instantiate(GhostPlayerPrefab, Vector3.left * 10000, Quaternion.identity); ghostScript_ = ghost.GetComponent <GhostPlayerScript>(); } } catch (System.Exception) { } camPos_ = SceneGlobals.Instance.CameraPositioner; camShake_ = SceneGlobals.Instance.CameraShake; lightingImageEffect_ = SceneGlobals.Instance.LightingImageEffect; mapAccess_ = SceneGlobals.Instance.MapAccess; mapScript_ = SceneGlobals.Instance.MapScript; lightingImageEffect_.Darkness = 0.0f; SceneGlobals.Instance.GraveStoneManager.CreateGravestones(); mapAccess_.BuildCollisionMapFromWallTilemap(mapScript_.FloorTileMap); SetLighting(MenuLightingSettings); CreateCharacters(); ActivateLatestSelectedCharacter(); StartCoroutine(InMenu()); }
private static MapScript[] CreateMapScripts(Script[] scripts) { var result = new MapScript[scripts.Length]; for (var i = 0; i < scripts.Length; i++) { result[i] = CreateMapScript(scripts[i]); } return(result); }
} // Sets the camera to match the map size private void InstanceMap() { if (instance) { Destroy(gameObject); } else { instance = this; } } // Magic, dont touch. Sometimes it works, sometimes it dont.
void Start () { user = GameObject.FindGameObjectWithTag("Network").GetComponent<UserScript>(); network = GameObject.FindGameObjectWithTag("Network").GetComponent<SocketScript>(); myMap = transform.GetChild(0).GetComponent<MapScript>(); otherMap = transform.GetChild(1).GetComponent<MapScript>(); menuPanel = Menu.GetComponent<Menu>(); network.MapManager = this; InitCharacters(); }
public void levelLoad() { mapScript = GameObject.Find ("MapAdmin").GetComponent<MapScript> (); curMoney = mapScript.startingMoneyAmount; numTotalRounds = mapScript.getNumRounds(); gameMenu.setCurMoney(curMoney); curGameState = GameState.RoundNotStarted; roundNum = 0; numKills = 0; enemyManager.levelLoad (); gridManager.levelLoad (); }
void Awake() { singleton = this; }
void OnDestroy() { singleton = null; }
public void CharaterSelect(MapScript map, CharacterScript selectedHero, bool isPrepositioning) { HighLight.transform.position = new Vector3(selectedHero.transform.position.x, 13.5f, selectedHero.transform.position.z); HighLight.transform.parent = selectedHero.transform; Debug.Log("Select:" + map + " " +selectedHero +" "+ isPrepositioning); if (isPrepositioning) { map.ChangeState(MapSelectState.MOVE_SELECT); } else { network.CharacterSelect(selectedHero.Index); menuPanel.SetTarget(selectedHero); } }
// Use this for initialization void Start() { map= GameObject.Find("Map").GetComponent<MapScript>(); click = false; }
// Use this for initialization void Start() { counter = gameObject.GetComponent<Text> (); mapScript = mainCamera.GetComponent<MapScript> (); counter.text = "Start!"; }
/// <summary> /// 从缓存中取映射脚本 /// </summary> /// <param name="strMapID"></param> /// <param name="objScript"></param> /// <returns></returns> public static bool GetCacheMapScript(string strMapID, ref SmsServer.Model.MapScript objScript) { bool bExist = false; lock (pMapScriptList) { bExist = pMapScriptList.ContainsKey(strMapID); if (bExist) { objScript = pMapScriptList[strMapID]; } } if (!bExist) { objScript = new MapScript().GetSelectMapScript(strMapID); if (objScript == null) { return false; } AddCacheMapScript(objScript); } return true; }
void Start() { gscript = GameObject.Find("Global").GetComponent<GlobalScript>(); mscript = GameObject.Find("Global").GetComponent<MapScript>(); idleAnimation = "look"; result = new float[3]; targetPos = new float[3]; startPos = new float[3]; oldTargetPos = new Vector3(0,0,0); seekTarget = GameObject.Find("Target"); target = seekTarget; occupyingSpot = null; occupying = false; seen = false; //GameObject hidingSpot = GameObject.Find("HidingSpot(Clone)"); //if (hidingSpot != null) { // target = hidingSpot; //} player = GameObject.Find("Player"); behavior = (int)Behaviors.followpath; InvokeRepeating ("moveTargetAround", 1, 1); }