Пример #1
0
 public Direction Directionto(Unit u)     // this changes the directions of the unit
 {
     if (u.GetType() == typeof(Emperor))
     {
         Emperor emperor = (Emperor)u;
         if (emperor.Xpos < Xpos)
         {
             return(Direction.Nort);
         }
         else if (emperor.Xpos > Xpos)
         {
             return(Direction.South);
         }
         else if (emperor.Ypos < Ypos)
         {
             return(Direction.West);
         }
         else
         {
             return(Direction.East);
         }
     }
     else
     {
         return(Direction.Nort);
     }
 }
Пример #2
0
 private int DistanceTo(Unit u)     //this
 {
     if (u.GetType() == typeof(Emperor))
     {
         Emperor emperor = (Emperor)u;
         int     d       = Math.Abs(Xpos - emperor.Xpos) + Math.Abs(Ypos - emperor.Ypos);
         return(d);
     }
     else
     {
         return(0);
     }
 }
Пример #3
0
    /// <summary>
    /// Creates new civilization leaders and adds them to the dictionary tracking it.
    /// </summary>
    private void InitializeCivLeaders()
    {
        allegianceToLeaderMapping = new Dictionary <Allegiance, Emperor>();
        emperors = new List <Emperor>();

        Emperor roman  = new Emperor("Cesar", Allegiance.ROMAN);
        Emperor gallic = new Emperor("Vercingetorix", Allegiance.GALLIC);

        allegianceToLeaderMapping.Add(Allegiance.ROMAN, roman);
        allegianceToLeaderMapping.Add(Allegiance.GALLIC, gallic);
        allegianceToLeaderMapping.Add(Allegiance.INDEPENDENT, null);
        allegianceToLeaderMapping.Add(Allegiance.NONE, null);

        emperors.Add(roman);
        emperors.Add(gallic);
    }
Пример #4
0
        private GMData(string dynastyName, string yearName, string emperorName)
        {
            this.dynastyName = dynastyName;
            this.yearName    = yearName;

            emperor = new Emperor(emperorName, Probability.GetRandomNum(18, 35), Probability.GetRandomNum(6, 10));

            date      = new Date();
            stability = new Stability();
            economy   = new Economy();
            military  = new Military();

            countryFlag = new CountryFlag();
            provinces   = new Provinces();
            //offices = new Offices();

            decisions = new Decisions();

            persons = new Persons();

            Relationship = new Relationship();

            countryTax = new CountryTax();

            //decisions.Add(new Decision(){_name = "TEST"});

            foreach (var elem in StreamManager.CSVManager.Province)
            {
                provinces.Add(new Province((IDictionary <string, object>)elem));
            }
            //foreach (var elem in StreamManager.CSVManager.Office)
            //{
            //    offices.Add(new Office((IDictionary<string, object>)elem));
            //}

            persons.GenerateData(HuangDAPI.Office.All.Count());

            Relationship.Init(this);

            Debug.Log("GMData New");
        }
    // Start is called before the first frame update
    void Start()
    {
        List <string> deck = Emperor.GenerateStdDeck();

        emperor   = FindObjectOfType <Emperor>();
        userInput = FindObjectOfType <UserInput>();

        int i = 0;

        foreach (string card in deck)
        {
            if (this.name == card)
            {
                cardFace = emperor.cardFaces[i];
                break;
            }
            i++;
        }
        spriteRenderer = GetComponent <SpriteRenderer>();
        selectable     = GetComponent <Selectable>();
    }
Пример #6
0
 public EmperorBrain(Emperor leader)
 {
     this.emperor = leader;
 }
