private void HandleLoadMovie()
        {
            var vm = this._datasource;

            this._movie = this._gauntletLayer.LoadMovie("CharacterSelectionScreen", (ViewModel)this._datasource);

            var culturesListPanel   = this._movie.RootView.Target.FindChild("Cultures", true) as ListPanel;
            var groupsListPanel     = this._movie.RootView.Target.FindChild("Groups", true) as ListPanel;
            var charactersListPanel = this._movie.RootView.Target.FindChild("Characters", true) as ListPanel;

            culturesListPanel.IntValue   = vm.SelectedCultureIndex;
            groupsListPanel.IntValue     = vm.SelectedGroupIndex;
            charactersListPanel.IntValue = vm.SelectedCharacterIndex;
            ModuleLogger.Log("vm.SelectedCharacterIndex {0}", vm.SelectedCharacterIndex);

            culturesListPanel.SelectEventHandlers.Add(w => {
                vm.SelectedCultureChanged(w as ListPanel);
                groupsListPanel.IntValue     = vm.SelectedGroupIndex;
                charactersListPanel.IntValue = vm.SelectedCharacterIndex;
            });
            groupsListPanel.SelectEventHandlers.Add(w => {
                vm.SelectedGroupChanged(w as ListPanel);
                charactersListPanel.IntValue = vm.SelectedCharacterIndex;
            });
            charactersListPanel.SelectEventHandlers.Add(w => vm.SelectedCharacterChanged(w as ListPanel));
        }
Beispiel #2
0
 public void SelectedCultureChanged(ListPanel listPanel)
 {
     this._inChange = true;
     try {
         var index = listPanel.IntValue;
         ModuleLogger.Log("SelectedCultureChanged {0}", index);
         var    culture   = Cultures[index].Name;
         string groupName = null;
         Groups.Clear();
         Characters.Clear();
         foreach (var group in this.allCharacters[culture].Keys)
         {
             if (groupName == null)
             {
                 groupName = group;
             }
             Groups.Add(new NameVM {
                 Name = group
             });
         }
         foreach (var character in this.allCharacters[culture][groupName])
         {
             Characters.Add(new CharacterVM(character));
         }
         SelectedCultureIndex   = index;
         SelectedGroupIndex     = 0;
         SelectedCharacterIndex = 0;
     } catch (System.Exception e) {
         ModuleLogger.Log("{0}", e);
         throw;
     }
     this._inChange = false;
 }
 public override void AfterStart()
 {
     try
     {
         this.AfterStart2();
     }
     catch (System.Exception e)
     {
         ModuleLogger.Log("{0}", e);
     }
 }
Beispiel #4
0
        public void SelectedCharacterChanged(ListPanel listPanel)
        {
            var index = listPanel.IntValue;

            if (index < 0 || this._inChange)
            {
                return;
            }
            ModuleLogger.Log("SelectedCharacterChanged {0}", index);
            SelectedCharacterIndex = index;
        }
        private void SelectEnemySoldierCharacter()
        {
            ModuleLogger.Log("SelectPlayerCharacter");
            var p = new CharacterSelectionParams {
                characters    = this._allCharacters,
                selectedIndex = this._allCharacters.IndexOf(this.EnemySoldierCharacter),
                setCharacter  = (c => EnemySoldierCharacter = c),
            };

            TaleWorlds.Engine.Screens.ScreenManager.PushScreen(new CharacterSelectionScreen(p));
        }
