示例#1
0
        public override void DoUpdate(GameTime gameTime)
        {
            int UnitsNotUpdatedCount = Map.ListPlayer[Map.ActivePlayerIndex].ListUnit.Count;

            for (int U = 0; U < Map.ListPlayer[Map.ActivePlayerIndex].ListUnit.Count; U++)
            {
                UnitConquest    ActiveUnit  = Map.ListPlayer[Map.ActivePlayerIndex].ListUnit[U];
                TerrainConquest UnitTerrain = Map.GetTerrain(ActiveUnit.Components);

                if (!ActiveUnit.CanMove)
                {
                    --UnitsNotUpdatedCount;
                    continue;
                }

                //Capture building on self
                if (UnitTerrain.CapturedPlayerIndex != Map.ActivePlayerIndex)
                {
                    AddToPanelListAndSelect(new ActionPanelCapture(Map, ActiveUnit));
                }
                else
                {
                    AddToPanelListAndSelect(new ActionPanelAIAttack(Map, ActiveUnit));
                }
            }

            if (UnitsNotUpdatedCount == 0)
            {
                Map.OnNewPhase();
            }
        }
示例#2
0
        public MapLayer(ConquestMap Map, List <AnimationBackground> ListBackgrounds, List <AnimationBackground> ListForegrounds, BinaryReader BR)
        {
            this.Map = Map;

            ListSubLayer = new List <SubMapLayer>();

            StartupDelay   = BR.ReadInt32();
            ToggleDelayOn  = BR.ReadInt32();
            ToggleDelayOff = BR.ReadInt32();
            Depth          = BR.ReadSingle();

            if (StartupDelay == 0)
            {
                IsVisible   = true;
                ToggleTimer = ToggleDelayOn;
            }
            else
            {
                IsVisible   = false;
                ToggleTimer = StartupDelay;
            }

            ArrayTerrain = new TerrainConquest[Map.MapSize.X, Map.MapSize.Y];
            for (int Y = 0; Y < Map.MapSize.Y; Y++)
            {
                for (int X = 0; X < Map.MapSize.X; X++)
                {
                    ArrayTerrain[X, Y] = new TerrainConquest(BR, X, Y);
                }
            }

            LayerGrid = new ConquestMap2D(Map, ListBackgrounds, ListForegrounds, new FogOfWarGridOverlay(Map), BR);
        }
示例#3
0
        public override void OnSelect()
        {
            Map.FinalizeMovement(ActiveUnit);
            ActiveUnit.UpdateSkillsLifetime(SkillEffect.LifetimeTypeOnAction);
            TerrainConquest ActiveTerrain = Map.GetTerrain(ActiveUnit.Components);

            if (ActiveTerrain.CapturedPlayerIndex != Map.ActivePlayerIndex)
            {
                ActiveTerrain.CapturePoints = Math.Max(0, ActiveTerrain.CapturePoints - ActiveUnit.HP);
                if (ActiveTerrain.CapturePoints == 0)
                {
                    ActiveTerrain.CapturedPlayerIndex = Map.ActivePlayerIndex;
                }
            }

            RemoveAllSubActionPanels();
        }
示例#4
0
        public MapLayer(ConquestMap Map, List <AnimationBackground> ListBackgrounds, List <AnimationBackground> ListForegrounds)
        {
            this.Map = Map;

            ListSubLayer = new List <SubMapLayer>();
            ToggleTimer  = StartupDelay;
            IsVisible    = StartupDelay > 0;

            //Tiles
            ArrayTerrain = new TerrainConquest[Map.MapSize.X, Map.MapSize.Y];
            for (int Y = 0; Y < Map.MapSize.Y; Y++)
            {
                for (int X = 0; X < Map.MapSize.X; X++)
                {
                    ArrayTerrain[X, Y] = new TerrainConquest(X, Y);
                }
            }

            LayerGrid = new ConquestMap2D(Map, ListBackgrounds, ListForegrounds, new FogOfWarGridOverlay(Map));
        }
