internal ArenaBehavior(World world, List<Team> teams)
        {
            Requires.NotNull(world, nameof(world));
            Requires.NotNull(teams, nameof(teams));

            this.world = world;
            this.teams = teams.ToImmutableArray();
        }
Exemple #2
0
        private static void MakeArenaModule(ScriptEngine engine, List<Team> teams, World world)
        {
            Requires.NotNull(engine, nameof(engine));
            Requires.NotNull(teams, nameof(teams));
            Requires.NotNull(world, nameof(world));

            var module = engine.CreateModule(Constants.ModuleName);

            module.SetVariable(nameof(Gunner), DynamicHelpers.GetPythonTypeFromType(typeof(Gunner)));
            module.SetVariable(nameof(Team), DynamicHelpers.GetPythonTypeFromType(typeof(Team)));
            module.SetVariable(nameof(Movement), DynamicHelpers.GetPythonTypeFromType(typeof(Movement)));
            module.SetVariable(nameof(Rotation), DynamicHelpers.GetPythonTypeFromType(typeof(Rotation)));
            module.SetVariable(nameof(Attack), DynamicHelpers.GetPythonTypeFromType(typeof(Attack)));
            module.SetVariable(nameof(teams), teams);
            module.SetVariable("World", world);
        }
Exemple #3
0
        protected override void CreateScene()
        {
            this.EntityManager.Add(Cameras.FixedCamera);

            List<Team> teams = new List<Team>();
            World world = new World();
            MakeArenaModule(this.engine, teams, world);

            var scope = this.engine.CreateScope();
            var script = this.engine.CreateScriptSourceFromFile(@"C:\BattleTeam\Test.py");

            script.Execute(scope); // Updates teams

            this.AddEnvironmentEntities(teams);

            this.AddSceneBehavior(new ArenaBehavior(world, teams), SceneBehavior.Order.PreUpdate);
        }