Пример #7
0
        static void Main(string[] args)
        {
            // PARAMETER
            var parameter = Expression.Parameter(typeof(Emperor));

            // INITIAL EMPTY PREDICATE
            Expression currentPredicate = null;

            var choiceNumber = 0;

            while (choiceNumber != 5)
            {
                choiceNumber = UI.Main.AskForChoiceNumber();

                switch (choiceNumber)
                {
                case 1:     // Name
                    var nameOfEmperor = UI.Main.AskForNameOfEmperor();

                    var name_member = Expression.Property(parameter, "Name");
                    var constant    = Expression.Constant(nameOfEmperor);

                    var name_expression = Expression.Equal(name_member, constant);

                    UI.Main.PrintNewExpression(name_expression);

                    currentPredicate = appendPredicate(currentPredicate, name_expression, LogicalConjunction.And);
                    break;

                case 2:     // Start of reign (SOR)
                    var SOR_span = UI.Main.AskForTimeSpan();

                    var SOR_member = Expression.Property(parameter, "StartOfReign");

                    var SOR_expression = clampExpression(SOR_span.Item1, SOR_span.Item2, SOR_member);

                    UI.Main.PrintNewExpression(SOR_expression);

                    currentPredicate = appendPredicate(currentPredicate, SOR_expression, LogicalConjunction.And);
                    break;

                case 3:     // End of reign (EOR)
                    var EOR_span   = UI.Main.AskForTimeSpan();
                    var EOR_member = Expression.Property(parameter, "EndOfReign");

                    var EOR_expression = clampExpression(EOR_span.Item1, EOR_span.Item2, EOR_member);

                    UI.Main.PrintNewExpression(EOR_expression);

                    currentPredicate = appendPredicate(currentPredicate, EOR_expression, LogicalConjunction.And);
                    break;

                case 4:     // Dynasty
                    var dynasty = UI.Main.AskForDynasty();

                    var dynasty_member     = Expression.Property(parameter, "Dynasty");
                    var dynasty_constant   = Expression.Constant(dynasty);
                    var dynasty_expression = Expression.Equal(dynasty_member, dynasty_constant);

                    UI.Main.PrintNewExpression(dynasty_expression);

                    currentPredicate = appendPredicate(currentPredicate, dynasty_expression, LogicalConjunction.And);
                    break;

                case 5:     // Run query
                    var lambda         = Expression.Lambda <Func <Emperor, bool> >(currentPredicate, parameter);
                    var finalPredicate = lambda.Compile();

                    var emperors = Emperor.GetEmperorsList();

                    var results = emperors.Where(finalPredicate);
                    UI.Main.PrintResults(results);
                    break;

                default:
                    UI.Main.PrintInvalidInputNotification();
                    break;
                }

                if (choiceNumber != 5)
                {
                    UI.Main.PrintCurrentPredicate(currentPredicate);
                }
            }
        }
Пример #8
0
 // Start is called before the first frame update
 void Start()
 {
     emperor      = FindObjectOfType <Emperor>();
     selectedCard = this.gameObject;
 }
