Beispiel #1
0
    void ClearHoverTile()
    {
        if (hoverTile == null)
        {
            return;
        }
        bool highlighted = false;

        for (int i = 0; i < highlightedTiles.Count; i++)
        {
            if (highlightedTiles[i] == hoverTile)
            {
                highlighted = true;
                break;
            }
        }
        if (highlighted)
        {
            hoverTile.GetComponent <Renderer>().material.color = new Color(0.3f, 0.3f, 0.3f, 1.0f);
        }
        else
        {
            hoverTile.GetComponent <Renderer>().material.color = new Color(0.375f, 0.375f, 0.375f, 1.0f);
        }

        CombatMonsterGroup group = GetArmyAt(hoverTile.gamePosition);

        hoverTile          = null;
        debugPosition.text = "";

        if (group == null)
        {
            return;
        }
        if (group.dead)
        {
            return;
        }

        TimelineTurn turn = GetTimelineItem(group.armyId);

        turn.SetColor(new Color(1.0f, 1.0f, 1.0f, 0.4f));

        if (currentArmy == group)
        {
            group.SetColor(new Color(0.3f, 0.3f, 0.6f, 1.0f));
        }
        else
        {
            group.SetColor(new Color(1.0f, 1.0f, 1.0f));
        }
    }
Beispiel #2
0
    void NextTurn()
    {
        TimelineTurn turn = timeline.transform.GetChild(0).GetComponent <TimelineTurn>();

        currentPlayer = turn.group.playerId;
        turnTitle.GetComponent <Text>().text = GetTurnTitle(currentPlayer);

        if (currentArmy)
        {
            currentArmy.SetColor(new Color(1.0f, 1.0f, 1.0f, 1.0f));
        }
        currentArmy = turn.group;
        currentArmy.SetColor(new Color(0.3f, 0.3f, 0.6f, 1.0f));
        currentArmy.hasMoved    = false;
        currentArmy.hasAttacked = false;

        Camera.main.GetComponent <CameraController>().MoveTo(currentArmy.transform.position + new Vector3(0.0f, 0.0f, -3.0f));

        pathfinder.SetTerrain(terrainPassable);
        List <Vector2i> tilesInRange = pathfinder.GetInRange(currentArmy.gamePosition, Creatures.Get(currentArmy.creatureId).speed);

        ClearHighlightedTiles();
        HighlightTiles(tilesInRange);

        pathfinder.SetTerrain(GetPassableTerrain());
        if (currentPlayer != 0)
        {
            computerTurnStartDelay   = true;
            computerTurnStartCurrent = 0.0f;
        }
    }
Beispiel #3
0
    void HoverTile()
    {
        Vector3    mousePosition = Input.mousePosition;
        Ray        ray           = Camera.main.ScreenPointToRay(mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.collider.tag == "Tile")
            {
                Tile   tile    = hit.collider.GetComponent <Tile>();
                bool   isthere = GetArmyAt(tile.gamePosition) == null;
                string has     = isthere ? "true" : "false";
                debugPosition.text = tile.gamePosition.ToString() + ": " + has;
                CombatMonsterGroup group = GetArmyAt(tile.gamePosition);
                if (group != null)
                {
                    int          armyId = group.armyId;
                    TimelineTurn turn   = GetTimelineItem(armyId);
                    turn.SetColor(new Color(0.75f, 0.75f, 0.0f, 0.4f));
                    group.SetColor(new Color(0.75f, 0.75f, 0.0f));

                    string   contextString = "";
                    Creature creature      = Creatures.Get(group.creatureId);
                    if (group.playerId != 0)
                    {
                        contextString = GetChanceToHit(Creatures.Get(currentArmy.creatureId).attack, creature.defense).ToString() + "%\n";
                    }
                    contextString += "A: " + creature.attack + "\nD: " + creature.defense + "\nDMG: " + creature.damage + "\nSPD: " + creature.speed;
                    ShowContext(contextString, group.transform.position);
                }
                else
                {
                    HideContext();
                }
                tile.GetComponent <Renderer>().material.color = new Color(0.2f, 0.2f, 0.2f, 1.0f);
                if (hoverTile && hoverTile.gamePosition != tile.gamePosition)
                {
                    ClearHoverTile();
                }
                hoverTile = tile;
            }
            else
            {
                ClearHoverTile();
                HideContext();
            }
        }
        else
        {
            ClearHoverTile();
            HideContext();
        }
    }