Beispiel #1
0
        public void rightClickOnHex()
        {
            Hex clickedHex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;

            if (clickedHex.location != null)
            {
                if (GraphicalMap.selectedSelectable != null &&
                    GraphicalMap.selectedSelectable is Unit &&
                    ((Unit)GraphicalMap.selectedSelectable).isEnthralled() &&
                    (!((Unit)GraphicalMap.selectedSelectable).automated))
                {
                    Unit u = (Unit)GraphicalMap.selectedSelectable;
                    if (u.location == clickedHex.location)
                    {
                        if (u.task is Task_GoToLocation)
                        {
                            u.task = null;//Cancel the move-to command
                        }
                    }
                    else if (u.location.getNeighbours().Contains(clickedHex.location))
                    {
                        if (u.movesTaken == 0)
                        {
                            u.location.map.adjacentMoveTo(u, clickedHex.location);
                            u.movesTaken += 1;
                            u.location.map.world.audioStore.playClickSelect();
                            u.task = null;

                            EventManager.onEnthralledUnitMove(u.location.map, u);
                        }
                    }
                    else
                    {
                        u.task = new Task_GoToLocation(clickedHex.location);
                        if (u.movesTaken == 0)
                        {
                            u.task.turnTick(u);
                            u.location.map.world.audioStore.playClickSelect();
                            EventManager.onEnthralledUnitMove(u.location.map, u);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void rightClickOnHex()
        {
            Hex clickedHex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;

            if (clickedHex.location != null)
            {
                if (GraphicalMap.selectedSelectable != null && GraphicalMap.selectedSelectable is Unit && ((Unit)GraphicalMap.selectedSelectable).isEnthralled())
                {
                    Unit u = (Unit)GraphicalMap.selectedSelectable;
                    if (u.location.getNeighbours().Contains(clickedHex.location))
                    {
                        if (u.movesTaken == 0)
                        {
                            u.location.map.adjacentMoveTo(u, clickedHex.location);
                            u.movesTaken += 1;
                            u.location.map.world.audioStore.playClickSelect();
                            u.task = null;
                        }
                    }
                }
            }
        }
        public void clickOnHex()
        {
            Hex clickedHex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;



            if (Input.GetKey(KeyCode.LeftControl))
            {
                GraphicalMap.selectedProperty = null;
                GraphicalMap.selectedHex      = clickedHex;
                return;
            }


            bool deselectedProperty = false;
            bool selectedAProperty  = false;

            if (GraphicalMap.selectedProperty != null)
            {
                //If we've clicked on his hex we want to cycle to the next unit in the cycle
                if (GraphicalMap.selectedProperty.location.hex == clickedHex)
                {
                    int  index    = GraphicalMap.selectedProperty.location.properties.IndexOf(GraphicalMap.selectedProperty);
                    bool foundAny = false;
                    for (int i = index + 1; i < clickedHex.location.properties.Count; i++)
                    {
                        foundAny = true;
                        GraphicalMap.selectedProperty = clickedHex.location.properties[i];
                        //world.ui.uiUnit.setTo(GraphicalMap.selectedProperty);
                        GraphicalMap.selectedHex = null;
                        selectedAProperty        = true;
                        break;
                    }

                    //Found no further units, want to select hex instead
                    if (!foundAny)
                    {
                        deselectedProperty            = true;
                        GraphicalMap.selectedProperty = null;
                    }
                }
                else
                {
                    GraphicalMap.selectedProperty = null;
                }
            }

            if (GraphicalMap.selectedProperty == null && !deselectedProperty)
            {
                //See if there's someone to select
                if (clickedHex.location != null)
                {
                    foreach (Property u in clickedHex.location.properties)
                    {
                        GraphicalMap.selectedProperty = u;
                        //world.ui.uiUnit.setTo(GraphicalMap.selectedProperty);
                        GraphicalMap.selectedHex = null;
                        return;
                    }
                }
            }

            if (!selectedAProperty)
            {
                GraphicalMap.selectedHex = clickedHex;
            }

            world.ui.checkData();
        }
Beispiel #4
0
        public void clickOnHex()
        {
            Hex clickedHex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;



            if (Input.GetKey(KeyCode.LeftControl))
            {
                GraphicalMap.selectedSelectable = null;
                GraphicalMap.selectedHex        = clickedHex;
                world.audioStore.playClick();
                return;
            }
            world.ui.checkData();


            if (clickedHex.location != null)
            {
                List <object> selectables = new List <object>();
                foreach (object o in clickedHex.location.units)
                {
                    selectables.Add(o);
                }
                foreach (object o in clickedHex.location.properties)
                {
                    selectables.Add(o);
                }
                int index = -1;
                if (GraphicalMap.selectedSelectable != null)
                {
                    index = selectables.IndexOf(GraphicalMap.selectedSelectable);
                }
                if (index == -1)//Nothing from this loc selected yet
                {
                    index = 0;
                }
                else
                {
                    index += 1;
                }
                //See if we're out of selectables (including if there were none)
                if (index >= selectables.Count)
                {
                    GraphicalMap.selectedSelectable = null;
                    GraphicalMap.selectedHex        = clickedHex;
                    world.audioStore.playClick();
                    world.ui.checkData();
                    return;
                }
                else
                {
                    GraphicalMap.selectedSelectable = selectables[index];
                    GraphicalMap.selectedHex        = clickedHex;
                    world.audioStore.playClick();
                    world.ui.checkData();
                    return;
                }
            }

            GraphicalMap.selectedSelectable = null;
            GraphicalMap.selectedHex        = clickedHex;
            world.audioStore.playClick();
            world.ui.checkData();
        }
Beispiel #5
0
        public string getBodyText()
        {
            if (mask == maskType.LIKING_ME)
            {
                try
                {
                    Hex    hex  = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;
                    Person me   = GraphicalMap.selectedHex.location.settlement.title.heldBy;
                    Person them = hex.location.settlement.title.heldBy;

                    if (me.state == Person.personState.enthralled)
                    {
                        return(me.getFullName() + " is enthralled, so does not have normal likings.");
                    }
                    string words = me.getFullName() + " liking for " + them.getFullName();
                    RelObj rel   = me.getRelation(them);
                    words += "\nAmount: " + ((int)rel.getLiking());

                    double sus = rel.getDislikingFromSuspicion(me);
                    if (sus != 0)
                    {
                        words += "\nFROM SUSPICION: " + sus;
                    }
                    List <RelEvent> sortedEvents = new List <RelEvent>();
                    sortedEvents.AddRange(rel.events);
                    sortedEvents.Sort();
                    int nPrinted = 0;
                    foreach (RelEvent ev in sortedEvents)
                    {
                        words    += "\n  -" + ev.reason + " : " + ((int)ev.amount);
                        nPrinted += 1;
                        if (nPrinted > 6)
                        {
                            break;
                        }
                    }
                    return(words);
                }
                catch (Exception e)
                {
                    return("");
                }
            }
            else if (mask == maskType.LIKING_THEM)
            {
                try
                {
                    Hex    hex  = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;
                    Person them = GraphicalMap.selectedHex.location.settlement.title.heldBy;
                    Person me   = hex.location.settlement.title.heldBy;

                    if (me.state == Person.personState.enthralled)
                    {
                        return(me.getFullName() + " is enthralled, so does not have normal likings.");
                    }

                    string words = me.getFullName() + " liking for " + them.getFullName();
                    RelObj rel   = me.getRelation(them);
                    words += "\nAmount: " + ((int)rel.getLiking());

                    double sus = rel.getDislikingFromSuspicion(me);
                    if (sus != 0)
                    {
                        words += "\nFROM SUSPICION: " + (int)sus;
                    }

                    List <RelEvent> sortedEvents = new List <RelEvent>();
                    sortedEvents.AddRange(rel.events);
                    sortedEvents.Sort();
                    int nPrinted = 0;
                    foreach (RelEvent ev in sortedEvents)
                    {
                        words    += "\n  -" + ev.reason + " : " + ((int)ev.amount);
                        nPrinted += 1;
                        if (nPrinted > 6)
                        {
                            break;
                        }
                    }
                    return(words);
                }
                catch (Exception e)
                {
                    return("");
                }
            }
            return("");
        }
Beispiel #6
0
        public string getBodyText()
        {
            if (mask == maskType.LIKING_ME)
            {
                try
                {
                    Hex    hex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;
                    Person me  = null;
                    if (GraphicalMap.selectedSelectable is Unit)
                    {
                        if (((Unit)GraphicalMap.selectedSelectable).person != null)
                        {
                            me = ((Unit)GraphicalMap.selectedSelectable).person;
                        }
                    }
                    else
                    {
                        me = GraphicalMap.selectedHex.location.settlement.title.heldBy;
                    }
                    Person them = hex.location.settlement.title.heldBy;

                    if (me.state == Person.personState.enthralled)
                    {
                        return(me.getFullName() + " is enthralled, so does not have normal likings.");
                    }
                    string words = me.getFullName() + " liking for " + them.getFullName();
                    RelObj rel   = me.getRelation(them);
                    words += "\nAmount: " + ((int)rel.getLiking());

                    double sus = rel.getDislikingFromSuspicion();
                    if (sus != 0)
                    {
                        words += "\nFROM SUSPICION: " + (int)sus;
                    }

                    List <ReasonMsg> msgs = new List <ReasonMsg>();
                    RelObj.getLikingModifiers(me, them.index, msgs);
                    foreach (ReasonMsg msg in msgs)
                    {
                        words += "\n\n  -" + msg.msg + " " + ((int)msg.value);
                    }

                    List <RelEvent> sortedEvents = new List <RelEvent>();
                    sortedEvents.AddRange(rel.events);
                    sortedEvents.Sort();
                    int nPrinted = 0;
                    foreach (RelEvent ev in sortedEvents)
                    {
                        words    += "\n\n  -" + ev.reason + " : " + ((int)ev.amount);
                        nPrinted += 1;
                        if (nPrinted > 6)
                        {
                            break;
                        }
                    }
                    return(words);
                }
                catch (Exception e)
                {
                    return("");
                }
            }
            else if (mask == maskType.LIKING_THEM)
            {
                try
                {
                    Hex    hex  = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex;
                    Person them = null;
                    if (GraphicalMap.selectedSelectable is Unit)
                    {
                        if (((Unit)GraphicalMap.selectedSelectable).person != null)
                        {
                            them = ((Unit)GraphicalMap.selectedSelectable).person;
                        }
                    }
                    else
                    {
                        them = GraphicalMap.selectedHex.location.settlement.title.heldBy;
                    }
                    Person me = hex.location.settlement.title.heldBy;

                    if (me.state == Person.personState.enthralled)
                    {
                        return(me.getFullName() + " is enthralled, so does not have normal likings.");
                    }

                    string words = me.getFullName() + " liking for " + them.getFullName();
                    RelObj rel   = me.getRelation(them);
                    words += "\nAmount: " + ((int)rel.getLiking());

                    double sus = rel.getDislikingFromSuspicion();
                    if (sus != 0)
                    {
                        words += "\nFROM SUSPICION: " + (int)sus;
                    }

                    List <ReasonMsg> msgs = new List <ReasonMsg>();
                    RelObj.getLikingModifiers(me, them.index, msgs);
                    foreach (ReasonMsg msg in msgs)
                    {
                        words += "\n\n  -" + msg.msg + " " + ((int)msg.value);
                    }

                    List <RelEvent> sortedEvents = new List <RelEvent>();
                    sortedEvents.AddRange(rel.events);
                    sortedEvents.Sort();
                    int nPrinted = 0;
                    foreach (RelEvent ev in sortedEvents)
                    {
                        words    += "\n\n  -" + ev.reason + " : " + ((int)ev.amount);
                        nPrinted += 1;
                        if (nPrinted > 6)
                        {
                            break;
                        }
                    }
                    return(words);
                }
                catch (Exception e)
                {
                    return("");
                }
            }
            else if (mask == maskType.VOTE_EFFECT)
            {
                if (GraphicalMap.selectedHex != null && GraphicalMap.selectedHex.location != null && GraphicalMap.selectedHex.location.person() != null)
                {
                    Person  voter = GraphicalMap.selectedHex.location.person();
                    Society soc   = (Society)voter.society;
                    if (soc.voteSession == null)
                    {
                        return("No voting currently happening in " + voter.getFullName() + "'s society");
                    }
                    VoteOption opt = soc.voteSession.issue.options[0];
                    foreach (VoteOption o2 in soc.voteSession.issue.options)
                    {
                        if (o2.votesFor.Contains(voter))
                        {
                            opt = o2;
                            break;
                        }
                    }
                    return("The change in liking towards " + voter.getFullName() + " if they vote for their currently preferred option (" + opt.info(soc.voteSession.issue) + ").");
                }
            }
            return("");
        }