Example #1
0
        public void Execute(Scenario scenario)
        {
            switch (Action)
            {
                case "loadMap":
                    GameManager.TheGameManager.LoadMap(Parameters["map"]);
                    break;

                case "playConversation":
                    GameManager.TheGameManager.PlayConversation(Parameters["conversation"]);
                    break;

                // FIXME - Need error checking here.
                case "spawnUnit":
                    int unit_number = 0;
                    Vector2 tileCoord = Vector2.Zero;
                    string unit_id = "";

                    int unitsToSpawn = Parameters.ContainsKey("unitsToSpawn") ? int.Parse( Parameters["unitsToSpawn"], CultureInfo.InvariantCulture ) : 1;

                    while (unit_number < unitsToSpawn)
                    {
                        unit_id = Parameters["unit" + ',' + unit_number];

                        int x = int.Parse(Parameters["position" + ',' + unit_number].Split(',')[0], CultureInfo.InvariantCulture);
                        int y = int.Parse(Parameters["position" + ',' + unit_number].Split(',')[1], CultureInfo.InvariantCulture);

                        tileCoord = new Vector2(x, y);

                        Unit newUnit = GameManager.TheGameManager.SpawnNewUnit(unit_id, tileCoord);

                        if ( Parameters.ContainsKey("tag" + ',' + unit_number) )
                            newUnit.Tag = Parameters["tag" + ',' + unit_number];

                        unit_number++;
                    }
                    break;

                case "controlUnit":
                    Unit unit = GameManager.TheGameManager.GetUnitByTag(Parameters["unitByTag"]);
                    GameManager.TheGameManager.ControlUnit(unit);
                    break;

                case "loadScenario":
                    GameManager.TheGameManager.LoadScenario(Parameters["scenario"]);
                    break;
            }

            if (Parameters.ContainsKey("doEvent"))
            {
                scenario.Events[Parameters["doEvent"]].Execute(scenario);
            }
        }
Example #2
0
 public void NotifyScenario(Scenario.Event scenarioEvent, string tag)
 {
     if (scenario != null) {
         scenario.Notify(scenarioEvent, tag);
     }
 }
        public bool LoadScenario(Scenario scenario)
        {
            Reset();
            Scenario = scenario;
            Scenario.Start();

            return true;
        }
Example #4
0
        public void LoadScenario(string scenario_id)
        {
            //Cleanup first.
            unitList.Clear();
            abilityList.Clear();

            Scenario scenario = Scenario.LoadScenario(scenario_id);
            scenario.StartScenario();
            this.scenario = scenario;
        }