Пример #9
0
    public void Display()
    {
        foreach (Unit u in map.Unit)
        {
            if (u.GetType() == typeof(MeleeUnit))
            {
                MeleeUnit m = (MeleeUnit)u;



                if (m.symbol == "=")
                {
                    if (m.Fact == 1)
                    {
                        GameObject clone = Instantiate(BlueKnight, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    else
                    {
                        GameObject clone = Instantiate(RedKnight, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    if (m.isDead())
                    {
                    }
                }
                else
                {
                    if (m.Fact == 1)
                    {
                        GameObject clone = Instantiate(BlueLance, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    else
                    {
                        GameObject clone = Instantiate(RedLance, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    if (m.isDead())
                    {
                    }
                }
            }
        }
        foreach (Unit u in map.Unit)
        {
            if (u.GetType() == typeof(RangedUnits))
            {
                RangedUnits m = (RangedUnits)u;



                if (m.symbol == "}")
                {
                    if (m.Fact == 1)
                    {
                        GameObject clone = Instantiate(BlueArcher, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    else
                    {
                        GameObject clone = Instantiate(RedArcher, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    if (m.isDead())
                    {
                    }
                }
                else
                {
                    if (m.Fact == 1)
                    {
                        GameObject clone = Instantiate(BlueMusk, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    else
                    {
                        GameObject clone = Instantiate(RedMusk, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        clone.transform.parent = transform;
                    }
                    if (m.isDead())
                    {
                    }
                }
            }
        }


        foreach (Unit u in map.Unit)
        {
            if (u.GetType() == typeof(Emperor))
            {
                Emperor emperor = (Emperor)u;



                if (emperor.Fact == 1)
                {
                    GameObject clone = Instantiate(BLueEmp, new Vector2(emperor.Xpos, emperor.Ypos), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(RedEmp, new Vector2(emperor.Xpos, emperor.Ypos), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (emperor.isDead())
                {
                }
            }
        }
        foreach (Building b in map.Building)
        {
            if (b.GetType() == typeof(FactoryBuilding))
            {
                FactoryBuilding m = (FactoryBuilding)b;



                if (m.Fact == 1)
                {
                    GameObject clone = Instantiate(BlueFactory, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(RedFactory, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (m.isDestoryed())
                {
                }
            }
        }
        foreach (ResourceBuilding b in map.RB)
        {
            if (b.GetType() == typeof(ResourceBuilding))
            {
                ResourceBuilding m = (ResourceBuilding)b;



                if (m.Fact == 1)
                {
                    GameObject clone = Instantiate(BlueResource, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(RedResource, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (m.isDestoryed())
                {
                }
            }
        }
    }
Пример #10
0
    private void UpdateMap()
    {
        foreach (Unit u in map.Unit)
        {
            bool inCombat = false;

            if (u.GetType() == typeof(MeleeUnit))
            {
                MeleeUnit m = (MeleeUnit)u;
                if (m.health > 0)
                {
                    foreach (Unit e in map.Unit) // working code
                    {
                        if (u.AttackRange(e))
                        {
                            u.Combat(e);
                            inCombat = true;
                        }
                        if (!inCombat)
                        {
                            Unit c = u.UnitDistance(map.Unit);
                            m.NewMovePos(m.Directionto(c));
                        }
                    }

                    if (m.health < 100)
                    {
                        switch (Random.Range(0, 4))
                        {
                        case 0: ((MeleeUnit)u).NewMovePos(Direction.Nort); break;

                        case 1: ((MeleeUnit)u).NewMovePos(Direction.East); break;

                        case 2: ((MeleeUnit)u).NewMovePos(Direction.South); break;

                        case 3: ((MeleeUnit)u).NewMovePos(Direction.West); break;
                        }
                    }
                }
                else
                {
                    m.isDead();
                    if (m.isDead())
                    {
                    }
                }
            }
        }
        foreach (Unit u in map.Unit)
        {
            bool inCombat = false;

            if (u.GetType() == typeof(RangedUnits))
            {
                RangedUnits ranged = (RangedUnits)u;
                if (ranged.health > 0)
                {
                    foreach (Unit e in map.Unit)     // working code
                    {
                        if (u.AttackRange(e))
                        {
                            u.Combat(e);
                            inCombat = true;
                        }
                        if (!inCombat)
                        {
                            Unit c = u.UnitDistance(map.Unit);
                            ranged.NewMovePos(ranged.Directionto(c));
                        }
                    }

                    if (ranged.health < 25)
                    {
                        switch (Random.Range(0, 4))
                        {
                        case 0: ((RangedUnits)u).NewMovePos(Direction.Nort); break;

                        case 1: ((RangedUnits)u).NewMovePos(Direction.East); break;

                        case 2: ((RangedUnits)u).NewMovePos(Direction.South); break;

                        case 3: ((RangedUnits)u).NewMovePos(Direction.West); break;
                        }
                    }
                }
                else
                {
                    ranged.isDead();
                    if (ranged.isDead())
                    {
                    }
                }
            }
        }
        foreach (Unit u in map.Unit)
        {
            bool inCombat = false;

            if (u.GetType() == typeof(Emperor))
            {
                Emperor m = (Emperor)u;
                if (m.health > 0)
                {
                    foreach (Unit e in map.Unit) // working code
                    {
                        if (u.AttackRange(e))
                        {
                            u.Combat(e);
                            inCombat = true;
                        }
                        if (!inCombat)
                        {
                            Unit c = u.UnitDistance(map.Unit);
                            m.NewMovePos(m.Directionto(c));
                        }
                    }

                    if (m.health < 25)
                    {
                        switch (Random.Range(0, 4))
                        {
                        case 0: ((Emperor)u).NewMovePos(Direction.Nort); break;

                        case 1: ((Emperor)u).NewMovePos(Direction.East); break;

                        case 2: ((Emperor)u).NewMovePos(Direction.South); break;

                        case 3: ((Emperor)u).NewMovePos(Direction.West); break;
                        }
                    }
                }
                else
                {
                    m.isDead();
                    if (m.isDead())
                    {
                    }
                }
            }
        }
    }
Пример #11
0
    public Map(int maxX, int maxY, int numUnits, int numbuilding)
    {
        building = new Building[numbuilding];
        rb       = new ResourceBuilding[numbuilding];
        unit     = new Unit[numUnits];
        for (int i = 0; i < numUnits; i++)
        {
            if (i <= 10)
            {
                MeleeUnit M = new MeleeUnit(r.Next(0, maxX), r.Next(0, maxY), r.Next(60, 100) * 10, r.Next(5, 20), 1, 1, i % 2, "=", "Knight");
                Unit[i] = M;
            }


            if (i > 10 && i < 20)
            {
                RangedUnits R = new RangedUnits(r.Next(0, maxX), r.Next(0, maxY), r.Next(10, 20) * 10, r.Next(5, 20), 1, 1, i % 2, "}", "Archer");
                Unit[i] = R;
            }

            if (i >= 20 && i < 22)
            {
                Emperor E = new Emperor(r.Next(0, maxX), r.Next(0, maxY), r.Next(10, 20) * 10, r.Next(5, 20), 1, 1, i % 2, "#", "Emperor");
                unit[i] = E;
            }
            if (i >= 22 && i < 27)
            {
                RangedUnits E = new RangedUnits(r.Next(0, maxX), r.Next(0, maxY), r.Next(10, 20) * 10, r.Next(5, 20), 1, 1, i % 2, "->", "Muksmen");
                unit[i] = E;
            }
            if (i > 26)
            {
                MeleeUnit Lance = new MeleeUnit(r.Next(0, maxX), r.Next(0, maxY), r.Next(10, 20) * 10, r.Next(5, 20), 1, 1, i % 2, ">", "Lance");
                unit[i] = Lance;
            }
        }
        for (int i = 0; i < numbuilding; i++)
        {
            if (i <= 5)
            {
                FactoryBuilding fb = new FactoryBuilding(r.Next(-14, 20), r.Next(-22, maxY), r.Next(5, 20), 1, "F", r.Next(0, 1), r.Next(5, 10), buildingx);
                building[i] = fb;
            }


            if (i > 5)
            {
                FactoryBuilding fbr = new FactoryBuilding(r.Next(50, maxX), r.Next(-22, maxY), r.Next(5, 20), 0, "F", r.Next(0, 1), r.Next(5, 10), buildingx);
                building[i] = fbr;
            }
        }
        for (int i = 0; i < numbuilding; i++)
        {
            if (i <= 5)
            {
                ResourceBuilding fb = new ResourceBuilding(r.Next(-14, 20), r.Next(-22, maxY), r.Next(5, 20), 1, "RB", r.Next(0, 1), r.Next(5, 10), 400);
                rb[i] = fb;
            }


            if (i > 5)
            {
                ResourceBuilding fbr = new ResourceBuilding(r.Next(50, 80), r.Next(-22, maxY), r.Next(5, 20), 0, "RB", r.Next(0, 1), r.Next(5, 10), 400);
                rb[i] = fbr;
            }
        }
    }