Example #1
0
 public void FocusOnProvince(Province province, bool select)
 {
     gameObject.transform.position = new Vector3(province.getPosition().x, province.getPosition().y, focusHeight);
     if (select)
     {
         selectProvince(province.getID());
     }
 }
Example #2
0
        internal void createMessage()
        {
            sb.Clear();

            if (attacker.IsHuman && isAttackerWon())
            {
                //.Append(" owned by ").Append(place.Country)
                sb.Append("Our glorious army attacked ").Append(defender).Append("'s army in ").Append(place)
                .Append(" with army of ").Append(attackerArmy).Append(" men.");
                sb.Append(" Modifiers: ").Append(attackerBonus);
                sb.Append("\n\nWhile enemy had ").Append(defenderArmy).Append(" men. Modifiers:  ").Append(defenderBonus);
                sb.Append("\n\nWe won, enemy lost all men and we lost ").Append(attackerLoss).Append(" men");
                sb.Append("\nProvince ").Append(place).Append(" is our now!");
                // sb.Append("\nDate is ").Append(Game.date);
                Message.NewMessage("We won a battle!", sb.ToString(), "Fine", false, place.getPosition());
            }
            else if (defender.IsHuman && isDefenderWon())
            {
                sb.Append("Our glorious army attacked in province ").Append(place).Append(" by evil ").Append(attacker)
                .Append(" with army of ").Append(attackerArmy).Append(" men.");
                sb.Append(" Modifiers: ").Append(attackerBonus);
                sb.Append("\n\nWhile we had ").Append(defenderArmy).Append(" men. Modifiers: ").Append(defenderBonus);
                sb.Append("\n\nWe won, enemy lost all men and we lost ").Append(defenderLoss).Append(" men");
                // sb.Append("\nDate is ").Append(Game.date);
                Message.NewMessage("We won a battle!", sb.ToString(), "Fine", true, place.getPosition());
            }
            else if (attacker.IsHuman && isDefenderWon())
            {
                //.Append(" owned by ").Append(place.Country)
                sb.Append("Our glorious army attacked ").Append(defender).Append("'s army in ").Append(place)
                .Append(" with army of ").Append(attackerArmy).Append(" men");
                sb.Append(" Modifiers: ").Append(attackerBonus);
                sb.Append("\n\nWhile enemy had ").Append(defenderArmy).Append(" men. Modifiers:  ").Append(defenderBonus);
                sb.Append("\n\nWe lost, our invasion army is destroyed, while enemy lost ").Append(defenderLoss).Append(" men");
                // sb.Append("\nDate is ").Append(Game.date);
                Message.NewMessage("We lost a battle!", sb.ToString(), "Fine", false, place.getPosition());
            }
            else if (defender.IsHuman && isAttackerWon())

            {
                sb.Append("Our glorious army attacked in province ").Append(place).Append(" by evil ").Append(attacker)
                .Append(" with army of ").Append(attackerArmy).Append(" men");
                sb.Append(" Modifiers: ").Append(attackerBonus);
                sb.Append("\n\nWhile we had ").Append(defenderArmy).Append(" men. Modifiers:  ").Append(defenderBonus);
                sb.Append("\n\nWe lost, our home army is destroyed, while enemy lost  ").Append(attackerLoss).Append(" men");
                var movement = attacker as Movement;
                if (movement == null)
                {
                    sb.Append("\nProvince ").Append(place).Append(" is not our anymore!");
                }
                else
                {
                    sb.Append("\nWe had to enact ").Append(movement.getGoal());
                }
                // sb.Append("\nDate is ").Append(Game.date);
                Message.NewMessage("We lost a battle!", sb.ToString(), "Not fine really", false, place.getPosition());
            }
        }
Example #3
0
        public void OnMoveArmy(object sender, EventArgs e)
        {
            if (getSize() > 0)
            {
                if (Path != null)
                {
                    if (Path.nodes.Count > 0)
                    {
                        var oldProvince = Province;
                        Province = Path.nodes[0].Province;
                        Path.nodes.RemoveAt(0);
                        oldProvince.RemoveArmy(this);

                        if (!Province.AllStandingArmies().Contains(this))
                        {
                            Province.AddArmy(this);
                        }

                        if (Game.selectedArmies.Contains(this))
                        {
                            ArmiesSelectionWindow.Get.Refresh();// need that ti check if units Ok to merge
                        }
                        if (Path.nodes.Count == 0)
                        {
                            Path = null;
                            //if (owner == Game.Player && !Game.isPlayerSurrended())
                            //    Message.NewMessage(this.FullName + " arrived!", "Commander, " + this.FullName + " arrived to " + Province + " province", "Fine", false, Province.getPosition());
                        }


                        if (owner != Province.Country) // thats attacking
                        {
                            if (Province.Country.isAI())
                            {
                                if (Province.Country == World.UncolonizedLand)
                                {
                                    Province.Country.mobilize(Province.Yield());
                                }
                                else
                                {
                                    Province.Country.mobilize(Province.Country.AllProvinces());
                                    Province.Country.AllArmies().PerformAction(x => x.SetPathTo(Province.Country.Capital));
                                }
                            }
                            var attackerIsCountry = owner as Country;
                            if (attackerIsCountry != null)
                            {
                                Province.Country.changeRelation(attackerIsCountry, -0.5f);
                                if (attackerIsCountry.LastAttackDate.ContainsKey(Province.Country))
                                {
                                    attackerIsCountry.LastAttackDate[Province.Country].set(Date.Today);
                                }
                                else
                                {
                                    attackerIsCountry.LastAttackDate.Add(Province.Country, Date.Today.Copy());
                                }
                            }
                        }


                        foreach (var enemyArmy in Province.AllStandingArmies().Where(x => x.owner != owner && (x.owner is Country || owner is Country)).ToList())
                        {
                            if (enemyArmy.getSize() > 0)
                            {
                                this.attack(enemyArmy).createMessage();
                            }
                        }

                        if (getSize() > 0) // todo change to alive check
                        {
                            var isCountryOwner = owner as Country;
                            if (isCountryOwner != null && isCountryOwner != Province.Country)
                            {
                                if (Province.Country == Game.Player && !Game.isPlayerSurrended())
                                {
                                    Message.NewMessage("Province lost!", "Commander, " + isCountryOwner + " took " + Province, "Fine", false, Province.getPosition());
                                }
                                isCountryOwner.TakeProvince(Province, true);
                            }
                        }
                        Game.provincesToRedrawArmies.Add(oldProvince);
                        Game.provincesToRedrawArmies.Add(Province);
                    }
                }
                if (owner.isAI())
                { // auto merge armies for AI
                    var sameCountryArmies = Province.AllStandingArmies().Where(x => x.owner == owner).ToList();
                    while (sameCountryArmies.Count > 1)
                    {
                        sameCountryArmies[0].JoinIn(sameCountryArmies[1]);
                        sameCountryArmies.Remove(sameCountryArmies[1]);
                    }
                }
            }
        }
Example #4
0
 private void CheckPathOnProvinceOwnerChanged(object sender, Province.OwnerChangedEventArgs e)
 {
     if (e.oldOwner == Province.Country && Path != null && Path.nodes.Any(x => x.Province == sender))//changed owner, probably, on our way
     {
         Path = null;
         Game.provincesToRedrawArmies.Add(Province);
         //Province.RedrawLocalArmies();
         Message.NewMessage(this.FullName + " arrived!", "Commander, " + this.FullName + " stopped at " + Province + " province", "Fine", false, Province.getPosition());
     }
 }