Beispiel #6
0
        public CharacterSelectionVM(CharacterSelectionParams p)
            : base()
        {
            ModuleLogger.Log("begin character selection vm construction");
            this._params       = p;
            this.allCharacters = new SortedDictionary <string, SortedDictionary <string, List <CharacterInfo> > >();
            foreach (var c1 in p.characters)
            {
                if (!this.allCharacters.ContainsKey(c1.culture))
                {
                    this.allCharacters.Add(c1.culture, new SortedDictionary <string, List <CharacterInfo> >());
                }
                var cultureDict = this.allCharacters[c1.culture];
                if (!cultureDict.ContainsKey(c1.defaultGroup))
                {
                    cultureDict.Add(c1.defaultGroup, new List <CharacterInfo>());
                }
                cultureDict[c1.defaultGroup].Add(c1);
            }
            var c = p.characters[p.selectedIndex];

            Cultures = new MBBindingList <NameVM>();
            foreach (var culture in this.allCharacters.Keys)
            {
                Cultures.Add(new NameVM {
                    Name = culture
                });
            }
            Groups = new MBBindingList <NameVM>();
            foreach (var group in this.allCharacters[c.culture].Keys)
            {
                Groups.Add(new NameVM {
                    Name = group
                });
            }
            Characters = new MBBindingList <CharacterVM>();
            foreach (var character in this.allCharacters[c.culture][c.defaultGroup])
            {
                Characters.Add(new CharacterVM(character));
            }
            SelectedCultureIndex   = Cultures.FindIndex(n => n.Name == c.culture);
            SelectedGroupIndex     = Groups.FindIndex(n => n.Name == c.defaultGroup);
            SelectedCharacterIndex = Characters.FindIndex(n => n.character == c);
            ModuleLogger.Log("end character selection vm construction");
        }
 void SwitchCamera()
 {
     ModuleLogger.Log("SwitchCamera");
     if (this._playerAgent == null || !this._playerAgent.IsActive())
     {
         this.displayMessage("no player agent");
         return;
     }
     if (this.Mission.MainAgent == null)
     {
         this._playerAgent.Controller = Agent.ControllerType.Player;
         this.displayMessage("switch to player agent");
     }
     else
     {
         this.Mission.MainAgent       = null;
         this._playerAgent.Controller = Agent.ControllerType.AI;
         var wp = this._playerAgent.GetWorldPosition();
         this._playerAgent.SetScriptedPosition(ref wp, Agent.AIScriptedFrameFlags.DoNotRun, "camera switch");
         this.displayMessage("switch to free camera");
     }
 }