示例#5
0
        public MapLayer(ConquestMap Map)
        {
            this.Map = Map;

            ListSubLayer = new List <SubMapLayer>();
            ToggleTimer  = StartupDelay;
            IsVisible    = StartupDelay > 0;

            //Tiles
            ArrayTerrain = new TerrainConquest[Map.MapSize.X, Map.MapSize.Y];
            for (int Y = 0; Y < Map.MapSize.Y; Y++)
            {
                for (int X = 0; X < Map.MapSize.X; X++)
                {
                    ArrayTerrain[X, Y] = new TerrainConquest(X, Y);
                }
            }

            LayerGrid = new ConquestMap2D(Map);
        }
        public override void DoUpdate(GameTime gameTime)
        {
            // Can Move, try capturing a building.
            if (ActiveUnit.CanMove)
            {
                List <Vector3> ListMVChoice = Map.GetMVChoice(ActiveUnit);

                //Remove everything that is closer then DistanceMax.
                for (int M = 0; M < ListMVChoice.Count; M++)
                {
                    TerrainConquest ActiveTerrain = Map.GetTerrain((int)ListMVChoice[M].X, (int)ListMVChoice[M].Y, ActiveUnit.Components.LayerIndex);

                    //Check if the Terrain is a building.
                    if (ActiveTerrain.CapturedPlayerIndex != Map.ActivePlayerIndex && ActiveTerrain.TerrainTypeIndex >= 13)
                    {
                        //Movement initialisation.
                        Map.MovementAnimation.Add(ActiveUnit.X, ActiveUnit.Y, ActiveUnit.Components);
                        //Prepare the Cursor to move.
                        Map.CursorPosition.X = ListMVChoice[M].X;
                        Map.CursorPosition.Y = ListMVChoice[M].Y;
                        //Move the Unit to the target position;
                        ActiveUnit.SetPosition(ListMVChoice[M]);

                        Map.FinalizeMovement(ActiveUnit);
                    }
                }
            }
            //If it didn't attacked yet.
            if (ActiveUnit.CanMove)
            {
                TerrainConquest ActiveTerrain = Map.GetTerrain(ActiveUnit.Components);

                // Can't move and on a building not owned by the current Player, try to capture it
                if (!ActiveUnit.CanMove && ActiveTerrain.CapturedPlayerIndex != Map.ActivePlayerIndex && ActiveTerrain.TerrainTypeIndex >= 13)
                {
                    ActiveTerrain.CapturePoints = Math.Max(0, ActiveTerrain.CapturePoints - ActiveUnit.HP);
                    if (ActiveTerrain.CapturePoints == 0)
                    {
                        ActiveTerrain.CapturedPlayerIndex = Map.ActivePlayerIndex;
                    }

                    ActiveUnit.EndTurn();
                }

                if (ActiveUnit.X < Map.CameraPosition.X || ActiveUnit.Y < Map.CameraPosition.Y ||
                    ActiveUnit.X >= Map.CameraPosition.X + Map.ScreenSize.X || ActiveUnit.Y >= Map.CameraPosition.Y + Map.ScreenSize.Y)
                {
                    Map.PushScreen(new CenterOnSquadCutscene(null, Map, ActiveUnit.Position));
                }

                bool AttackSuccess = false;
                //Try to attack.
                AttackSuccess = Map.AIAttackWithWeapon1(ActiveUnit) || Map.AIAttackWithWeapon2(ActiveUnit);

                //All weapon are used, if he had to attack at this point it's already done.
                if (!AttackSuccess)
                {
                    ActiveUnit.EndTurn();
                }

                RemoveFromPanelList(this);
            }

            //If the Unit can't attack at all, move toward the nearest enemy.
            else if (ActiveUnit.CanMove)
            {
                AddToPanelListAndSelect(new ActionPanelAIMoveTowardEnemy(Map, ActiveUnit));
            }
        }