Exemple #1
0
    private void Start()
    {
        /// Setting up the level
        var main = GameObject.Find("Main");

        this.ms = main.GetComponent <TargetManagerBehaviour>();
        var rb = main.GetComponent <ReferenceBuffer>();

        this.gl     = new GenerateLevel(this.ms, rb);
        this.player = this.gl.Player(new Vector3(20, 0, 10), true, true, true);

        GameObject floor = GameObject.CreatePrimitive(PrimitiveType.Plane);

        floor.transform.position   = new Vector3(0, 0, 0);
        floor.transform.localScale = new Vector3(50, 50, 50);
        floor.GetComponent <Renderer>().material.color = Color.green;
        this.mainCamera = GameObject.Find("MainCamera");
        CamHandling camHandling = this.mainCamera.GetComponent <CamHandling>();

        camHandling.target = this.player.transform;
        ///---------------------------------------------------------------------------

        this.positions    = new Fix64Vector2[2][];
        this.positions[0] = new Fix64Vector2[10];
        this.positions[1] = new Fix64Vector2[10];

        unitViss = new List <GameObject>();
        projViss = new List <GameObject>();

        for (int i = 0; i < 10; i++)
        {
            Vector3 pos = new Vector3(i * 2, 1, -10);
            this.positions[0][i] = pos.ToFixed2d();
            GameObject vis = GameObject.CreatePrimitive(PrimitiveType.Cube);
            vis.GetComponent <Renderer>().material.color = Color.red;
            vis.transform.position = pos;
            Destroy(vis.GetComponent <Collider>());
            unitViss.Add(vis);
        }

        for (int i = 0; i < 10; i++)
        {
            Vector3 pos = new Vector3(i * 2, 1, 10);
            this.positions[1][i] = pos.ToFixed2d();
            GameObject vis = GameObject.CreatePrimitive(PrimitiveType.Cube);
            vis.GetComponent <Renderer>().material.color = Color.blue;
            vis.transform.position = pos;
            Destroy(vis.GetComponent <Collider>());
            unitViss.Add(vis);
        }

        /// Setting up the Controll Sphere
        GameObject controlSphereRed  = gl.GenerateTestEntity("team red", "Red Sphere", TargetType.BattleMoveSameDom, new Vector3(10, 4, -10));
        GameObject controlSphereBlue = gl.GenerateTestEntity("team blue", "Blue Sphere", TargetType.BattleMoveSameDom, new Vector3(10, 4, 10));

        this.redTB  = controlSphereRed.GetComponent <TargetBehaviour>();
        this.blueTB = controlSphereBlue.GetComponent <TargetBehaviour>();

        this.redTB.AIAttachedEvent  += () => Attached("red");
        this.blueTB.AIAttachedEvent += () => Attached("blue");
        ///------------------------------------------------------------------------

        /// Starting the simulation
        this.battleSimulations = new GroupBattleSimulation();
        this.battleSimulations.Start(
            new TeamBundle[] { new TeamBundle(this.RedTeamName, new AI1()), new TeamBundle(this.BlueTeamName, new AI1()) },
            this.positions,
            new string[][] { new string[] { "fireball" }, new string[] { "fireball" } });
        this.StartSimulation();
        ///-------------------------------------------------------------------------
    }