Beispiel #8
0
        public void SelectedGroupChanged(ListPanel listPanel)
        {
            var index = listPanel.IntValue;

            if (index < 0 || this._inChange)
            {
                return;
            }
            this._inChange = true;
            ModuleLogger.Log("SelectedGroupChanged {0} {1}", index, Groups.Count);
            var    culture = Cultures[SelectedCultureIndex].Name;
            string group   = Groups[index].Name;

            Characters.Clear();
            foreach (var character in this.allCharacters[culture][group])
            {
                Characters.Add(new CharacterVM(character));
            }
            SelectedGroupIndex     = index;
            SelectedCharacterIndex = 0;
            this._inChange         = false;
        }
        public void AfterStart2()
        {
            this._started = true;
            var scene = this.Mission.Scene;

            if (this.battleTestParams.skyBrightness >= 0)
            {
                scene.SetSkyBrightness(this.battleTestParams.skyBrightness);
            }

            if (this.battleTestParams.rainDensity >= 0)
            {
                scene.SetRainDensity(this.battleTestParams.rainDensity);
            }

            this.Mission.MissionTeamAIType = Mission.MissionTeamAITypeEnum.FieldBattle;
            this.Mission.SetMissionMode(MissionMode.Battle, true);

            var xInterval      = this.battleTestParams.soldierXInterval;
            var yInterval      = this.battleTestParams.soldierYInterval;
            var soldiersPerRow = this.battleTestParams.soldiersPerRow;

            var startPos        = this.battleTestParams.FormationPosition;
            var xDir            = this.battleTestParams.formationDirection;
            var yDir            = this.battleTestParams.formationDirection.LeftVec();
            var agentDefaultDir = new TL.Vec2(0, 1);
            var useFreeCamera   = this.battleTestParams.useFreeCamera;

            BasicCharacterObject soldierCharacter = this._game.ObjectManager.GetObject <BasicCharacterObject>(this.battleTestParams.playerSoldierCharacterId);
            var playerSoldierFormationClass       = soldierCharacter.CurrentFormationClass;
            var playerTeam = this.Mission.Teams.Add(BattleSideEnum.Attacker, 0xff3f51b5);

            playerTeam.AddTeamAI(new TeamAIGeneral(this.Mission, playerTeam));
            playerTeam.AddTacticOption(new TacticCharge(playerTeam));
            // playerTeam.AddTacticOption(new TacticFullScaleAttack(playerTeam));
            playerTeam.ExpireAIQuerySystem();
            playerTeam.ResetTactic();
            this.Mission.PlayerTeam = playerTeam;

            var playerPosVec2 = startPos + xDir * -10 + yDir * -10;
            var playerPos     = new TL.Vec3(playerPosVec2.x, playerPosVec2.y, 30);

            if (!useFreeCamera)
            {
                var playerMat = TL.Mat3.Identity;
                playerMat.RotateAboutUp(agentDefaultDir.AngleBetween(xDir));
                BasicCharacterObject playerCharacter = this._game.ObjectManager.GetObject <BasicCharacterObject>(this.battleTestParams.playerCharacterId);
                AgentBuildData       agentBuildData  = new AgentBuildData(new BasicBattleAgentOrigin(playerCharacter))
                                                       .ClothingColor1(0xff3f51b5)
                                                       .ClothingColor2(0xff3f51b5)
                                                       .Banner(Banner.CreateRandomBanner())
                                                       .IsFemale(false)
                                                       .InitialFrame(new TL.MatrixFrame(playerMat, playerPos));
                Agent player = this.Mission.SpawnAgent(agentBuildData, false, 0);
                player.Controller = Agent.ControllerType.Player;
                player.WieldInitialWeapons();
                player.AllowFirstPersonWideRotation();

                Mission.MainAgent = player;
                player.SetTeam(playerTeam, true);
                playerTeam.GetFormation(playerSoldierFormationClass).PlayerOwner = player;
                playerTeam.PlayerOrderController.Owner = player;
                this._playerAgent = player;
            }
            else
            {
                var c = this.battleTestParams.playerSoldierCount;
                if (c <= 0)
                {
                    this.freeCameraPosition = new TL.Vec3(startPos.x, startPos.y, 30);
                }
                else
                {
                    var rowCount = (c + soldiersPerRow - 1) / soldiersPerRow;
                    var p        = startPos + (System.Math.Min(soldiersPerRow, c) - 1) / 2 * yInterval * yDir - rowCount * xInterval * xDir;
                    this.freeCameraPosition = new TL.Vec3(p.x, p.y, 5);
                }
            }

            var mapHasNavMesh = false;

            {
                var formation = playerTeam.GetFormation(playerSoldierFormationClass);
                var width     = this.getInitialFormationWidth(playerTeam, playerSoldierFormationClass);
                var centerPos = startPos + yDir * (width / 2);
                var wp        = new WorldPosition(scene, centerPos.ToVec3());
                formation.SetPositioning(wp, xDir, null);
                formation.FormOrder = FormOrder.FormOrderCustom(width);
                mapHasNavMesh       = wp.GetNavMesh() != System.UIntPtr.Zero;
            }

            for (var i = 0; i < this.battleTestParams.playerSoldierCount; i += 1)
            {
                var formation = playerTeam.GetFormation(playerSoldierFormationClass);

                AgentBuildData soldierBuildData = new AgentBuildData(new BasicBattleAgentOrigin(soldierCharacter))
                                                  .ClothingColor1(playerTeam.Color)
                                                  .ClothingColor2(playerTeam.Color2)
                                                  .Banner(playerTeam.Banner)
                                                  .IsFemale(false)
                                                  .Team(playerTeam)
                                                  .Formation(formation);

                if (!mapHasNavMesh)
                {
                    var x   = i / soldiersPerRow;
                    var y   = i % soldiersPerRow;
                    var mat = TL.Mat3.Identity;
                    var pos = startPos + xDir * (-xInterval * x) + yDir * yInterval * y;
                    mat.RotateAboutUp(agentDefaultDir.AngleBetween(xDir));
                    var agentFrame = new TaleWorlds.Library.MatrixFrame(mat, new TL.Vec3(pos.x, pos.y, 30));
                    soldierBuildData.InitialFrame(agentFrame);
                }

                var agent = this.Mission.SpawnAgent(soldierBuildData);
                agent.SetWatchState(AgentAIStateFlagComponent.WatchState.Alarmed);
            }

            BasicCharacterObject enemyCharacter = this._game.ObjectManager.GetObject <BasicCharacterObject>(this.battleTestParams.enemySoldierCharacterId);
            var enemyTeam = this.Mission.Teams.Add(BattleSideEnum.Defender, 0xffff6090);

            enemyTeam.AddTeamAI(new TeamAIGeneral(this.Mission, enemyTeam));
            enemyTeam.AddTacticOption(new TacticCharge(enemyTeam));
            // enemyTeam.AddTacticOption(new TacticFullScaleAttack(enemyTeam));
            enemyTeam.SetIsEnemyOf(playerTeam, true);
            playerTeam.SetIsEnemyOf(enemyTeam, true);
            enemyTeam.ExpireAIQuerySystem();
            enemyTeam.ResetTactic();

            var enemyFormationClass = enemyCharacter.CurrentFormationClass;
            var enemyFormation      = enemyTeam.GetFormation(FormationClass.Ranged);

            {
                float width     = this.getInitialFormationWidth(enemyTeam, enemyFormationClass);
                var   centerPos = startPos + yDir * (width / 2) + xDir * this.battleTestParams.distance;
                var   wp        = new WorldPosition(scene, centerPos.ToVec3());
                enemyFormation.SetPositioning(wp, -xDir, null);
                enemyFormation.FormOrder = FormOrder.FormOrderCustom(width);
            }

            for (var i = 0; i < this.battleTestParams.enemySoldierCount; i += 1)
            {
                AgentBuildData enemyBuildData = new AgentBuildData(new BasicBattleAgentOrigin(enemyCharacter))
                                                .ClothingColor1(enemyTeam.Color)
                                                .ClothingColor2(enemyTeam.Color2)
                                                .Banner(enemyTeam.Banner)
                                                .Formation(enemyFormation);

                if (!mapHasNavMesh)
                {
                    var x   = i / soldiersPerRow;
                    var y   = i % soldiersPerRow;
                    var mat = TL.Mat3.Identity;
                    mat.RotateAboutUp(agentDefaultDir.AngleBetween(-xDir));
                    var pos        = startPos + xDir * this.battleTestParams.distance + xDir * xInterval * x + yDir * yInterval * y;
                    var agentFrame = new TaleWorlds.Library.MatrixFrame(TaleWorlds.Library.Mat3.Identity, new TL.Vec3(pos.x, pos.y, 30));
                    enemyBuildData.InitialFrame(agentFrame);
                }
                var agent = this.Mission.SpawnAgent(enemyBuildData);
                agent.SetTeam(enemyTeam, true);
                agent.Formation = enemyFormation;
                agent.SetWatchState(AgentAIStateFlagComponent.WatchState.Alarmed);
            }

            {
                var a = this.Mission.IsOrderShoutingAllowed();
                var b = this.Mission.IsAgentInteractionAllowed();
                var c = GameNetwork.IsClientOrReplay;
                var d = playerTeam.PlayerOrderController.Owner == null;
                ModuleLogger.Log("mission allowed shouting: {0} interaction: {1} {2} {3}", a, b, c, d);
            }
        }