public void Clicked() { Placer.EnablePlacing(buildObj, this); placeBtn.SetActive(false); uiToHide.SetActive(false); closeBtn.SetActive(true); }
public (int x, int y) GetCoords(Placer tileBeforeOffset, int offsetIndex) { (int x, int y) = tileBeforeOffset.GetCoords(); Offset offset = TileObject.Config.Offsets[offsetIndex]; return(x + offset.X, y - offset.Y); }
public void OnFieldMouseEnter(object sender, MouseEventArgs mouseEventArgs) { Button button = sender as Button; Tile tile = Placer.GetPlacerFromButton(_tileGrid, button) as Tile; _selection.UpdateChangedPlacerList(tile, _tileGrid); }
public virtual void ConfigurePlacesRepeat() { // TODO: randomize choice // Placer = new Placer(new Positions.Rand((float) (2*ZChunk.size)), Positions.Rand.NoCenter(1f)); Options.Repeaters(this); Positions.Rand directions = Positions.Rand.NoCenter(1f); Positions pos; // pos = new Positions.LineAround(4f); if (true) { float u = Hashes.Rand(seed, "positionType"); if (u < 0.4) { pos = new Positions.AtZChunk(); } else if (u < 0.8) { pos = new Positions.Rand((float)(2 * ZChunk.size)); } else { pos = new Positions.LineAround(4f); } } Placer = new Placer(new Positions.Rand((float)(2 * ZChunk.size)), Positions.Rand.NoCenter(1f)); Printer.Log(40, "ZBEffect ConfigurePlacesRepeat: Repeater, Positions, Directions"); }
private void Awake() { UITableFiller.FillTable(_panel, _resolveResults, _variableCount.value, _expectedResults.valueArray, 2); UITableFiller.FillTable(_expectedPanel, _expectedResults.valueArray, _variableCount.value, _expectedResults.valueArray, 2); inventory = new Grid(1, 1, 20, new Vector3(-30, 0, 0)); grid = new Grid(_width, _height, _cellSize, _offset); _mainGrid.grid = grid; _auxGrid.grid = inventory; GameObject ground = Resources.Load <GameObject>("Prefabs/ground"); for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { Placer.PlaceObject(grid, ground, i, j); } } InputHandler.instance.ChangeGIT(GameInputType.GateBuilder); Placer.PlaceObject(inventory, ground, 0, 0); GameObject start = Resources.Load <GameObject>("Prefabs/start"); GameObject end = Resources.Load <GameObject>("Prefabs/end"); foreach (StartingPointData startingpoint in _startingpoints) { GameObject temp = Placer.PlaceObject(grid, start, startingpoint.position.x, startingpoint.position.y); temp.GetComponent <StartingPoint>().SetCharge(startingpoint.charge); } Placer.PlaceObject(grid, end, _endpoint.x, _endpoint.y); }
public void Clicked() { toShow.SetActive(true); gameObject.SetActive(false); Placer.PlaceCurrent(); PopupWindow.HidePopup(); }
public override void ConfigurePlacesRepeat() { Positions line = new Positions.LineAround(2f); Placer = new Placer(line, Positions.Rand.NoCenter(1f)); Options.Repeaters(this); }
/* * If the player releases the right mouse button, the last grid-element is being removed and the input-behaviour is reset. * @param context The information provided with the triggering event. In this case the release of the right-mouse-button. */ public void StopRemoving(InputAction.CallbackContext context) { // Before resetting the input-bevaviour to not remove any object, after the mouse moved, remove the last element which was hit. // Placing and removing objects is only allowed, when the selection is not blocked. // This indicates that there is no socket left to place for a logic-element. if (!_selectionBlocked) { // Cast a ray from the camera through the cursor and identify the hit object. Ray ray = _camera.go.GetComponent <Camera>().ScreenPointToRay(Mouse.current.position.ReadValue()); RaycastHit hit; // If any object has been hit, remove it from the grid and play a feedback sound. if (Physics.Raycast(ray, out hit)) { // Play a sound through to indicate a successfull removal. AudioManager.instance.PlaySound(clips[0]); // Identify the hit by it's coordinates in the grid. Vector2Int temp = _mainGrid.grid.GetCoordinate(hit.point); // Place a filler-element on the identified coordinates, thusly "removing" the element. Placer.PlaceObject(_mainGrid.grid, _filler.go, temp.x, temp.y, _filler.go); } } // After the last element has been removed, reset to normal input-bevahiour _inputs.Schaltnetz.PreviewBuilding.performed -= RemoveMore; }
public void Placed(GameObject placedGo) { Placer.DisablePlacing(); placeBtn.SetActive(false); uiToHide.SetActive(true); closeBtn.SetActive(false); NavMeshController.Bake(); }
public void Clicked() { toShow.SetActive(true); gameObject.SetActive(false); PopupWindow.HidePopup(); //disable all actions Placer.DisablePlacing(); }
private void OnClick() { Placer.GetInstance().SetPlaceable(buildingPrefab); buildDrawer.SetActive(false); if (overlay != null) { Destroy(overlay.gameObject); } }
private void OnEnable() { placer = target as Placer; pathCreator = serializedObject.FindProperty(nameof(pathCreator)); placeByClosestPoint = serializedObject.FindProperty(nameof(placeByClosestPoint)); time = serializedObject.FindProperty(nameof(time)); ignoredAxis = serializedObject.FindProperty(nameof(ignoredAxis)); rotateTowards = serializedObject.FindProperty(nameof(rotateTowards)); lookAt = serializedObject.FindProperty(nameof(lookAt)); lookAtAxis = serializedObject.FindProperty(nameof(lookAtAxis)); }
private void Awake() { _selectionPanel.go = _selectionPanelGO; _results = new int[(int)Mathf.Pow(2, _variableCount.value)]; _outputs = new MultiCellElement[_outputCount.value]; _mainCamera.go = this.gameObject; _grid = new Grid(100, 100, 5, Vector3.zero); InputHandler.instance.ChangeGIT(GameInputType.Plotter); InputHandler.instance.floatingText = _floatingText; _mainGrid.grid = _grid; GameObject empty = Resources.Load <GameObject>("Prefabs/emptyCube"); _filler.go = empty; for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { GameObject tempObj = Placer.PlaceObject(_grid, empty, i, j); } } int offSetX = _startingPointGo.GetComponent <GridElement>().size.x; int offSetY = _startingPointGo.GetComponent <GridElement>().size.y; for (int i = 0; i < _variableCount.value; i++) { GameObject tempMCE = Placer.PlaceMultiCellObject(_grid, _startingPointGo, _startingpoints[i].x, _startingpoints[i].y, _filler.go); if (tempMCE.GetComponentInChildren <TMP_Text>()) { tempMCE.GetComponentInChildren <TMP_Text>().text = ((Charge)i + 1).ToString(); } Vector2Int tempVecOutgoingSocket = new Vector2Int(_startingpoints[i].x + offSetX, _startingpoints[i].y); GameObject tempObj = Placer.PlaceObject(_grid, _outGoingSocket, _startingpoints[i].x + offSetX, _startingpoints[i].y); tempMCE.GetComponent <MultiCellElement>().AddToList(tempMCE.GetComponent <MultiCellElement>().outgoingSockets, tempVecOutgoingSocket); tempMCE.GetComponent <MultiCellElement>().outgoingSocketObjects.Add(tempObj.GetComponent <OutGoingSocket>()); } for (int j = 0; j < _outputCount.value; j++) { GameObject tempMCE = Placer.PlaceMultiCellObject(_grid, _endPointGo, _endPoints[j].x, _endPoints[j].y, _filler.go); if (tempMCE.GetComponentInChildren <TMP_Text>()) { tempMCE.GetComponentInChildren <TMP_Text>().text = j.ToString(); } Vector2Int tempVecIncomingSocket = new Vector2Int(_endPoints[j].x - 1, _endPoints[j].y); GameObject tempObj = Placer.PlaceObject(_grid, _incomingSocket, tempVecIncomingSocket.x, tempVecIncomingSocket.y); tempObj.GetComponent <SocketOfGridElement>().coordsToTarget = new Vector2Int(_endPoints[j].x, _endPoints[j].y); tempObj.GetComponent <SocketOfGridElement>().targetGo = tempMCE; tempMCE.GetComponent <MultiCellElement>().AddToList(tempMCE.GetComponent <MultiCellElement>().incomingSockets, tempVecIncomingSocket); _outputs[j] = tempMCE.GetComponent <MultiCellElement>(); } }
private void Start() { GetComponent <Button>().onClick.AddListener(() => { if (Placer.GetInstance().GetPlaceable() != null) { Placer.GetInstance().ClearPlaceable(); } else { buildDrawer.SetActive(!buildDrawer.activeSelf); } }); }
private bool RSCLoadingInicialization(string IDD) { if (IsSC(IDD, "Сотрудники")) { return(Placer.FoundIDD(IDD)); } else { FExcStr = "Не верный тип справочника!"; return(false); } //return true; }
// Start is called before the first frame update void Start() { GameManeger gameManeger = GetComponent <GameManeger>(); maxLenght = gameManeger.Difficulty + 5; corners = maxLenght / 4; random = new System.Random(); placer = GetComponent <Placer>(); placer.fade = corners * 0.4f + 1f + 0.4f; Generate(); }
private void Awake() { placer = GetComponent <Placer>(); placer.objectPlaced += onObjectPlacedOnPath; pathCreator = placer.pathCreator; ignoredAxis = placer.ignoredAxis; if (endInstruction == EndOfPathInstruction.Loop && pathCreator != null && !pathCreator.path.isClosedLoop) { endInstruction = EndOfPathInstruction.Reverse; backwardSpeed = forwardSpeed; } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); Placer t = (Placer)target; if (GUILayout.Button("Place to grid")) { t.PlaceToGrid(); } if (GUILayout.Button("Revert positions")) { t.RevertPositions(); } }
public override void OnTrigger(Mobile from) { if (!IsEnemy(from)) { return; } Conceal(); DoVisibleEffect(); Effects.PlaySound(Location, Map, EffectSound); DoAttackEffect(from); var silverToAward = from.Alive ? 20 : 40; if (silverToAward > 0 && Placer != null && Faction != null) { var victimState = PlayerState.Find(from); if (victimState?.CanGiveSilverTo(Placer) == true && victimState.KillPoints > 0) { var silverGiven = Faction.AwardSilver(Placer, silverToAward); if (silverGiven > 0) { // TODO: Get real message if (from.Alive) { Placer.SendMessage( "You have earned {0} silver pieces because {1} fell for your trap.", silverGiven, from.Name ); } else { Placer.SendLocalizedMessage( 1042736, $"{silverGiven} silver\t{from.Name}" ); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~! } } victimState.OnGivenSilverTo(Placer); } } from.LocalOverheadMessage(MessageType.Regular, MessageHue, AttackMessage); }
public void Refund() { Gold toGive = new Gold(Price); if (Placer.BankBox.TryDropItem(Placer, toGive, false)) { Delete(); Placer.SendLocalizedMessage(1060397, toGive.Amount.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } else { toGive.Delete(); Placer.SendMessage("Your bankbox is full!"); } }
//////////////////////////////////////////////////////////////////////////////////////////// // General Input-Behaviour Methods /* * Cancel method, to either present the Pause menu, or stop placing a logic element on Powercity. * @param context Information provided by the triggering event. In this case the buttonpress on the ESC-key. */ private void Cancel(InputAction.CallbackContext context) { // If the selection is blocked, and therefore the player must be placing sockets to an logic-element in powercity, stop this process. if (_selectionBlocked) { Placer.PlaceObject(_mainGrid.grid, _filler.go, tempTargetCoord.x, tempTargetCoord.y, _filler.go); _incomingSocketsToPlace = 0; _outgoingSocketsToPlace = 0; _selectionBlocked = false; selected.go = null; return; } // In any other case, pause the game. PauseGame(); }
/* * After being added to the input-behaviour, this method is called every frame the mouse has moved and is used to continously place connections, * while the left mouse-button is being held down. * @param context Information provided by the triggering event. In this case the movement of the mouse. */ private void PlaceConnection(InputAction.CallbackContext context) { // Cast a ray from the camera through the cursor and keep a reference to the hit object. Ray ray = _camera.go.GetComponent <Camera>().ScreenPointToRay(Mouse.current.position.ReadValue()); RaycastHit hit; // If an object was hit, place a connection-element on it's place. if (Physics.Raycast(ray, out hit)) { // Get the coordinates of the hit grid-element, if it is one. Vector2Int temp = _mainGrid.grid.GetCoordinate(hit.point); // Place a connection element on the hit grid-element. Placer.PlaceObject(_mainGrid.grid, selected.go, temp.x, temp.y, _filler.go); } }
// Use this for initialization void Start() { GameObject boardContainer = Generator.Generate(cell, numberOfRows, numberOfColumns); GameObject[] cellList = FindByTag("Cell"); map = fillMap(cellList); Placer.PlaceEnemies(cellList, numberOfMines, mine); Labeller.Label(map, numberOfRows, numberOfColumns); flaggedCells = 0; totalCells = numberOfRows * numberOfColumns; revealedCells = 0; gameOver = false; boardRevealed = false; gameWon = false; }
void OnGUI() { GUI.Label(new Rect(Screen.width/2, 40,200,50), "XP : " + playerAttributes.experience); Placer placer = null; if (paused) { // todo is this a on screen location if (activePlacer == null) { // todo if buttons have been clicked then others can't be...or if they are they've gotta be deleted if (playerAttributes.experience >= buttonOneCost) { if (GUI.Button (new Rect(20,40,200,50), buttonOneTexture)) { placer = ((GameObject) Instantiate(buttonOnePlacer)).GetComponent<Placer>(); if (placer != null) { placer.SetObserver(this, buttonOneCost); activePlacer = placer; return; } else { Debug.LogError("Button one's associated game object does not have a placer component"); } } GUI.Label(new Rect(40,100,200,50), "XP COST : " + buttonOneCost); } else { GUI.Button (new Rect(20,40,200,50), "REQ. " + buttonOneCost + " XP"); } if (playerAttributes.experience >= buttonTwoCost) { if (GUI.Button (new Rect(240,40,200,50), buttonTwoTexture)) { placer = ((GameObject)Instantiate(buttonTwoPlacer)).GetComponent<Placer>(); if (placer != null) { placer.SetObserver(this, buttonTwoCost); activePlacer = placer; return; } else { Debug.LogError("Button two's associated game object does not have a placer component"); } } GUI.Label(new Rect(260,100,200,50), "XP COST : " + buttonTwoCost); } else { GUI.Button (new Rect(240,40,200,50), "REQ. " + buttonTwoCost + " XP"); } } else { if (GUI.Button (new Rect(Screen.width - 220, 40,200,50), "FLIP")) { // TODO perhaps better way than message passing. Use a reference for speed. activePlacer.flip(); } } } }
// Start is called before the first frame update void Awake() { SetParams(); UITableFiller.FillTable(_expectedPanel, _expectedResults.valueArray, _variableCount.value, _expectedResults.valueArray); int cellCount = Convert.ToInt32(Math.Pow(2, _variableCount.value)); while (_width * _height != cellCount) { if (_width == _height) { _width *= 2; } else { _height *= 2; } } _charges.keyValuePairs = new Dictionary <char, bool>(); _charges.keyValuePairs['A'] = true; _charges.keyValuePairs['B'] = true; _charges.keyValuePairs['C'] = true; _charges.keyValuePairs['D'] = true; _charges.keyValuePairs['E'] = true; _grid = new Grid(_width, _height, 12, _gridOffset); _mainGrid.grid = _grid; InputHandler.instance.ChangeGIT(GameInputType.KV); Dictionary <char, bool> temp = new Dictionary <char, bool>(); GameObject empty = Resources.Load <GameObject>("Prefabs/empty"); for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { temp = PrepareCharge(i, j); GameObject tempObj = Placer.PlaceObject(_grid, empty, i, j); tempObj.GetComponent <KVelement>().charge = ChargeCombinationToInt(temp); tempObj.GetComponent <KVelement>().text.text = ChargeCombinationToInt(temp).ToString(); } } DrawIndicators(); }
private void OnEnable() { follower = target as Follower; placer = follower.GetComponent <Placer>(); endInstruction = serializedObject.FindProperty(nameof(endInstruction)); forwardSpeed = serializedObject.FindProperty(nameof(forwardSpeed)); forwardSpeedCurve = serializedObject.FindProperty(nameof(forwardSpeedCurve)); backwardSpeed = serializedObject.FindProperty(nameof(backwardSpeed)); backwardSpeedCurve = serializedObject.FindProperty(nameof(backwardSpeedCurve)); startDelay = serializedObject.FindProperty(nameof(startDelay)); stopDelay = serializedObject.FindProperty(nameof(stopDelay)); rotateTowards = serializedObject.FindProperty(nameof(rotateTowards)); lookAt = serializedObject.FindProperty(nameof(lookAt)); lookAtAxis = serializedObject.FindProperty(nameof(lookAtAxis)); destroyOnStop = serializedObject.FindProperty(nameof(destroyOnStop)); unscaledDeltaTime = serializedObject.FindProperty(nameof(unscaledDeltaTime)); }
public override IEnumerator _Next(EntityPlayer player) { /* Over should keep some memory (position), and regenerate toward player */ long start_time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); Emplacement placeBase = new Emplacement(player, opt); placeBase.direction = Vectors.Float.Randomize(this.rand, 1f); // useless for peak Printer.Log(46, "MultiEffect._Next() placeBase", player, placeBase.position, placeBase.direction); foreach (int p in Cycler.Over()) { if (Cycler.dt >= 0 && DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - start_time > (long)(Cycler.dt * 1000)) { yield break; } Printer.Log(41, "_Next iterating Over"); Vector3 maybeFollowing = (this.isFollowing) ? player.GetPosition() : placeBase.position; int q = -1; foreach (Emplacement place in Iter.On(Placer.Get(maybeFollowing))) { q = q + 1; if (q >= Repeater.n) { break; } if (place.valid) { Printer.Log(40, "MultiEffect._Next iterating Clones", place); // last before null (firestorm) // float state = ((float) q) / Repeater.copies; OptionEffect rdm = Randomize(); Printer.Log(40, "_Next Randomized", p, q, opt); Printer.Log(40, "_Next Place", p, q, place); this.Effect1(player, place, rdm); } else { Printer.Log(40, "Invalid place:", q, place, place.valid_msg); } yield return(Repeater.Yield); } yield return(Cycler.Yield); } }
} // end move placer down void movePlacerLeft(Placer placer) { placer.x--; if (placer.x < 0) { placer.x++; float randomDir = Random.Range(0, 1f); if (randomDir >= 0.5) { movePlacerUp(placer); }// end if else { movePlacerDown(placer); } // end else } // end if } // end move player left
} // end move placer right void movePlacerDown(Placer placer) { placer.y--; if (placer.y < 0) { placer.y++; float randomDir = Random.Range(0, 1f); if (randomDir >= 0.5) { movePlacerRight(placer); }// end if else { movePlacerLeft(placer); } // end else } // end if } // end move placer down
} // end move placer up void movePlacerRight(Placer placer) { placer.x++; if (placer.x >= width) { placer.x--; float randomDir = Random.Range(0, 1f); if (randomDir >= 0.5) { movePlacerUp(placer); }// end if else { movePlacerDown(placer); } // end else } // end if } // end move placer right
}// end subtract rooms /* * * * NOTE* all of the move placer functions are practicaly the same, only difference is which direction they move in, * and what the maximum or minium value they can move too is. * * for example look at move Placer Up, first thing it does is move the placer up * but if the y of the placer is greater or equal to height it moves it back down * and then chooses a random direction from 0 - 1 and if it is greater or equal to * 0.5 it moves right, otherwise it will move left. * */ void movePlacerUp(Placer placer) { placer.y++; if (placer.y >= height) { placer.y--; float randomDir = Random.Range(0, 1f); if (randomDir >= 0.5) { movePlacerRight(placer); }// end if else { movePlacerLeft(placer); } // end else } // end if } // end move placer up
public void ObserverBuy(int cost) { playerAttributes.experience -= cost; activePlacer = null; }
public void ObserveCancel() { activePlacer = null; }