/* * Creates a new list carpark of the defined size, it also moves the cars from the existing carpark to the new * carpark and removes the old carpark afterwards. The callback will only return true if operations are * successfully performed. */ public void CreateNewCarpark(int size, Action <bool> callback) { if (size > GetMaxListSize()) { Debug.Log($"Maximum carpark size is {Carpark.GetComponent<ListCarparkManager>().Carparks.Count}"); callback(false); } else { GameObject carpark = Instantiate(Carpark); IsoTransform isoTransform = carpark.GetComponent <IsoTransform>(); _shiftAmount = new Vector3(isoTransform.Size.x, 0, 0); if (_currentListCarpark != null) { isoTransform.Position = _currentListCarpark.GetComponent <IsoTransform>().Position + _shiftAmount; } ListCarparkManager newCarparkManager = carpark.GetComponent <ListCarparkManager>(); if (newCarparkManager.CreateCarpark(size, out List <IsoTransform> newCarpark)) { GridGraph.UpdateGraph(); StartCoroutine(CopyVehiclesToNewCarpark(newCarparkManager, newCarpark, callback)); } else { DestroyImmediate(carpark); } } }
public void placeObject(GameObject obj, int i, int j) { IsoTransform iso = obj.GetComponent <IsoTransform>(); iso.Position = new Vector3(i + 1 + iso.Position.x, iso.Position.y, j + 1 + iso.Position.z); obj.transform.SetParent(this.transform); }
public GameObject cut() { GameObject newTronc = GameObject.Instantiate(souche); SoucheDefaut t = newTronc.AddComponent <SoucheDefaut>(); newTronc.AddComponent <AssignedCase>().set(GetComponent <AssignedCase>().get()); IsoTransform iso1 = GetComponent <IsoTransform>(); IsoTransform iso2 = newTronc.GetComponent <IsoTransform>(); iso2.Position = new Vector3(iso1.Position.x, iso2.Position.y, iso1.Position.z); float scale = 0.4f + 0.6f * Mathf.Min(1.0f, age2 / growingTime); float h = isDead ? sDeadHumidite : sHumidite; float l = isDead ? sDeadLuminosite : sLuminosite; float f = isDead ? sDeadFertilite : sFertilite; t.setProperties(age, scale, dead, baseUprootCost, h, l, f); if (inc != null) { GameObject.Destroy(inc); } Main.get().money += getCutPrice(); newTronc.name = "Souche de " + name; return(newTronc); }
// Use this for initialization void Start() { lastUpdate = Main.time(); inc = null; IsoTransform iso = GetComponent <IsoTransform>(); finalY = iso.Position.y; finalSize = new Vector3(iso.Size.x, iso.Size.y, iso.Size.z); finalScale = transform.localScale; // Randomizing the final size of the tree float adultSize = 0.7f + 0.3f * Main.random(); finalY *= adultSize; finalSize *= adultSize; finalScale *= adultSize; transform.localScale = new Vector3(); // Changing alpha Color c = GetComponent <SpriteRenderer>().color; c.a = 0.7f; GetComponent <SpriteRenderer>().color = c; }
// Update is called once per frame void Update() { float t = Main.time(); float scale; if (!isDead) { float dt = t - lastUpdate; age += dt; age2 += dt * (0.5f + 0.5f * GetComponent <AssignedCase>().get().getFertilite()); scale = 0.3f + 0.7f * Mathf.Min(1.0f, age2 / growingTime); if (inc == null && scale >= 0.6) { inc = Main.addIncome(income, period); } } else { scale = 0.3f + 0.7f * Mathf.Min(1.0f, age2 / growingTime); } lastUpdate = t; transform.localScale = scale * finalScale; IsoTransform iso = GetComponent <IsoTransform>(); iso.Size = scale * finalSize; iso.Position = new Vector3(iso.Position.x, scale * finalY, iso.Position.z); }
public bool SpawnIndividualTile(float xPosition, float zPosition) { Vector3 newPosition = new Vector3(xPosition, characterPosition.y, zPosition); bool obstacleInTheWay = false; foreach (GameObject obstacle in GameObject.FindGameObjectsWithTag("Obstacle")) { Debug.Log("Found obstacle."); Debug.Log("Obstacle Position: " + ((IsoTransform)obstacle.GetComponent(typeof(IsoTransform))).Position); Debug.Log("New Position: " + newPosition); if (((IsoTransform)obstacle.GetComponent(typeof(IsoTransform))).Position == newPosition) { obstacleInTheWay = true; } } if (!obstacleInTheWay) { GameObject obj = (GameObject)GameObject.Instantiate( Resources.Load("g3544"), new Vector3(0, 0, 0), Quaternion.identity); obj.AddComponent <BoxCollider>(); IsoTransform newIsoTransform = obj.GetComponent(typeof(IsoTransform)) as IsoTransform; newIsoTransform.Position = newPosition; movementTiles.Add(obj); } else { Debug.Log("Hit an obstacle!"); } return(obstacleInTheWay); }
public void SetFieldParty(int id) { hero_prefab = (IsoTransform)Resources.Load("Prefabs/Unit/Monster", typeof(IsoTransform)); var copy = Instantiate(hero_prefab); copy.GetComponent <PartyControl>().hero_party = GetParty(id); copy.Position = new Vector3(12.0f, 0.6f, 12.0f); copy.GetComponent <PartyControl>().DebugLogPartyInfo(); }
void Awake() { _isoTransform = this.GetOrAddComponent <IsoTransform>(); xOffsets.Add(1); xOffsets.Add(-1); zOffsets.Add(1); zOffsets.Add(-1); characterPosition = _isoTransform.Position; }
// Use this for initialization public virtual void Start() { var player = GameObject.Find("Player"); _playerPos = player.GetComponent <IsoTransform>(); _npcPos = GetComponent <IsoTransform>(); _canvas = GameObject.Find("DialogCanvas").GetComponent <DialogCanvasManager>(); _playerSprite = player.GetComponent <SaveSprite>().Sprite; }
void OnCollisionStay(Collision collisionInfo) { var isoCollision = new IsoCollision(collisionInfo); if (isoCollision.gameObject != null) { IsoTransform.SendMessage("OnIsoCollisionStay", isoCollision, SendMessageOptions.DontRequireReceiver); } }
public IsoRaycastHit(IsoCollider collider, float distance, Vector3 normal, Vector3 point, IsoRigidbody isoRigidbody, IsoTransform isoTransform) { Collider = collider; Distance = distance; Normal = normal; Point = point; IsoRigidbody = isoRigidbody; IsoTransform = isoTransform; }
private void Start() { if (Watch == null) { Watch = GameObject.Find("Player").GetComponent <IsoTransform>(); } Transform = GetComponent <IsoTransform>(); }
public void Setup(IsoTransform isoTransform) { if (isoTransform) { IsoTransform = isoTransform; _lastPos = isoTransform.Position; transform.position = IsoTransform.Position; UpdateLayer(); } }
//forwards Triggers and Collision to the IsoCollider void OnTriggerEnter(Collider other) { var otherghost = other.GetComponent <Ghost>(); if (otherghost != null) { var isoCollider = otherghost.IsoTransform.GetComponent <IsoCollider>(); IsoTransform.SendMessage("OnIsoTriggerEnter", isoCollider, SendMessageOptions.DontRequireReceiver); } }
public Gap(float minY, float maxY, Vector2 gridPos, IsoTransform isotransform, bool _isquestion = false) { MinY = minY; MaxY = maxY; _gridPos = gridPos; IsQuestion = _isquestion; NextNodes = new HashSet <INode>(); Passable = false; Visited = false; }
// Initialization void Start() { isoTransform = this.GetOrAddComponent <IsoTransform>(); generator = gameObject.GetComponentInParent(typeof(SoftwareLevelGenerator)) as SoftwareLevelGenerator; startPos = isoTransform.Position; // Initialise offset coordinates X = (int)(isoTransform.Position.x + 1); Y = 1; Z = (int)(isoTransform.Position.z + 1); }
private void Start() { IsoTransform = GetComponent <IsoTransform>(); Animator = GetComponent <Animator>(); GhostReference = GetComponent <GhostReference>(); // Disable auto updating position - fixes movement due to weird as code in this library GhostReference.GhostObject.GetComponent <Ghost>().AutoUpdatePosition = false; }
public void SetFieldParty(int id) { //enemy_prefab = (IsoTransform)Resources.Load("Prefabs/Building/" + build_data.prefab_path, typeof(IsoTransform)); enemy_prefab = (IsoTransform)Resources.Load("Prefabs/Unit/Monster", typeof(IsoTransform)); var copy = Instantiate(enemy_prefab); copy.GetComponent <PartyControl>().enemy_party = GetParty(id); copy.Position = new Vector3(10.0f, 0.6f, 10.0f); copy.GetComponent <PartyControl>().DebugLogPartyInfo(); //copy.name = build_data.name; }
private void OnEnable() { UpdateHandlePos(); _instance = target as IsoTransform; _instance.Position = _instance.Position; _instanceFields = ExposeProperties.GetProperties(_instance); if (_instance == null) { return; } _instance.GetComponent <Transform>().hideFlags = HideFlags.HideInInspector; //hides Transform component UnityEditorInternal.ComponentUtility.MoveComponentUp(_instance); }
public IsoCollision(Collision collisionInfo) { var ghost = collisionInfo.collider.GetComponent <Ghost>(); if (ghost != null) { isoCollider = ghost.IsoTransform.GetComponent <IsoCollider>(); contacts = collisionInfo.contacts; gameObject = ghost.IsoTransform.gameObject; impulse = collisionInfo.impulse; relativeVelocity = collisionInfo.relativeVelocity; isoRigidbody = gameObject.GetComponent <IsoRigidbody>(); isoTransform = ghost.IsoTransform; } }
/* * Copy the car at the temp carpark to the specified index. The car originally occupying the specified index * will be destroyed if operation is successful. * * If the car is unable to move to destination or there are no car occupying the specified index, the * callback with return false. */ public void CopyFromTempVarToIndex(int index, Action <bool> callback) { IsoTransform isoTransform = ActiveCarpark[index]; if (GetVehicleAtPosition(ConvertTileToPosition(TempVarTile), out GameObject vehicle)) { GameObject clone = Instantiate(vehicle); if (AddVehicle(clone, GetVehicleType(vehicle))) { StartCoroutine(WriteToIndex(clone, ConvertTileToPosition(isoTransform), callback)); } } else { callback?.Invoke(false); } }
public void setProperties(float age, float scale, bool dead, float cost, float humidite, float luminosite, float fertilite) { IsoTransform iso = GetComponent <IsoTransform>(); iso.Size *= scale; iso.Position = new Vector3(iso.Position.x, scale * iso.Position.y, iso.Position.z); transform.localScale *= scale; size = scale; this.age = age; this.isDead = dead; this.uprootCost = (int)(size * cost); h = humidite; l = luminosite; f = fertilite; }
private void InitializeGrid() { GameObject[] characterObjects = GameObject.FindGameObjectsWithTag("Character"); int minCol = int.MaxValue; int minRow = int.MaxValue; int maxRow = int.MinValue; int maxCol = int.MinValue; float tileSize = 2.25f; foreach (GameObject characterObject in characterObjects) { IsoTransform isoTransform = characterObject.GetComponent <IsoTransform>(); Vector2Int gridPosition = new Vector2Int( Mathf.FloorToInt(isoTransform.Position.x / tileSize), Mathf.FloorToInt(isoTransform.Position.z / tileSize)); minCol = Mathf.Min(minCol, gridPosition.x); maxCol = Mathf.Max(maxCol, gridPosition.x); minRow = Mathf.Min(minRow, gridPosition.y); maxRow = Mathf.Max(maxRow, gridPosition.y); } int stageRows = maxRow - minRow + 1; int stageCols = maxCol - minCol + 1; characters = new Character[stageRows, stageCols]; Vector2Int gridOffset = new Vector2Int(-minCol, -minRow); foreach (GameObject characterObject in characterObjects) { Character character = characterObject.GetComponent <Character>(); IsoTransform isoTransform = characterObject.GetComponent <IsoTransform>(); Vector2Int gridPosition = new Vector2Int( Mathf.FloorToInt(isoTransform.Position.x / tileSize), Mathf.FloorToInt(isoTransform.Position.z / tileSize) ); gridPosition += gridOffset; characters[stageRows - gridPosition.y - 1, gridPosition.x] = character; } }
public override void Start() { base.Start(); NpcTransform = gameObject.GetComponent <IsoTransform>(); MovementAnimator = gameObject.GetComponent <Animator>(); ProximityToggle = GetComponent <ProximityToggle>(); PlayerTransform = GameObject.Find("Player").GetComponent <IsoTransform>(); StartCoroutine(SetDirection()); if (!Toolbox.Instance.GameManager.Settings.HasBeenGreeted) { IsGreeting = true; IntroduceStudentServices = true; StartCoroutine(Greet()); } }
private void Awake() { if (Follow == null) { var parent = transform.parent; Follow = parent == null ? null : parent.GetComponent <IsoTransform>(); } ThisTransform = GetComponent <IsoTransform>(); CanvasRectTransform = GetComponent <RectTransform>(); ImageRectTransform = transform.Find("Image").GetComponent <RectTransform>(); Text = transform.Find("Text").GetComponent <Text>(); CanvasRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, MaxHeight); CanvasRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, MaxWidth); FollowTarget(); }
private void SetBuildingObject(Vector2 vector2, string TechnicalName) { GDEBuildingData build_data = BuildingMasterData.instance.GetData(TechnicalName); if (!CheckResourceBuilding(TechnicalName)) { return; } UseResourceBuilding(TechnicalName); building_prefab = (IsoTransform)Resources.Load("Prefabs/Building/" + build_data.prefab_path, typeof(IsoTransform)); Debug.Log(build_data.prefab_path); var copy = Instantiate(building_prefab); copy.Position = new Vector3(vector2.x, 0.6f, vector2.y); copy.name = build_data.name; Debug.Log("Building"); _building_id = ""; }
private Dictionary <Vector3, Node> UpdateGraphInternal(IEnumerable <TileRules> allTiles) { var grid = new Dictionary <Vector3, Node>(); foreach (var tile in allTiles) { IsoTransform isoTransform = tile.GetComponent <IsoTransform>(); if (!grid.ContainsKey(isoTransform.Position)) { var adjacentCells = AdjacentPositions .Select(adjacentPosition => adjacentPosition + isoTransform.Position) .ToArray(); HashSet <INode> neighbours = new HashSet <INode>(); foreach (var adjacentCell in adjacentCells) { if (grid.TryGetValue(adjacentCell, out Node neighbour)) { if (Traversable(isoTransform.Position, neighbour.Position, tile)) { neighbours.Add(neighbour); } } } Node node = new Node(isoTransform.Position, tile, isoTransform.Size.y, neighbours); foreach (var potentialNeighbour in grid.Values) { if (Traversable(potentialNeighbour.Position, node.Position, potentialNeighbour.TileRules)) { potentialNeighbour.NextNodes.Add(node); } } grid.Add(isoTransform.Position, node); } } return(grid); }
/* * Due to complexity of the sorting logic, we need to hide the car entering the carpark if the building is * enabled so that it appears as if the car is entering the carpark rather than going over or under the * entrance/exit tiles * * HideCarTiles is a collection of gameObjects defined in the manager of the respective level. */ private void CheckIfCarIsEnteringOrExitingCarpark() { if (Building.activeSelf) { foreach (CustomAStarAgent vehicle in FindObjectsOfType <CustomAStarAgent>()) { IsoTransform isoTransform = vehicle.GetComponent <IsoTransform>(); foreach (IsoTransform tile in HideCarTiles) { // Check if is intersecting the entrance/exit tiles (or any tiles added to HideCarTiles if (Vector3Collider.Intersect(isoTransform.Position, ConvertTileToPosition(tile), tile.Size)) { vehicle.GetComponent <Renderer>().enabled = false; vehicle.GetComponent <CustomVehicleAnimator>().PointOfInterestIndicator.GetComponent <Renderer>().enabled = false; return; } } vehicle.GetComponent <Renderer>().enabled = true; vehicle.GetComponent <CustomVehicleAnimator>().PointOfInterestIndicator.GetComponent <Renderer>().enabled = true; } } }
public void Update() { // Handle mouse movement if (Input.GetMouseButtonDown(0) && !mouseDebounce && trackMouse) { trackMouse = false; var isoRay = Isometric.MouseToIsoRay(); //do an isometric raycast on left mouse click if (Input.GetMouseButtonDown(0)) { IsoRaycastHit isoRaycastHit; if (IsoPhysics.Raycast(isoRay, out isoRaycastHit)) { selectedObj = isoRaycastHit.IsoTransform; // Update instruction text component2 = new InstructionComponent("X: " + selectedObj.Position.x + " Z: " + selectedObj.Position.z) { OnComponentClicked = onClicked }; targetPos = new Vector3(selectedObj.Position.x, 1, selectedObj.Position.z); instructionRenderer.Render(); } } if (instructionRenderer != null) { instructionRenderer.BackgroundColor = instructionRenderer.DefaultBackgroundColor; } } mouseDebounce = false; }
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000.0f)) { if (hit.transform.name == "Main_Character") { Debug.Log("Clicked on player"); if (movementTiles.Count == 0) { SpawnMovementTiles(); } else { DestroyMovementTiles(); } } if (movementTiles.Contains(hit.transform.gameObject)) { Debug.Log("Clicked a coin!"); IsoTransform coinLocation = hit.transform.gameObject.GetComponent(typeof(IsoTransform)) as IsoTransform; _isoTransform.Position = coinLocation.Position; DestroyMovementTiles(); } } else { Debug.Log("Not Raycast!"); } } characterPosition = _isoTransform.Position; }