public void Start() { animator = GetComponent <Animator>(); roadTool = GetComponent <RoadTool>(); buildingTool = GetComponent <BuildingTool>(); moveUI = GetComponent <MoveUI>(); tileHighlighter = GetComponent <TileHighlighter>(); Menus = new GameObject[] { buildingMenu, mainMenu, buildMenu }; foreach (CompoundButton menuButton in buildMenuButtons) { menuButton.OnButtonClicked += BuildMenuButtonPressed; } foreach (CompoundButton menuButton in mainMenuButtons) { menuButton.OnButtonClicked += MainMenuButtonPressed; } foreach (CompoundButton timeButton in timeButtons) { timeButton.OnButtonClicked += TimeButtonPressed; } }
/// <summary> /// Main mod class constructor. Sets up the static instance. /// </summary> public PrepareLanding() { Logger.Message("Enter constructor."); if (Instance == null) { Instance = this; } // initialize events EventHandler = new RimWorldEventHandler(); // global game options GameOptions = new GameOptions(Settings, EventHandler); // instance used to keep track of (or override) game ticks. GameTicks = new GameTicks(); // Holds various mod options (shown on the 'option' tab on the GUI). var filterOptions = new FilterOptions(); GameData = new GameData.GameData(filterOptions); TileFilter = new WorldTileFilter(GameData.UserData); // instantiate the tile highlighter TileHighlighter = new TileHighlighter(filterOptions); Logger.Message("Exit constructor."); }
/// <summary> /// Start this instance. /// </summary> private void Initialize() { print("Unit.Initialize"); Transform unitSpriteTransform = transform.Find("Sprite(Clone)"); _unitAnimationController = unitSpriteTransform.GetComponent <UnitAnimationController> (); _spriteRenderer = unitSpriteTransform.GetComponent <SpriteRenderer> (); _attributeCollection = UnitData.AttributeCollection; _effectCollection = new EffectCollection(); _modifyAttributeEffectCollection = new ModifyAttributeEffectCollection(); _unitColorEffects = new List <UnitColorEffect> (); SetMaximumValueToCurrentValue(AttributeEnums.AttributeType.HIT_POINTS); SetMaximumValueToCurrentValue(AttributeEnums.AttributeType.ABILITY_POINTS); _inventorySlots = UnitData.InventorySlots; _canvas = transform.Find("Canvas").GetComponent <Canvas> (); FacedDirection = TileDirection.EAST; _characterSheetController = GameManager.Instance.GetCharacterSheetController(); _combatMenuController = GameManager.Instance.GetCombatMenuController(); TileHighlighter = new TileHighlighter(GameManager.Instance.GetTileMap(), _movementHighlightCube); _movementAudioSource = gameObject.AddComponent <AudioSource> (); _weaponAudioSource = gameObject.AddComponent <AudioSource> (); _currentColor = DefaultColor; }
private bool handleAttack(bool updateState) { // If both tanks have been clicked, orchestrate the attack if (tankClicked != null && tankClicked2 != null) { // Create coordinates CoordinateSet currentPlayerTankCoordinates = new CoordinateSet((int)tankClicked.transform.position.x, (int)tankClicked.transform.position.z); CoordinateSet targetPlayerTankCoordinates = new CoordinateSet((int)tankClicked2.transform.position.x, (int)tankClicked2.transform.position.z); PlayerColors opposingPlayer; if (playerTurn == PlayerColors.Red) { opposingPlayer = PlayerColors.Blue; } else { opposingPlayer = PlayerColors.Red; } if (gs.getPlayerTank(playerTurn, currentPlayerTankCoordinates).getHealth() <= 0 || gs.getPlayerTank(opposingPlayer, targetPlayerTankCoordinates).getHealth() <= 0) { return(false); } // Check if the attack is valid if (gs.checkValidAttack(playerTurn, currentPlayerTankCoordinates, targetPlayerTankCoordinates, updateState)) { if (!updateState) { return(true); } // Do knockback handleKnockback(currentPlayerTankCoordinates, targetPlayerTankCoordinates); } else { if (!updateState) { return(false); } } // Update player powerup state gs.updatePlayerPowerupState(playerTurn); // Update the state information round = Rounds.Gamble; TileHighlighter.resetTiles(); gs.toggleTankRings(playerTurn == PlayerColors.Red ? redTanks : blueTanks, new CoordinateSet(-1, -1), true); gs.toggleTankRings(playerTurn == PlayerColors.Red ? blueTanks : redTanks, new CoordinateSet(-1, -1), false); printTurn(); tankClicked = null; tankClicked2 = null; updateTooltips("Gamble"); } return(true); }
/// <summary> /// Called when the world map is generated. /// </summary> /// <remarks>This is not a RimWorld event. It is generated by an Harmony patch.</remarks> public void WorldGenerated() { // disable all tiles that are currently highlighted TileHighlighter.RemoveAllTiles(); // call onto subscribers to tell them that the world has been generated. OnWorldGenerated.Invoke(); }
public static void highlightTilesAt(Vector2 originLocation, Color highlightColor, int distance) { List <GameTile> highlightedTiles = TileHighlighter.FindHighlight(GameManager.instance.map[(int)originLocation.x][(int)originLocation.y], distance); foreach (GameTile tile in highlightedTiles) { tile.transform.GetComponent <Renderer>().material.color = highlightColor; } }
private void Start() { buttonMenuPrefab = Instantiate(buttonMenuPrefab); buttonMenuPrefab.SetActive(false); indicatorPrefab.SetActive(false); tileHighlighter = GetComponent <TileHighlighter>(); GetButtons(); }
private void highlightAttackTiles(CoordinateSet currentTankCoordinates) { gs.toggleTankRings(playerTurn == PlayerColors.Red ? redTanks : blueTanks, currentTankCoordinates, true); gs.toggleTankRings(playerTurn == PlayerColors.Red ? blueTanks : redTanks, new CoordinateSet(-1, -1), true); Tank currentTank = gs.getPlayerTank(playerTurn, currentTankCoordinates); TileHighlighter.highlightValidTiles(currentTank.getWeapon().getValidAttacks(gs.getGrid()), round); }
// Use this for initialization void Start() { _meshFilter = GetComponent <MeshFilter>(); _meshCollider = GetComponent <MeshCollider>(); if (TileHighlighter == null) { TileHighlighter = FindObjectOfType <TileHighlighter>(); } GenerateMesh(); }
private void assignTanksClicked(RaycastHit hit) { // Assign tanks clicked Tank currentTank; if (hit.transform.gameObject.tag == "Red Tank") { currentTank = gs.getPlayerTank(PlayerColors.Red, new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z)); if (playerTurn == PlayerColors.Red && !currentTank.isDead()) { tankClicked = hit.transform.gameObject; TileHighlighter.resetTiles(); highlightAttackTiles(new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z)); if (gs.playerHasValidAttack(playerTurn, new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z))) { updateTooltips("Attack2"); } else { updateTooltips("Attack3"); } } else if (!currentTank.isDead()) { tankClicked2 = hit.transform.gameObject; TileHighlighter.resetTiles(); } } else if ((hit.transform.gameObject.tag == "Blue Tank")) { currentTank = gs.getPlayerTank(PlayerColors.Blue, new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z)); if (playerTurn == PlayerColors.Blue && !currentTank.isDead()) { tankClicked = hit.transform.gameObject; TileHighlighter.resetTiles(); highlightAttackTiles(new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z)); if (gs.playerHasValidAttack(playerTurn, new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z))) { updateTooltips("Attack2"); } else { updateTooltips("Attack3"); } } else if (!currentTank.isDead()) { tankClicked2 = hit.transform.gameObject; TileHighlighter.resetTiles(); } } }
public void Hide() { if (isShowing) { isShowing = false; foreach (Highlight light in lights) { TileHighlighter.DestroyHighlight(light); } lights.Clear(); } }
public void Hide() { if (ramMove != null) { MapController.instance.GetTile(ramMove.pos).OnMouseClick -= ramMove.OnMouseClick; } TileHighlighter.DestroyHighlight(posHighlight); foreach (PossibleMove move in possibleMoves) { MapController.instance.GetTile(move.destination).OnMouseClick -= move.OnMouseClick; TileHighlighter.DestroyHighlight(move.highlight); } }
private void handleMove(RaycastHit hit) { if ((hit.transform.gameObject.tag == "Red Tank" && playerTurn == PlayerColors.Red) || (hit.transform.gameObject.tag == "Blue Tank" && playerTurn == PlayerColors.Blue)) { tankClicked = hit.transform.gameObject; CoordinateSet tankCoordinates = new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z); Tank currentTank = gs.getPlayerTank(playerTurn, tankCoordinates); // If the player didn't choose one of their own tanks, or if that tank is dead, just ignore if (currentTank.isDead() || currentTank.getPlayer().getPlayerColor() != playerTurn) { tankClicked = null; return; } TileHighlighter.resetTiles(); TileHighlighter.highlightValidTiles(currentTank.getValidMovements(gs.getGrid(), tankCoordinates), round); gs.toggleTankRings(playerTurn == PlayerColors.Red ? redTanks : blueTanks, tankCoordinates, true); gs.toggleTankRings(playerTurn == PlayerColors.Red ? blueTanks : redTanks, new CoordinateSet(-1, -1), false); updateTooltips("Move2"); } else if (tankClicked != null) { tileClicked = hit.transform.gameObject; CoordinateSet tankCoordinates = new CoordinateSet((int)tankClicked.transform.position.x, (int)tankClicked.transform.position.z); CoordinateSet tileCoordinates = new CoordinateSet((int)tileClicked.transform.position.x, (int)tileClicked.transform.position.z); if (gs.checkValidMove(playerTurn, tankCoordinates, tileCoordinates, true)) { TileHighlighter.resetTiles(); Tank currentTank = gs.getPlayerTank(playerTurn, tileCoordinates); // Tank moving animation StartCoroutine(moveTank(tileClicked, tankClicked, currentTank)); tileClicked = null; tankClicked = null; round = Rounds.Attack; TileHighlighter.resetTiles(); printTurn(); updateTooltips("Attack1"); gs.toggleTankRings(redTanks, new CoordinateSet(-1, -1), false); gs.toggleTankRings(blueTanks, new CoordinateSet(-1, -1), false); } } }
/// <summary> /// Init this instance. /// </summary> private IEnumerator Init() { selectionIcon = controller.SelectionIcon; characterSheetController = controller.CharacterSheetController; terrainDetailsController = controller.TerrainDetailsController; tileMap = controller.TileMap; nextUnitInLine = controller.TurnOrderController.GetNextUp(); tileHighlighter = nextUnitInLine.TileHighlighter; controller.ShowCursorAndTileSelector(true); // If the unit had a deferred Ability, use that right now if (nextUnitInLine.HasDeferredAbility) { controller.HighlightedUnit = nextUnitInLine; yield return(null); controller.ChangeState <PlayerPerformActionState> (); } }
private void changeTurns() { if (playerTurn == PlayerColors.Red) { playerTurn = PlayerColors.Blue; if (aiON == false) { camera.translateToPlayer(PlayerColors.Blue); } } else { playerTurn = PlayerColors.Red; if (aiON == false) { camera.translateToPlayer(PlayerColors.Red); } } TileHighlighter.resetTiles(); gs.toggleTankRings(redTanks, new CoordinateSet(-1, -1), false); gs.toggleTankRings(blueTanks, new CoordinateSet(-1, -1), false); roundCounter++; }
/// <summary> /// Called during mod initialization. /// </summary> public override void Initialize() { Logger.Message("Initializing."); // initialize events PatchWorldInterfaceOnGui.OnWorldInterfaceOnGui += WorldInterfaceOnGui; PatchWorldInterfaceUpdate.OnWorldInterfaceUpdate += WorldInterfaceUpdate; // various options show on the 'option' tab on the GUI. _filterOptions = new FilterOptions(); // main instance to keep user filter choices on the GUI. UserData = new UserData(_filterOptions); TileFilter = new WorldTileFilter(UserData); // instantiate the main window now MainWindow = new MainWindow(UserData); // instantiate the tile highlighter TileHighlighter = new TileHighlighter(); Instance.OnWorldInterfaceOnGui += TileHighlighter.HighlightedTileDrawerOnGui; Instance.OnWorldInterfaceUpdate += TileHighlighter.HighlightedTileDrawerUpdate; }
void Awake() { instance = this; }
// Update is called once per frame void Update() { if (aiON && aiMove) { return; } if (numGambles == 4) { updateTooltips("GLHF"); } // Check if gameover gameOver(); // Run if ai's turn if (playerTurn == PlayerColors.Blue && aiON) { gs.toggleTankRings(redTanks, new CoordinateSet(-1, -1), false); gs.toggleTankRings(blueTanks, new CoordinateSet(-1, -1), false); //handleGreedyAi(); if (aiMove == false) { aiMove = true; if (currentLevel == Levels.Level1) { StartCoroutine(handleGreedyAi()); } else { StartCoroutine(handleMinMaxAi()); } } } // Skip turn if spacebar is pressed if (Input.GetKeyDown(KeyCode.Space) && !aiMove) { round++; TileHighlighter.resetTiles(); if (round == Rounds.Gamble) { gs.toggleTankRings(playerTurn == PlayerColors.Red ? redTanks : blueTanks, new CoordinateSet(-1, -1), true); gs.toggleTankRings(playerTurn == PlayerColors.Red ? blueTanks : redTanks, new CoordinateSet(-1, -1), false); updateTooltips("Gamble"); gs.updatePlayerPowerupState(playerTurn); } if (round == Rounds.Attack) { gs.toggleTankRings(redTanks, new CoordinateSet(-1, -1), false); gs.toggleTankRings(blueTanks, new CoordinateSet(-1, -1), false); updateTooltips("Attack1"); } if (round > Rounds.Gamble) { round = Rounds.Move; updateTooltips("Move1"); numGambles++; changeTurns(); } printTurn(); } // If nothing has been clicked, return if (oc.objectClicked == null) { return; } // Assign variables objectClicked = oc.objectClicked; oc.objectClicked = null; ClickItems items = getItemClicked(); RaycastHit hit = items.getRaycastHit(); if (!items.isValid()) { return; } switch (round) { case Rounds.Move: handleMove(hit); break; case Rounds.Attack: assignTanksClicked(hit); handleAttack(true); break; case Rounds.Gamble: handleGamble(hit); break; } gs.updatePlayerHealthBars(hpController); }