private void CreateMap() { GlobalMap.MapBounds = MapSize; GlobalMap.Map = new Tile[MapSize.x, MapSize.y]; GlobalMap.FillMap(selftTrans.position, TilePrefab, DefaultData); }
public void Load(System.IO.FileStream fs) { var data = new byte[24]; fs.Read(data, 0, data.Length); newWindVector = new Vector2(System.BitConverter.ToSingle(data, 0), System.BitConverter.ToSingle(data, 4)); windVector = new Vector2(System.BitConverter.ToSingle(data, 8), System.BitConverter.ToSingle(data, 12)); windTimer = System.BitConverter.ToSingle(data, 20); vegetationShaderWindPropertyID = Shader.PropertyToID("_Windpower"); float windPower = windVector.magnitude; Shader.SetGlobalFloat(vegetationShaderWindPropertyID, windPower); if (WindUpdateEvent != null) { WindUpdateEvent(windVector); } skyboxMaterial = RenderSettings.skybox; gmap = GameMaster.realMaster.globalMap; SetEnvironment(gmap.GetCurrentEnvironment()); RecalculateCelestialDecorations(); prepared = true; }
public void Initial() { map = GlobalMap.GetMap(); mapSize = GlobalMap.GetMapSize(); mapIndex = 0; resurrectionIndex = 0; GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz); GlobalMap.SetWinFlag(0); transform.position = new Vector3(0, 0, 0); now_x = transform.position.x; //now_y = transform.position.y; now_z = transform.position.z; ground_index = 0; resurrectionPoint = new MyPoint((int)now_x, (int)now_z, 2.5, 2.5); ground[ground_index] = new MyPoint((int)now_x, (int)now_z, 2.5, 2.5); ground[1 - ground_index] = new MyPoint((int)now_x + dx, (int)now_z + dz, 2.5, 2.5); rotation_count = 0; isalive = 1; speed = spee_default; max_x = min_x = (int)now_x; max_z = min_z = (int)now_z; nowScore = 0; lastScore = 0; continueCount = 3; ui_gameSystem.ContinueTextUpdate(continueCount); transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); }
public void Initial() { map = GlobalMap.GetMap(); mapSize = GlobalMap.GetMapSize(); mapIndex = 0; now_x = (int)hero.position.x; now_y = (int)hero.position.y - 2; now_z = (int)hero.position.z; dx = 0; dz = 5; while (groundQueue.Count > 0) { Destroy(groundQueue.Peek()); groundQueue.Dequeue(); } while (scoreQueue.Count > 0) { Destroy(scoreQueue.Peek()); scoreQueue.Dequeue(); } for (int i = 0; i < groundList.Count; ++i) { Destroy(groundList [i]); } groundList.Clear(); GlobalMap.SetWinFlag(0); }
/// <summary> /// This is called to create a default file /// </summary> public virtual void InitDefaults() { GlobalMap.Add(new ViewAction() { EventName = "Click", EventHandlerName = "EventHandler", EventArgsName = "EventArgs" }); var textBoxAction = new ViewActions(); textBoxAction.Add(new ViewAction() { EventName = "TextChanged", EventHandlerName = "EventHandler", EventArgsName = "EventArgs" }); ControlActionMap.Add(new ViewControlAction() { ControlType = "TextBox", ControlActions = textBoxAction }); var comboBoxAction = new ViewActions(); comboBoxAction.Add(new ViewAction() { EventName = "CheckedChanged", EventHandlerName = "EventHandler", EventArgsName = "EventArgs" }); ControlActionMap.Add(new ViewControlAction() { ControlType = "CheckBox", ControlActions = comboBoxAction }); }
void SelectPoint(RaycastHit2D hit) { if (!EventSystem.current.IsPointerOverGameObject()) { if (hit.transform == transform) { if (NameLoc == "C0") { SceneManager.LoadScene("Town"); } else { bool isnearPoint = false; for (int i = 0; i < nearPoint.Length; i++) { if (GameManager.instance.HeroPos == nearPoint[i].name) { isnearPoint = true; } } if (isnearPoint) { GlobalMap gm = Camera.main.GetComponent <GlobalMap>(); gm.ShowInfoPanel(NameLoc); } } } } }
public void OnPointerDown(PointerEventData eventData) { GlobalMap gm = Camera.main.GetComponent <GlobalMap>(); if (NameLoc == "C0") { SceneManager.LoadScene("Town"); } /* * else if (GameManager.instance.locations[NameLoc] == 2) * { * gm.ShowInfoPanel(NameLoc); * }*/ else { bool isnearPoint = true; for (int i = 0; i < nearPoint.Length; i++) { if (GameManager.instance.HeroPos == nearPoint[i].name) { isnearPoint = true; } } if (isnearPoint) { gm.ShowInfoPanel(NameLoc); } } }
public override void Live() { if (Satiety <= 0 || Dead) { Dead = true; } else if (GlobalMap.CheckTime()) { CurrentBirthCooldown--; Sleep(); } else if (Satiety <= SatTreshold) { CurrentBirthCooldown--; FindFood(); Eat(); } else if (FoundPartner == null) { RandomMove(); CurrentBirthCooldown--; if (CurrentBirthCooldown < BirthCooldown) { FindPartner(); } } else if (FoundPartner != null) { MoveTo(DateX, DateY); ProduceNewUnit(); } }
private void setupEnvironments(Car car, World world, Game game, Move move) { TilePos.TileSize = game.TrackTileSize; GlobalMap.InstanceInit(world); GlobalMap.Instance.SetupEnvironment(world, game); AngleReachEvent.setupEnvironment(game); MoveToAngleFunction.setupEnvironment(world); MoveToPoint.setupEnvironment(world); PhysicExtensions.setupEnvironment(game); PhysicEventsCalculator.setupEnvironment(game, world); CollisionSide.SetupEnvironment(game); CollisionCircle.SetupEnvironment(game); CollisionDetector.SetupEnvironment(game, GlobalMap.Instance); map.SetupEnvironment(car, GlobalMap.Instance); path.SetupEnvironment(car, GlobalMap.Instance, world, game); foreach (IAction action in actions.Values) { action.setupEnvironment(car, world, game, path); } foreach (AdditionalPoints action in additionalPointsActions) { action.setupEnvironment(car, world, game, path); } }
void Start() { Debug.Log(CYWGlobal.gameSelect); GlobalMap.UpdateMap(); StartCoroutine(MyLoadScene()); }
void Start() { map = GlobalMap.instance; if (camera == null) { camera = Camera.main; } }
void Update() { mousePos = cam.ScreenToWorldPoint(Input.mousePosition); if (Input.GetMouseButton(0) || Input.GetMouseButton(1)) { Indice = GlobalMap.NearestIndice(mousePos); } }
public void MapGeneration() { GlobalMap.Generate_Map(BiomePrefabs[0]); PlayerXMap = (int)GlobalMap.Biomes[0].Center.x; PlayerYMap = (int)GlobalMap.Biomes[0].Center.y; SetGlobalEntities(); SpawnCorridor(DirectionType.North); Player.GetComponent <PlayerControls>().ShowHideMenu(); Player.transform.position = new Vector3(0.0f, 0.0f, Player.transform.position.z); }
public static string[] GetSpeciesList(string prefixText, int count, string contextKey) { List <string> arrayList = new List <string>(); foreach (Species s in GlobalMap.GetInstance().SpeciesList) { arrayList.Add(s.AlphaCode + " (" + s.CommonName + ")"); } return(arrayList.ToArray <string>()); }
public void SetGlobalMap(GlobalMap gm) { if (gm == null) { return; } globalMap = gm; ringsRotation = globalMap.ringsRotation; mapPoints = globalMap.mapPoints; }
void Awake() { if (instance == null) { instance = this; } else { Debug.Log("More than 1 instance " + this.GetType().ToString()); Destroy(this); } }
protected List <TTargetToSearch> LocateTarget <TTargetToSearch>() { int[] wayX = { -1, 0, 1, 0 }; int[] wayY = { 0, 1, 0, -1 }; int radius = 8; int[] anotherWay = { -1, 1 }; List <TTargetToSearch> list = new List <TTargetToSearch>(); for (int i = 0; i < wayX.Length * radius; i++) { int k = i / wayX.Length + 1; int moveRight = wayY[i % 4] * k; int moveForward = wayX[i % 4] * k; if (i % 2 == 1) { for (int j = 0; j < anotherWay.Length * radius; j++) { int c = j / anotherWay.Length + 1; moveForward = anotherWay[j % 2] * c; if (GlobalMap.CheckBorder(X + moveForward, Y + moveRight)) { if (GlobalMap.Field[X + moveForward, Y + moveRight].Entity.OfType <TTargetToSearch>().FirstOrDefault() != null) { foreach (var target in GlobalMap.Field[X + moveForward, Y + moveRight].Entity.OfType <TTargetToSearch>()) { list.Add(target); } } } } } else if (GlobalMap.CheckBorder(X + moveForward, Y + moveRight)) { if (GlobalMap.Field[X + moveForward, Y + moveRight].Entity.OfType <TTargetToSearch>().FirstOrDefault() != null) { foreach (var target in GlobalMap.Field[X + moveForward, Y + moveRight].Entity.OfType <TTargetToSearch>()) { list.Add(target); } } } } return(list); }
// Update is called once per frame void LateUpdate() { //tmp = GetComponent<SphereRun> (); if (!GlobalMap.GetWinFlag()) { transform.position = target.position - target.transform.rotation * Vector3.forward * 20 + target.transform.rotation * Vector3.up * 20; transform.rotation = target.rotation; transform.Rotate(40, 0, 0); //transform.position = target.position - Vector3.forward * 20 + Vector3.up * 20; } else { } }
public void SaveGame() { GlobalMap map = GlobalMap.instance; save = new SaveData( map.mapSizeX, map.mapSizeZ, map.selectedUnit.GetComponent <Unit>(), map.tiles, UnitList.instance, map.mapObjects, Inventory.PlayerInventory ); SaveSystem.Save(SaveName, save); }
public void Prepare() { if (prepared) { return; } else { prepared = true; } vegetationShaderWindPropertyID = Shader.PropertyToID("_Windpower"); if (!GameMaster.loading) { windVector = Random.insideUnitCircle; newWindVector = windVector; } Shader.SetGlobalFloat(vegetationShaderWindPropertyID, 1); sun = FindObjectOfType <Light>(); if (sun == null) { sun = new GameObject("sun").AddComponent <Light>(); sun.type = LightType.Directional; } sunTransform = sun.transform; decorations = new List <Transform>(); skyboxMaterial = RenderSettings.skybox; gm = GameMaster.realMaster; globalMap = gm.globalMap; SetEnvironment(Environment.defaultEnvironment); if (gm.gameMode != GameMode.Editor) { RefreshVisual(); RecalculateCelestialDecorations(); } else { } islandStability = DEFAULT_ISLAND_STABILITY; globalMap?.LinkEnvironmentMaster(this); if (GameMaster.realMaster.IsInTestMode) { AnnouncementCanvasController.MakeAnnouncement("environment master loaded"); } }
void Start() { currentHealth = MaxHealth; currentMovePoint = MaxMovePoints; currentIndice = StartIndice; prevIndice = currentIndice; selfTrans = transform; MoveToTile(GlobalMap.GetTile(currentIndice)); if (PlayerTileData.filter == PlayerFilter.PLAYER_ONE) { GlobalMap.SetPointTile(StarData); } }
public override void TakeAction(PlayerController ctrl) { Tile tile = GlobalMap.GetTile(ctrl.currentIndice + Direction); ctrl.prevIndice = ctrl.currentIndice; ctrl.currentIndice = tile.Indice; ctrl.selfTrans.position = tile.Position; tile.RefreshData(ctrl.PlayerTileData); tile.UpdateTile(); GlobalMap.GetTile(ctrl.prevIndice).ResetTile(); TurnTimer.SwitchPlayers(ctrl.PlayerTileData.filter); Debug.Log("Move Tile move " + ctrl.name + " to indice: " + (tile.Indice)); }
public Expedition Load(System.IO.Stream fs) { int LENGTH = 28; // (id excluded) var data = new byte[LENGTH]; fs.Read(data, 0, LENGTH); hasConnection = data[0] == 1; crystalsCollected = System.BitConverter.ToUInt16(data, 1); suppliesCount = data[3]; stage = (ExpeditionStage)data[4]; int x = System.BitConverter.ToInt32(data, 5); if (x != NO_VALUE) { destination = GameMaster.realMaster.globalMap.GetMapPointByID(x) as PointOfInterest; destination?.AssignExpedition(this); } else { destination = null; } crew = Crew.GetCrewByID(System.BitConverter.ToInt32(data, 9)); if (crew != null) { crew.SetCurrentExpedition(this); } artifact = Artifact.GetArtifactByID(System.BitConverter.ToInt32(data, 13)); shuttleID = System.BitConverter.ToInt32(data, 17); transmissionID = System.BitConverter.ToInt32(data, 21); planPos = new Vector2Int(data[25], data[26]); if (data[27] == 1) { data = new byte[8]; fs.Read(data, 0, 8); // #creating map marker GlobalMap gmap = GameMaster.realMaster.globalMap; mapMarker = new FlyingExpedition(this, System.BitConverter.ToSingle(data, 0), System.BitConverter.ToSingle(data, 4), stage == ExpeditionStage.WayOut ? gmap.cityPoint : destination, FLY_SPEED); gmap.AddPoint(mapMarker, true); // } missionCompleted = fs.ReadByte() == 1; return(this); }
private static void Main(string[] args) { if (!IsWindows()) { throw new Exception("Not running on a windows os"); } //Works for getting files from desktop var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (!dir.EndsWith(@"CharacterLibrary\Files")) { dir = GetPathToGlobalFiles(dir); } var xmlDocPath = dir + @"\config.xml"; using (var writer = new StreamWriter("asdf.txt")) { writer.WriteLine(xmlDocPath); } var mapPath = dir + @"\map.png"; var appPath = dir + @"\ImageDisplayApp.exe"; IBattleManager battleManager = new BattleManager(); IReader reader = new XmlReader(battleManager); reader.ReadDocument(xmlDocPath); IPlayer player = SetupPlayer(reader.Width, reader.Height); IMap map = new GlobalMap(reader.Width, reader.Height, mapPath, appPath, reader.Tiles); var dungeons = GetDungeonTiles(map.GetMapGrid()); IVictoryCondition victoryCondition = new DungeonVictoryCondition(map, player, dungeons); map.GetTileByLocation(player.GetCurrentLocation()).Visited = true; IGameManager game = new GameManager(map, victoryCondition, player); game.Play(); }
void FixedUpdate() { int t = 5; if (GlobalMap.GetWinFlag() && delay / t < mapSize) { // Debug.Log (delay+" " + GroundMap.winCount); if (delay % t != 0) { //groundList [delay/t].transform.Translate (Vector3.up * Time.deltaTime * 100, Space.World); } else { groundList [delay / t].GetComponent <Renderer> ().material = material [3]; } delay++; } }
public bool onContinue() { int ddx, ddz, ans; if (continueCount > 0) { continueCount--; ui_gameSystem.ContinueTextUpdate(continueCount); } else { return(false); } rotation_count = 0; mapIndex = resurrectionIndex; GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz); ground [ground_index].Set(resurrectionPoint); ground [1 - ground_index].Set(resurrectionPoint); ground [1 - ground_index].Updata(dx, dz); GlobalMap.ChangeDxy(map [mapIndex + 1].dxDz, out ddx, out ddz); //transform.position.Set(ground [ground_index].x,0,ground [ground_index].z); transform.position = new Vector3(ground [ground_index].x, 0, ground [ground_index].z); //transform.rotation = Quaternion.AngleAxis((dx-dz)/5*90, new Vector3(0,1,0)); if (ddz != 0) { ans = (ddz) / 5 * 90 - 90; } else { ans = 0; } if (ddx != 0) { ans += (ddx) / 5 * 90; } transform.rotation = Quaternion.Euler(new Vector3(0, ans, 0)); Debug.Log("dx:" + ddx + " dz:" + ddz); //speed = spee_default; isalive = 1; nowScore = lastScore; speed = spee_default; return(true); }
/// =============================== public Expedition(PointOfInterest i_destination, Crew c, int i_shuttleID, QuantumTransmitter transmitter, float i_supplies, float i_crystals) { // СДЕЛАТЬ: проверка компонентов и вывод ошибок ID = nextID++; stage = ExpeditionStage.WayIn; destination = i_destination; destination.AssignExpedition(this); crew = c; c.SetCurrentExpedition(this); if (Hangar.OccupyShuttle(i_shuttleID)) { shuttleID = i_shuttleID; } else { AnnouncementCanvasController.MakeAnnouncement(Localization.GetExpeditionErrorText(ExpeditionComposingErrors.ShuttleUnavailable)); Dismiss(); } if (transmitter != null) { transmissionID = transmitter.StartTransmission(); hasConnection = true; } else { transmissionID = QuantumTransmitter.NO_TRANSMISSION_VALUE; hasConnection = false; } suppliesCount = (byte)i_supplies; crystalsCollected = (ushort)i_crystals; //#creating map marker GlobalMap gmap = GameMaster.realMaster.globalMap; mapMarker = new FlyingExpedition(this, gmap.cityPoint, destination, FLY_SPEED); gmap.AddPoint(mapMarker, true); // expeditionsList.Add(this); listChangesMarker++; }
void Update() { if (Input.GetKeyDown(KeyCode.Space) && GlobalMap.Map != null) { tile = GlobalMap.GetTile(SwitchIndice); if (tile != null) { tile.RefreshData(ReplaceData); tile.UpdateTile(); } Debug.Log("Tile type: " + tile.Data.type); } if (Input.GetKeyUp(KeyCode.Space) && GlobalMap.Map != null && tile != null) { tile.ResetTile(); tile = null; } }
public void EndMission() { switch (stage) { case ExpeditionStage.OnMission: stage = ExpeditionStage.WayOut; // #creating map marker GlobalMap gmap = GameMaster.realMaster.globalMap; mapMarker = new FlyingExpedition(this, destination, gmap.cityPoint, FLY_SPEED); gmap.AddPoint(mapMarker, true); // changesMarkerValue++; break; case ExpeditionStage.WayIn: mapMarker.ChangeDestination(GameMaster.realMaster.globalMap.cityPoint); changesMarkerValue++; break; } }
void CloneObject() { cloneObj = Instantiate(cloneGround[map[mapIndex].cubeType]) as GameObject; cloneObj.transform.position = new Vector3(now_x, now_y, now_z); //if (map [mapIndex].materialType != 0) { cloneObj.GetComponent <Renderer> ().material = material [map [mapIndex].materialType]; //} if (map [mapIndex].dxDz == 0) { cloneObj.transform.Rotate(new Vector3(0, 90, 0)); } else if (map [mapIndex].dxDz == 1) { cloneObj.transform.Rotate(new Vector3(0, 270, 0)); } else if (map [mapIndex].dxDz == 2) { cloneObj.transform.Rotate(new Vector3(0, 180, 0)); } else if (map [mapIndex].dxDz == 3) { cloneObj.transform.Rotate(new Vector3(0, 0, 0)); } groundQueue.Enqueue(cloneObj); groundList.Add(cloneObj); if (map[mapIndex].rewardType != 0) { cloneObj = Instantiate(cloneScore) as GameObject; cloneObj.transform.position = new Vector3(now_x + Random.value * 4 - 2, (float)(now_y + 2.5), now_z + Random.value * 4 - 2); scoreQueue.Enqueue(cloneObj); } GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz); if (mapIndex < mapSize) { mapIndex++; } now_x += dx; now_z += dz; }