예제 #1
0
    void GenerateBatlleForTheSun()
    {
        center   = Vector3.zero;
        distance = config.battleSize.value;
        float halfDistance = distance / 2;

        Vector3 team1Pos = center + Vector3.forward * halfDistance;
        Vector3 team2Pos = center - Vector3.forward * halfDistance;

        float teamOffset = 250;

        GenerateShips(team1Pos + Vector3.forward * (halfDistance + teamOffset), team2Pos - Vector3.forward * (halfDistance + teamOffset));

        sunSystem = SunSystem.Random(new LineBounds(distance * .33f, distance * .33f), new LineBounds <int>(1, 13));

        GenerateEnvironment(center, sunSystem);

        var station1 = new StationInitializerModel(teams[0]).Init(team1Pos - new Vector3(0, 0, 100), Quaternion.LookRotation(Vector3.forward, Vector3.up));
        var station2 = new StationInitializerModel(teams[1]).Init(team2Pos + new Vector3(0, 0, 100), Quaternion.LookRotation(Vector3.forward * -1, Vector3.up));

        {
            var o = station1.AddMyComponent <Obstacle>();
            o.radius = 250;
            navigation.AddObstacle(o);

            o        = station2.AddMyComponent <Obstacle>();
            o.radius = 250;
            navigation.AddObstacle(o);
        }

        station1.AddMyComponent <SatelliteBehaviour>().SetSun(sun.transform, Vector3.Distance(team1Pos, sun.transform.position), station1.transform.up);
        station2.AddMyComponent <SatelliteBehaviour>().SetSun(sun.transform, Vector3.Distance(team2Pos, sun.transform.position), station1.transform.up);

        ships.Add(station1);
        ships.Add(station2);

        teams[0].AddGoal(new DestroyObjectGoal(station2));
        teams[1].AddGoal(new DestroyObjectGoal(station1));
        foreach (var t in teams)
        {
            t.GetType().GetMethod("Lock", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(t, new object[] { 0, (int)Random.value * int.MaxValue });
        }

        _updaters.Add(new RespawnBehaviour(teams,
                                           new Transform[] { station1.transform, station2.transform },
                                           new float[] { distance + teamOffset, distance + teamOffset },
                                           25));
    }
예제 #2
0
    void GenerateEscort()
    {
        center   = Vector3.zero;
        distance = config.battleSize.value;

        Vector3 team1Pos = center + Vector3.forward * (distance / 2);
        Vector3 team2Pos = center - Vector3.forward * (distance / 2);

        GenerateShips(team1Pos, team1Pos);

        sunSystem = SunSystem.Random(new LineBounds(distance * .33f, distance * .33f), new LineBounds <int>(1, 13));

        Vector3 sunSystemPos = RandomVector3() * (distance + sunSystem.sun.radius);

        GenerateEnvironment(sunSystemPos, sunSystem);
        //Station
        Vector3 stationPos = sunSystemPos + RandomVector3() * (sunSystem.sun.radius * 2);
        var     station1   = new StationInitializerModel(teams[0]).Init(stationPos, Quaternion.LookRotation(Vector3.forward, Vector3.up));

        station1.AddMyComponent <SatelliteBehaviour>().SetSun(sun.transform, Vector3.Distance(stationPos, sun.transform.position), station1.transform.up);

        ships.Add(station1);

        //Big ship
        var bigShip = new StationInitializerModel(teams[0]).Init(team1Pos, Quaternion.LookRotation(Vector3.forward, Vector3.up));

        Elf.With(bigShip.AddMyComponent <Obstacle>(),
                 o => o.radius = 250,
                 o => navigation.AddObstacle(o)
                 );

        ships.Add(bigShip);

        teams[0].AddGoal(new EscortObjectGoal(bigShip, station1, 200));
        teams[1].AddGoal(new DestroyObjectGoal(bigShip));
        foreach (var t in teams)
        {
            t.GetType().GetMethod("Lock", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(t, new object[] { 0, (int)Random.value * int.MaxValue });
        }
    }
예제 #3
0
    void GenerateDeathMatch()
    {
        center   = Vector3.zero;
        distance = config.battleSize.value;

        Vector3 team1Pos = center + Vector3.forward * (distance / 2);
        Vector3 team2Pos = center - Vector3.forward * (distance / 2);

        GenerateShips(team1Pos, team2Pos);
        teams[0].AddGoal(new KillNEnemiesGoal(config.shipsAmount * config.battleDurationMultipier, teams[1]));
        teams[1].AddGoal(new KillNEnemiesGoal(config.shipsAmount * config.battleDurationMultipier, teams[0]));

        foreach (var t in teams)
        {
            t.GetType().GetMethod("Lock", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(t, new object[] { 0, (int)Random.value * int.MaxValue });
        }

        sunSystem = SunSystem.Random(new LineBounds(500, 20000), new LineBounds <int>(1, 13));

        GenerateEnvironment(RandomVector3() * (distance + sunSystem.sun.radius), sunSystem);


        Transform emptyObject = Resources.Load <Transform>("EmptyObject");

        var team1RespawnPoint = new GameObject("Team1RespawnPoint");

        team1RespawnPoint.transform.position = team1Pos;
        var team2RespawnPoint = new GameObject("Team2RespawnPoint");

        team2RespawnPoint.transform.position = team2Pos;

        _updaters.Add(
            new RespawnBehaviour(teams, new Transform[] {
            team1RespawnPoint.transform,
            team2RespawnPoint.transform
        },
                                 new float[] { distance, distance },
                                 25));
    }