コード例 #1
0
ファイル: Combats.cs プロジェクト: Juamedrod/Ponienteros
    public int Assasination(ref DiplomacyAgent myAgent, ref DiplomacyAgent enemyAgent, int mySpies, int enemySpies)
    {
        int asasinationCoefPositive = 0, asasinationCoefNegative = 0;
        int absCoeficient = 0;

        if (myAgent.noble)
        {
            asasinationCoefPositive++;
        }
        if (myAgent.havePeopleLove)
        {
            asasinationCoefPositive++;
        }
        if (enemyAgent.noble)
        {
            asasinationCoefNegative++;
        }
        if (enemyAgent.havePeopleLove)
        {
            asasinationCoefNegative++;
        }

        myAgent.numberOfSpies    -= mySpies;
        enemyAgent.numberOfSpies -= enemySpies;
        assasinationCoeficient    = asasinationCoefPositive - asasinationCoefNegative;//coeficient given by agents traits
        //abscoeficient shows the balance between strength in each case(assa, dissua, cheat) relative to eachother.
        absCoeficient = (myAgent.assasinationStrength + mySpies + asasinationCoefPositive) - (enemyAgent.assasinationStrength + enemySpies + asasinationCoefNegative);

        if (absCoeficient >= 0)
        {
            enemyAgent.diplomacyStrength -= absCoeficient;
            ReloadUI();
            if (enemyAgent.diplomacyStrength < 0)
            {
                Victory();
                this.gameObject.SetActive(false);
                return(0);//myAgent wins and kill enemy
            }
            Victory();
            this.gameObject.SetActive(false);
            return(2);//my agent hit enemy agent but its not enough to kill him
        }
        else
        {
            myAgent.diplomacyStrength += absCoeficient;
            Defeat();
        }

        ReloadUI();
        this.gameObject.SetActive(false); //close combat windows
        return(1);                        //my agent is blocked by the enemy
    }
コード例 #2
0
ファイル: Combats.cs プロジェクト: Juamedrod/Ponienteros
    public int Dissuade(ref DiplomacyAgent myAgent, ref DiplomacyAgent enemyAgent, int mySpies, int enemySpies)
    {
        int dissuadeCoefPositive = 0, dissuadeCoefNegative = 0;
        int absCoeficient = 0;

        if (myAgent.Smart)
        {
            dissuadeCoefPositive++;
        }
        if (myAgent.havePeopleLove)
        {
            dissuadeCoefPositive++;
        }
        if (enemyAgent.Smart)
        {
            dissuadeCoefNegative++;
        }
        if (enemyAgent.havePeopleLove)
        {
            dissuadeCoefNegative++;
        }


        assasinationCoeficient = dissuadeCoefPositive - dissuadeCoefNegative;
        absCoeficient          = (myAgent.retoricStrength + mySpies + dissuadeCoefPositive) - (enemyAgent.retoricStrength + enemySpies + dissuadeCoefNegative);
        if (absCoeficient >= 0)
        {
            enemyAgent.diplomacyStrength -= absCoeficient;
            ReloadUI();
            if (enemyAgent.diplomacyStrength < 0)
            {
                Victory();
                this.gameObject.SetActive(false);
                return(0);//myAgent dissuaded enemy
            }
            Victory();
            this.gameObject.SetActive(false);
            return(2);//my agent dissuaded the enemy for a short time until discover the retoric bullshit
        }
        else
        {
            myAgent.diplomacyStrength += absCoeficient;
            Defeat();
        }
        ReloadUI();
        this.gameObject.SetActive(false);
        return(1);//my agent talked too much but enemy is still my enemy. maybe myagent is captive or maybe not
    }
