Example #1
0
    /// <summary>
    /// Handles the cursor over event.
    /// </summary>
    /// <param name="ray">Ray.</param>
    private void HandleCursorOver()
    {
        TileData tileData = GetCursorCurrentTileData();

        if (tileData != null)
        {
            controller.CursorMoveSource.PlayOneShot(controller.CursorMoveSource.clip);

            // Move selection icon
            selectionIcon.transform.position = controller.CurrentTileCoordinates * tileMap.TileSize;

            // Show terrain UI
            terrainDetailsController.Activate(tileData);

            // Handle highlighting units and unit turn order images
            if (!controller.TurnOrderController.IsImageHighlighted)
            {
                Unit unit = tileData.Unit;
                if (unit != null)
                {
                    // If it's a new highlighted unit, remove highlighted tiles from previous one
                    if (controller.HighlightedUnit != null && unit != controller.HighlightedUnit)
                    {
                        controller.TurnOrderController.DeHighlightUnitImage();
                        controller.HighlightedUnit.TileHighlighter.RemoveHighlightedTiles();
                    }

                    unit.ActivateCharacterSheet();
                    unit.TileHighlighter.HighlightTiles(unit, unit.Tile);
                    controller.HighlightedUnit = unit;
                    controller.TurnOrderController.HighlightUnitImage(unit);
                }
                else
                {
                    if (controller.HighlightedUnit != null)
                    {
                        // We only want to de-highlight unit if they don't have persistent tiles highlighted
                        if (!controller.HighlightedUnit.TileHighlighter.IsPersistent)
                        {
                            controller.TurnOrderController.DeHighlightUnitImage();
                            controller.HighlightedUnit.TileHighlighter.RemoveHighlightedTiles();
                        }

                        characterSheetController.Deactivate();
                        controller.HighlightedUnit = null;
                    }
                }
            }
        }
    }
Example #2
0
    private void Init()
    {
        _tileMap    = controller.TileMap;
        _pathfinder = controller.Pathfinder;

        _cpu = controller.TurnOrderController.GetNextUp();
        controller.HighlightedUnit = _cpu;

        // If cpu has persistent highlighted tiles, temporarily remove, then re-apply after move
        _hasPersistentHighlightedTiles = _cpu.TileHighlighter.IsPersistent;
        if (_hasPersistentHighlightedTiles)
        {
            _cpu.TileHighlighter.RemovePersistentHighlightedTiles();
        }

        _cpu.Highlight();
        _cpu.Select();

        // Show terrain related things
        Vector3  cpuTilemapCoordinates = TileMapUtil.WorldCenteredToTileMap(_cpu.transform.position, _tileMap.TileSize);
        TileData tileData = _tileMap.GetTileMapData().GetTileDataAt(cpuTilemapCoordinates);

        controller.TerrainDetailsController.Activate(tileData);

        // Show character sheet
        _cpu.ActivateCharacterSheet();

        // Show movement tiles
        _cpu.TileHighlighter.HighlightTiles(_cpu, cpuTilemapCoordinates, false);

        // Get AI Action
        // TODO: Refactor the shit out of all of this. I'm so not proud of this.
        AI ai = new KamiKazeAI(_cpu, _tileMap.GetTileMapData(), controller.TileDiscoverer, _pathfinder);

        _cpu.Action = ai.GetAction();

        //print (string.Format ("Start CPU Turn: {0}", _selectedCharacter));
        StartCoroutine(Move());
    }