Example #1
0
        public override void UpdateInteract(Apoc3D.GameTime time)
        {
            base.UpdateInteract(time);

            if (MouseInput.IsMouseUpLeft)
            {
                Player player = gameLogic.LocalHumanPlayer;

                PlayerArea area = player.Area;
                for (int i = 0; i < area.CityCount; i++)
                {
                    if (area.GetCity(i).IsHomeCity)
                    {
                        scene.Camera.Longitude = MathEx.Degree2Radian(area.GetCity(i).Longitude);
                        scene.Camera.Latitude  = MathEx.Degree2Radian(area.GetCity(i).Latitude);

                        return;
                    }
                }
            }
        }
Example #2
0
        void Attack()
        {
            float maxAttack = 0;

            City bestAttackCity = null;

            //City bestAttackCityParent = null;


            for (int i = 0; i < area.CityCount; i++)
            {
                City cc = area.GetCity(i);

                for (int j = 0; j < cc.LinkableCityCount; j++)
                {
                    City cc2 = cc.GetLinkableCity(j);
                    if (cc2.Owner != player)
                    {
                        float m = helper.GetCityMark(cc2, 2.5f, 1, -0.005f) + cc.NearbyOwnedBallCount * 0.5f;
                        if (m > maxAttack)
                        {
                            maxAttack      = m;
                            bestAttackCity = cc2;
                            //bestAttackCityParent = cc;
                        }
                    }
                }
            }

            if (bestAttackCity != null)// && bestAttackCityParent.CanHandleCommand()
            {
                FastList <City> sources           = new FastList <City>();
                int             targetAttackCount = bestAttackCity.GetOwnedAttackBallCount();

                int accumBallCount = 0;
                int tries          = 0;
                for (int i = Randomizer.GetRandomInt(area.CityCount);
                     tries < area.CityCount && accumBallCount <= targetAttackCount;
                     i = Randomizer.GetRandomInt(area.CityCount))
                {
                    City cc = area.GetCity(i);

                    int toAdd = cc.NearbyOwnedBallCount;

                    if (toAdd >= AIAttackMiniumBallCount && cc.HasPathTo(bestAttackCity))
                    {
                        accumBallCount += toAdd;
                        sources.Add(cc);
                    }
                    tries++;
                }


                int abc = accumBallCount;
                if (abc >= bestAttackCity.GetOwnedAttackBallCount())
                {
                    for (int i = 0; i < sources.Count; i++)
                    {
                        sources[i].Throw(bestAttackCity);
                    }

                    //bestAttackCityParent.Throw(bestAttackCity);
                }
            }
        }