예제 #1
0
    /// <summary>
    /// if we're in game mode, the tooltip's background will change color according to the current playing faction's
    /// relation value with the target owner faction
    /// </summary>
    /// <param name="targetOwnerFaction"></param>
    public void ChangeBackgroundAccordingToFactionRelations(Faction targetOwnerFaction)
    {
        if (GameInterface.IsInGameMode())
        {
            if (GameModeHandler.instance.curPlayingFaction != targetOwnerFaction)
            {
                GameFactionRelations.FactionStanding relationToPlayer =
                    GameModeHandler.instance.curPlayingFaction.GetStandingWith(targetOwnerFaction);

                switch (relationToPlayer)
                {
                case GameFactionRelations.FactionStanding.ally:
                    backgroundImg.color = isAlliedColor;
                    break;

                case GameFactionRelations.FactionStanding.enemy:
                    backgroundImg.color = isEnemyColor;
                    break;

                default:
                    backgroundImg.color = isNeutralColor;
                    break;
                }
            }
            else
            {
                backgroundImg.color = defaultColor;
            }
        }
        else
        {
            backgroundImg.color = defaultColor;
        }
    }
예제 #2
0
    /// <summary>
    /// this makes our faction change its relation levels after an attack
    /// if the attack somehow affected it (attacked faction was an ally, for example)
    /// </summary>
    /// <param name="ourFacID"></param>
    /// <param name="attackerFacs"></param>
    /// <param name="attackedFacID"></param>
    public static void FacReactToAttack(int ourFacID, List <int> attackerFacs, int attackedFacID)
    {
        GameInfo gData = GameController.CurGameData;

        Faction ourFac = GameController.GetFactionByID(ourFacID);

        if (ourFacID == attackedFacID)
        {
            gData.factionRelations.AddRelationBetweenFactions(ourFacID, attackerFacs, GetRelDmgAttacked(),
                                                              false);
        }
        else if (attackedFacID >= 0)
        {
            if (!attackerFacs.Contains(ourFacID))
            {
                Faction attackedFac = GameController.GetFactionByID(attackedFacID);
                GameFactionRelations.FactionStanding standingWithAttacked =
                    attackedFac.GetStandingWith(ourFacID);
                if (standingWithAttacked == GameFactionRelations.FactionStanding.enemy)
                {
                    ourFac.AddRelationWith(attackerFacs, GetRelGainEnemyAttacked());
                }
                else
                {
                    if (standingWithAttacked == GameFactionRelations.FactionStanding.ally)
                    {
                        ourFac.AddRelationWith(attackerFacs, GetRelDmgAllyAttacked());
                    }

                    //add some relation to the attacked if at least one of the attackers is an enemy of ours
                    bool attackersContainEnemy = false;
                    foreach (int facID in attackerFacs)
                    {
                        if (ourFac.GetStandingWith(facID) == GameFactionRelations.FactionStanding.enemy)
                        {
                            attackersContainEnemy = true;
                            break;
                        }
                    }
                    if (attackersContainEnemy)
                    {
                        ourFac.AddRelationWith(attackedFac, GetRelGainAttackedByEnemy());
                    }
                }
                //and worsen relations
                ourFac.AddRelationWith(attackerFacs, GetRelDmgAggressiveBehaviour());
            }
            else
            {
                foreach (int atkerFacID in attackerFacs)
                {
                    if (atkerFacID != ourFacID)
                    {
                        ourFac.AddRelationWith(atkerFacID, GetRelGainJoinAttack());
                    }
                }
            }
        }
    }