Ejemplo n.º 1
0
        public static List <SpaceBody> GenerateGalaxy(Vector3 position, SunSystem sunSystem, Navigation navigation)
        {
            List <SpaceBody> bodies = new List <SpaceBody>();

            GenerateGalaxy(position, sunSystem, navigation, bodies);
            return(bodies);
        }
Ejemplo n.º 2
0
    public static void Inspector( SunSystem s)
    {
        GuiTools.DrawTitleChapter("Sun",12,true,0,Screen.width,Color.white);

        if (GUILayout.Button(new GUIContent(" Add sun",CosmosInspector.GetIcon(13)))){
            AddSun();
            GuiTools.SetSceneCamera( 0,0);
        }

        EditorGUILayout.Space();

        GuiTools.DrawSeparatorLine();

        RenderSettings.ambientLight = EditorGUILayout.ColorField("Ambient",RenderSettings.ambientLight);

        GuiTools.DrawSeparatorLine();

        Sun[] suns = s.GetComponentsInChildren<Sun>();
        int i=0;
        while (i<suns.Length){
            SunProperties(suns[i]);
            i++;
        }

        GuiTools.DrawSeparatorLine();

        // Delete All
        if (GUILayout.Button( new GUIContent( " Clear",CosmosInspector.GetIcon(12)))){
            if (EditorUtility.DisplayDialog( "Delete all suns","Are you sure ?","Delete","Cancel")){
                SunSystem.instance.ClearSuns();
            }

        }
    }
Ejemplo n.º 3
0
    void GenerateEnvironment(Vector3 center, SunSystem sunSystem)
    {
        List <SpaceBody> spaceBodies = new List <SpaceBody>();

        BattleGenerator.GenerateGalaxy(center, sunSystem, navigation, spaceBodies, AP);
        otherObjects.Add(new SunSystemUpdater(spaceBodies));
        sun = spaceBodies.First(b => b is SunBehaviour) as SunBehaviour;
    }
Ejemplo n.º 4
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));
    }
Ejemplo n.º 5
0
        public static void GenerateGalaxy(Vector3 position, SunSystem sunSystem, Navigation navigation, ICollection <SpaceBody> outGeneratedObjects, AsyncProcessor asyncProcessor)
        {
            List <Obstacle> obstacles = new List <Obstacle>();

            var sun = ((SunBehaviour)GameObject.Instantiate(Resources.Load <SunBehaviour>(@"Environment\Sun"), position, Quaternion.identity));

            outGeneratedObjects.Add(sun);

            Color sunColor = new Color(.5f, .5f, .5f) + new Color(Random.value, Random.value, Random.value) * .5f;

            sun.Initialize(sunColor, sunSystem.sun.radius, asyncProcessor);

            sun.AddMyComponent <WorldlGravity>();
            var obstacle = sun.AddMyComponent <Obstacle>();

            obstacle.radius = sunSystem.sun.radius;
            obstacles.Add(obstacle);

            PlanetBehaviour planet = Resources.Load <PlanetBehaviour>(@"Environment\Planet");

            Vector3 axisRight = MyVector.RandomAxis3();
            Vector3 axisUp    = Vector3.Cross(sun.transform.up, axisRight);

            foreach (var pl in sunSystem.planets)
            {
                var p = GameObject.Instantiate(planet, sun.transform.position + axisRight * pl.axisOffset, Quaternion.identity);

                p.transform.RotateAround(sun.transform.position, axisUp, Random.value * 360);

                p.Initialize(sun, axisUp, pl.radius, asyncProcessor);

                if (Random.value < .1f)
                {
                    p.InitializeAtmosphere(sunColor, sun.transform.position, sunSystem.sun.radius, pl.radius, asyncProcessor);
                }

                p.AddMyComponent <WorldlGravity>();
                obstacle        = p.AddMyComponent <Obstacle>();
                obstacle.radius = pl.radius;
                obstacles.Add(obstacle);

                outGeneratedObjects.Add(p);
            }

            navigation.AddObstacles(obstacles);
        }
Ejemplo n.º 6
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 });
        }
    }
Ejemplo n.º 7
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));
    }
Ejemplo n.º 8
0
 public static void GenerateGalaxy(Vector3 position, SunSystem sunSystem, Navigation navigation, ICollection <SpaceBody> outGeneratedObjects)
 {
     GenerateGalaxy(position, sunSystem, navigation, outGeneratedObjects, null);
 }