コード例 #3
0
ファイル: Combats.cs プロジェクト: Juamedrod/Ponienteros
    public int Cheat(ref DiplomacyAgent myAgent, ref DiplomacyAgent enemyAgent, int mySpies, int enemySpies)
    {
        int cheatCoefPositive = 0, cheatCoefNegative = 0;
        int absCoeficient = 0;

        if (myAgent.Smart)
        {
            cheatCoefPositive++;
        }
        if (myAgent.havePeopleLove)
        {
            cheatCoefPositive++;
        }
        if (enemyAgent.Smart)
        {
            cheatCoefNegative++;
        }
        if (enemyAgent.havePeopleLove)
        {
            cheatCoefNegative++;
        }


        assasinationCoeficient = cheatCoefPositive - cheatCoefNegative;
        absCoeficient          = (myAgent.liesStrength + mySpies + cheatCoefPositive) - (enemyAgent.liesStrength + enemySpies + cheatCoefNegative);
        if (absCoeficient >= 0)
        {
            enemyAgent.diplomacyStrength -= absCoeficient;
            ReloadUI();
            if (enemyAgent.diplomacyStrength < 0)
            {
                Victory();
                this.gameObject.SetActive(false);
                return(0);//myAgent cheated enemy and maybe now is our agent or suicide
            }
            Victory();
            this.gameObject.SetActive(false);
            return(2);//enemyagent will attack his comrades if its in range
        }
        else
        {
            myAgent.diplomacyStrength += absCoeficient;
            Defeat();
        }
        ReloadUI();
        this.gameObject.SetActive(false);
        return(1);//my agent talked too much but enemy is still my enemy. maybe myagent is captive or maybe not
    }
コード例 #4
0
 public void GenerateAgents(int numberOfAgents, bool isNotWithSprite)//Generate Random Agent
 {
     agentsPool.Clear();
     for (int i = 0; i < numberOfAgents; i++)
     {
         DiplomacyAgent e = new DiplomacyAgent();
         e.name = RandomNamesGenerator();
         e.diplomacyStrength    = Random.Range(1, 11);
         e.assasinationStrength = Random.Range(1, 11);
         e.retoricStrength      = Random.Range(1, 11);
         e.liesStrength         = Random.Range(1, 11);
         e.numberOfSpies        = Random.Range(1, 11);
         e.bornInPonienteros    = Random.Range(0, 11) <= Random.Range(0, 11);
         e.noble          = Random.Range(0, 11) <= Random.Range(0, 11);
         e.havePeopleLove = Random.Range(0, 11) <= Random.Range(0, 11);
         e.Smart          = Random.Range(0, 11) <= Random.Range(0, 11);
         e.cost          += 5 * (e.diplomacyStrength + e.assasinationStrength + e.liesStrength + e.retoricStrength + e.numberOfSpies);
         agentsPool.Add(e);
     }
 }
コード例 #5
0
    public void ShowFromMouseOver(DiplomacyAgent agent)
    {
        agentStored    = agent;
        agentName.text = agent.name;
        afixes.text    = "";

        foreach (GameObject g in diplomacyStrengthImg)
        {
            g.SetActive(false);
        }

        foreach (GameObject g in assasinationImg)
        {
            g.SetActive(false);
        }
        foreach (GameObject g in RetoricImg)
        {
            g.SetActive(false);
        }
        foreach (GameObject g in liesImg)
        {
            g.SetActive(false);
        }
        foreach (GameObject g in SpiesImg)
        {
            g.SetActive(false);
        }


        for (int i = 0; i < agent.diplomacyStrength; i++)
        {
            diplomacyStrengthImg[i].SetActive(true);
        }
        for (int i = 0; i < agent.assasinationStrength; i++)
        {
            assasinationImg[i].SetActive(true);
        }
        for (int i = 0; i < agent.retoricStrength; i++)
        {
            RetoricImg[i].SetActive(true);
        }
        for (int i = 0; i < agent.liesStrength; i++)
        {
            liesImg[i].SetActive(true);
        }
        for (int i = 0; i < agent.numberOfSpies; i++)
        {
            SpiesImg[i].SetActive(true);
        }

        if (agent.noble)
        {
            afixes.text += "NOBLE \n";
        }
        if (agent.Smart)
        {
            afixes.text += "SABIO \n";
        }
        if (agent.bornInPonienteros)
        {
            afixes.text += "NACIDO EN PONIENTEROS \n";
        }
        if (agent.havePeopleLove)
        {
            afixes.text += " TIENE EL AMOR DEL PUEBLO";
        }
    }
