/// <summary> /// Sells the placeable and returns some gold to the player. /// </summary> public void SellPlaceable(Placeable placeableToSell) { placeableToSell.Sell(); Player.Instance.Gold += GetSellPrice(placeableToSell); // Return to the pool PlaceablePool.Instance.ReclaimObject(placeableToSell); }
internal void AddMovingObject(Placeable p) { movingObjects[p] = movingObjectInsterPtr++; if (movingObjectInsterPtr >= movingObjectMaxPtr) { movingObjectInsterPtr = 0; } }
private void Start() { placeable = new Placeable("demo"); placeable.AddTag(PlaceableTag.tagBlueSkillToken); //placeable.AddTag(PlaceableTag.tagGreenSkillToken); //Debug.Log("done"); }
private void attemptConnection(int ourPointIndex, Placeable otherPlaceable, int theirPointIndex) { Debug.Log("Attempting connection"); if (canConnectAtPoint(ourPointIndex) && otherPlaceable.canConnectAtPoint(theirPointIndex)) { makeConnection(ourPointIndex, otherPlaceable, theirPointIndex); } }
private void RemoveElement() { if (placeable != null) { manager.ReturnPlaceable(placeable); Destroy(placeable.gameObject); } placeable = null; }
private void Update() { var cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (placeableInstance != null) { if (Input.GetKeyDown(KeyCode.R)) { placeableInstance.transform.Rotate(new Vector3(0, 90, 0), Space.World); } if (Input.GetKeyDown(KeyCode.Escape)) { ClearPlaceable(); return; } if (CanPlace()) { placeableInstance.GetComponent <Selectable>().ChangeColor(Color.green); } else { placeableInstance.GetComponent <Selectable>().ChangeColor(Color.red); } var selectionManager = SelectionManager.GetInstance(); if (Physics.Raycast(cameraRay, out hitInfo, float.MaxValue, LayerMask.GetMask("Ground"))) { placeableInstance.transform.position = hitInfo.point; if (CanPlace() && Input.GetMouseButtonUp(0) && !EventSystem.current.IsPointerOverGameObject()) { if (ResourceManager.GetInstance().OffsetAll(-placeableInstance.GetWoodCost(), -placeableInstance.GetStoneCost(), -placeableInstance.GetMetalCost(), 0)) { var buildSite = BuildSite.Instantiate(placeableInstance).GetComponent <Assignable>(); foreach (var worker in selectionManager.GetSelected().Where(s => s.GetComponent <Worker>() != null).Select(s => s.GetComponent <Worker>()).OrderBy(s => s.IsAssigned())) { if (!buildSite.AddWorker(worker)) { break; } } placeableInstance.GetComponent <Selectable>().ChangeColor(Color.clear); placeableInstance = null; selectionManager.DeselectAll(); selectionManager.Enable(); } } else if (Input.GetMouseButtonUp(1)) { ClearPlaceable(); return; } } } }
public void ClearPlaceable() { if (placeableInstance != null) { placeableInstance.Remove(); placeableInstance = null; SelectionManager.GetInstance().Enable(); } }
private void DuplicatePlaceable_Click(object sender, RoutedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; Placeable duplicate = vm.SelectedPlaceable.Duplicate(true); duplicate.Name += string.Format(" ({0})", vm.SelectedCollection.PlaceableFile.Data.Count(x => x.Name == duplicate.Name)); vm.SelectedCollection.PlaceableFile.Data.Add(duplicate); vm.SelectedPlaceableIndex = vm.SelectedCollection.PlaceableFile.Data.Count - 1; }
private void makeConnection(int ourPointIndex, Placeable otherPlaceable, int theirPointIndex) { var connectionSuccess = otherPlaceable.receiveConnection(theirPointIndex, this, ourPointIndex); if (connectionSuccess) { receiveConnection(ourPointIndex, otherPlaceable, theirPointIndex); } }
private void MarkByCP(Placeable p, int zShift, Content content) { Mark2x2(p, zShift, content, new Vector2Int(1, 1)); Mark2x2(p, zShift, content, new Vector2Int(3, 1)); Mark2x2(p, zShift, content, new Vector2Int(5, 1)); Mark2x2(p, zShift, content, new Vector2Int(1, 3)); Mark2x2(p, zShift, content, new Vector2Int(3, 3)); Mark2x2(p, zShift, content, new Vector2Int(5, 3)); }
public void CmdInputShot(GameObject shotPlaceable) { this.shotPlaceable = shotPlaceable.GetComponent <Placeable>(); if (isServer) { Debug.Log("Coucou shot commanded"); Debug.Log(shotPlaceable); } }
/// <summary> /// Spawn the object and parse and apply any additional parameters /// </summary> /// <param name="obj">The object string along with parameters</param> private void PlaceObject(string obj, Vector3 position, Transform parent) { string[] obj_id = obj.Split(ID_SEPERATOR); string[] color = obj_id[0].Split(COL_SEPERATOR); string[] orientation = color[0].Split(ROT_SEPERATOR); string tile = orientation[0]; if (!placeablesMap.ContainsKey(tile)) { UserErrorInfo.ErrorWriter.AddMessage($"Invalid symbol '{tile}' at position '{position}'"); return; } Placeable p = placeablesMap[tile]; if (p.prefabs.Length == 0) { UserErrorInfo.ErrorWriter.AddMessage($"No prefabs assigned for object '{tile}'"); return; } GameObject prefab = p.prefabs[Random.Range(0, p.prefabs.Length)]; GameObject instance = Instantiate(prefab, position, Quaternion.identity, parent); if (tile == "cb") { if (color.Length < 2) { UserErrorInfo.ErrorWriter.AddMessage($"The ColorButton '{obj_id}' requires a color parameter"); } instance.GetComponent <ColorButton>().SetColor(Utils.colorFromHexString(color[1])); } if (orientation.Length > 1) { RotateObject(instance, orientation[1]); } if (obj_id.Length > 1) { string id = obj_id[1]; if (p.group == EntityGroup.Agents) { AssignAgentID(instance, id, obj, position); } else { instance.name = id; } } else if (ObjectIDRequired(p.group)) { UserErrorInfo.ErrorWriter.AddWorldMessage($"No ID specified for '{tile}', required for {p.group}.", obj, position); return; } }
private void CreateTerrain() { DataEntity terrain = new DataEntity(); _entities.Add(terrain); Placeable placeable = new Placeable(terrain); Tilemap2D terrainViewable = new Tilemap2D(terrain); _viewManager.AddViewable(terrainViewable); }
public void CmdMoveTo(NetworkInstanceId toGo) { Placeable potential = NetworkServer.FindLocalObject(toGo).GetComponent <Placeable>(); if (gameManager.PlayingPlaceable.joueur == this)//on update que si c'est à son tour de jouer, on fait les autres vérifs dans la Gamemanager { placeToGo = potential.position; Debug.Log(placeToGo); } }
protected virtual void OnPlaceablePainted(Placeable placeable) { if (PlaceablePainted != null) { PlaceablePainted(this, new PlaceablePaintedEventArgs() { NewPlaceable = placeable }); } }
private void setTextBasedOnValue(Placeable building, ResourceType type, bool produce = true) { float?value = produce? getProduceValue(building.gameObject, type) : getConsumeValue(building.gameObject, type); var text = produce ? produceDictionary[type] : consumeDictionary[type]; Debug.Log(text.gameObject.name); Debug.Log(value); setOrHideText(text, value, type); }
/// <summary> /// Performs initialization related to the placing component. /// </summary> private void InitPlaceableComponent() { placeableComponent = gameObject.GetComponentInChildren <Placeable>(true); if (placeableComponent != null) { placeableComponent.StartedPlacing += OnStartedPlacingMagnet; placeableComponent.StoppedPlacing += OnStoppedPlacingMagnet; placeableComponent.StartPlacing(false); } }
private void CheckValidPlaceable(string input, string rest = "") { var cs = NCS(input); L20n.FTL.AST.INode result; Assert.IsTrue(Placeable.PeekAndParse(cs, out result)); Assert.IsNotNull(result); Assert.AreEqual(rest, cs.ReadUntilEnd()); Assert.AreEqual(typeof(L20n.FTL.AST.Placeable), result.GetType()); }
public override GameObject cloneObj(GameObject model, Placeable data, RaycastHit hit) { GameObject newFlower = GameObject.Instantiate(model, posClamp(hit), Quaternion.identity, hit.transform);//make a copy //newFlower.name = x + " " + y;//placement stuff newFlower.transform.LookAt(transform.position); int yRot = (int)((mainCamera.transform.parent.eulerAngles.y + 225) / 90); newFlower.transform.eulerAngles = new Vector3(0, yRot * 90, 0); // newFlower.transform.Rotate(new Vector3(0, 90, 0)); newFlower.SetActive(true); newFlower.transform.localScale = Vector3.one; benchController currentFlowerObj = newFlower.GetComponent <benchController>(); int[] flowerGridLoc = WorldManager.instance.worldPointToFlowerGrid(hit.point);//find what grid the point is in float chunkOverFlower = (float)WorldManager.instance.chunkWidth / WorldManager.instance.FlowerWidthPerChunk; Vector3 flowerCellCenterPosition = VectorUtilities.VectorAdd((VectorUtilities.VectorFloor(hit.point * chunkOverFlower) / chunkOverFlower), (chunkOverFlower * .5f)); int x2 = flowerGridLoc[0]; int y2 = flowerGridLoc[1]; WorldManager.instance.placableGrid[x2, y2] = currentFlowerObj;//move the flower data over Vector3 distanceFromCenter = hit.point - flowerCellCenterPosition; if (yRot % 2 == 0) { if (distanceFromCenter.x > 0) { x2++; } else { x2--; } } else { if (distanceFromCenter.z > 0) { y2++; } else { y2--; } } x2 = WorldManager.instance.trueX(x2); y2 = WorldManager.instance.trueX(y2); WorldManager.instance.removeFromFlowerList(x2, y2); WorldManager.instance.placableGrid[x2, y2] = currentFlowerObj;//move the flower data over currentFlowerObj.flowerGridPos2 = new int[] { x2, y2 }; currentFlowerObj.flowerGridPos = flowerGridLoc; return(newFlower); }
private void NewPlaceableClick(Placeable placeable) { Placeable newPlaceable = Instantiate(placeable); newPlaceable.name = placeable.name; currentPlaceables.Add(newPlaceable); newPlaceable.transform.position = placeable.GetDefaultPosition(); selectedPlaceable = newPlaceable; SelectedPlaceableChanged?.Invoke(selectedPlaceable); }
public void Select(Placeable block) { DeSelectCurrent(); selected = block; if (selected.name == "Golden") { selected.gameObject.AddComponent <GoldBlock>(); } block.activateDragMode(); }
public bool Evaluate(Placeable placeable) { foreach (ITagCondition condition in children) { if (condition.Evaluate(placeable)) { return(true); } } return(false); }
private void PreviousPlaceable() { CurrentPlaceableIndex = Modp(CurrentPlaceableIndex - 1, GameManager.Instance.Placeables.Length); if (CurrentPlaceable) { Destroy(CurrentPlaceable.gameObject); } CurrentPlaceable = CreateGhostPlaceable(GameManager.Instance.Placeables[CurrentPlaceableIndex]); }
private void NextPlaceable() { CurrentPlaceableIndex = (CurrentPlaceableIndex + 1) % GameManager.Instance.Placeables.Length; if (CurrentPlaceable) { Destroy(CurrentPlaceable.gameObject); } CurrentPlaceable = CreateGhostPlaceable(GameManager.Instance.Placeables[CurrentPlaceableIndex]); }
/// <summary> /// Places the placeable at the <see cref="placementPosition"/>, updates player's current gold and also the <see cref="lastPlacedPosition"/>. /// </summary> private void PlacePlaceable() { Player.Instance.Gold -= activePlaceable.GoldCost; activePlaceable.IsPlaced = true; activePlaceable.transform.position = placementPosition; activePlaceable = null; lastPlacedPosition = placementPosition; //currentRotationDegrees = 0; }
public void SetObjectToPlace(Placeable obj) { if (m_objectToPlace) { m_objectToPlace.CancelPlacement(); } m_objectToPlace = null; m_preview = null; m_objectToPlace = obj; }
// Use this for initialization void Start() { gameStore = FindObjectOfType <Store>(); outline = GetComponent <OutlineComponent>(); outline.Enable(); outline.setParticles(false); dragging = true; pointer = GetComponentInChildren <ArrowPointer>(); placement = GetComponent <Placeable>(); selectable = GetComponent <Selectable>(); }
private void TriggerRemoveTest(Placeable p1, Placeable p2, Ksids ksids) { if (p2.IsTrigger && ksids.IsParentOrEqual(p1.Ksid, p2.TriggerTargets)) { p2.RemoveTarget(p1); } if (p1.IsTrigger && ksids.IsParentOrEqual(p2.Ksid, p1.TriggerTargets)) { p1.RemoveTarget(p2); } }
private void PlaceElement(Placeable placeablePrefab) { if (placeablePrefab == null) { // TODO: Indicate there was no element to place return; } placeable = Instantiate(placeablePrefab, transform); available = false; overlayUI.SetActive(false); }
public void ToggleTooltip(Placeable placeab = null) { if (placeab != null) { tooltip.gameObject.SetActive(true); tooltip.SetTooltip(placeab); } else { tooltip.gameObject.SetActive(false); } }
public GameObjectSaveEventArgs(Placeable placeable) { this.ActivePlaceable = placeable; }