コード例 #6
0
    public void LoadGame()
    {
        if (File.Exists(Application.persistentDataPath + "/gamesave.save"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/gamesave.save", FileMode.Open);
            Save            save = (Save)bf.Deserialize(file);
            file.Close();
            //faction settings
            faction.adultsToChildren    = save.adultsToChildren;
            faction.childrenToAdults    = save.childrenToAdults;
            faction.factionID           = save.factionID;
            faction.factionName         = save.factionName;
            faction.leader              = save.leader;
            faction.children            = save.children;
            faction.populationHappiness = save.populationHappiness;
            faction.food          = save.food;
            faction.goldScorpions = save.goldScorpions;
            faction.population    = save.population;
            topUI.UpdateTopUi();
            //factionArmy
            factionArmy.swordmen              = save.swordmen;
            factionArmy.spearmen              = save.spearmen;
            factionArmy.horsemen              = save.horsemen;
            factionArmy.archersShortBow       = save.archersShortBow;
            factionArmy.archerLongBow         = save.archerLongBow;
            factionArmy.knightOnFoot          = save.knightOnFoot;
            factionArmy.knightOnStallionSword = save.knightOnStallionSword;
            factionArmy.knightOnStallionSpear = save.knightOnStallionSpear;
            factionArmy.monsters              = save.monsters;
            factionArmy.totalArmy             = save.totalArmy;
            //faction Structure
            factionStructures.BarrackCentinel = save.BarrackCentinel;
            factionStructures.StableCentinel  = save.StableCentinel;
            factionStructures.ArmoryCentinel  = save.ArmoryCentinel;
            factionStructures.AltarCentinel   = save.AltarCentinel;
            factionStructures.pitCentinel     = save.pitCentinel;
            factionStructures.FoundryCentinel = save.FoundryCentinel;
            for (int i = 0; i < factionStructures.initializeStructuresBools.Length; i++)
            {
                factionStructures.initializeStructuresBools[i].constructed = save.construtedStructuresList[i];
            }

            //faction diplomacy

            foreach (DiplomacyAgentWrapper d in save.agentsRecruited)
            {
                DiplomacyAgent wrapper = new DiplomacyAgent();
                wrapper.name = d.name;
                wrapper.cost = d.cost;
                wrapper.diplomacyStrength    = d.diplomacyStrength;
                wrapper.assasinationStrength = d.assasinationStrength;
                wrapper.retoricStrength      = d.retoricStrength;
                wrapper.liesStrength         = d.liesStrength;
                wrapper.numberOfSpies        = d.numberOfSpies;
                wrapper.bornInPonienteros    = d.bornInPonienteros;
                wrapper.noble          = d.noble;
                wrapper.havePeopleLove = d.havePeopleLove;
                wrapper.Smart          = d.Smart;
                wrapper.avatar         = generateRandomAgent.spritesPool[Random.Range(0, generateRandomAgent.spritesPool.Length)];

                bool dead = false; //Here we evaluate if the agent is dead in combat somehow( if he is stored in the agentsDead.
                foreach (DiplomacyAgent agentDead in GameManager.gameManager.agentsDeadInCombat)
                {
                    if (agentDead.name == wrapper.name)
                    {
                        dead = true;
                        break;
                    }
                }
                if (!dead)
                {
                    factionDiplomacy.NewAgent(wrapper);
                }
            }

            GameManager.gameManager.agentsDeadInCombat.Clear();
            displayAgentsRecruited.DisplayAgentsRecruitedUI();

            //TimeManager
            TimeManager.timeManager.timeIncrement = save.timeIncrement;
            // TimeManager.timeManager.deltaIncrement= save.deltaIncrement;
            TimeManager.timeManager.year      = save.year;
            TimeManager.timeManager.centinela = save.centinel;
        }
        else
        {
            Debug.Log("No game saved!");
        }
    }
コード例 #7
0
 public void NewAgent(DiplomacyAgent agentRecruited)
 {
     agentsRecruited.Add(agentRecruited);
     DisplayAgentsRecruited.DisplayAgentsRecruitedUI();
 }