Esempio n. 1
0
    private void FixedUpdate()
    {
        if (rocketType == RocketType.Guided)
        {
            rb.velocity        = (Target.transform.position - transform.position).normalized * speed;
            transform.rotation = Quaternion.LookRotation(rb.velocity) * Quaternion.Euler(rocketRotation);
        }
        else if (rocketType == RocketType.HitByBat || rocketType == RocketType.HitByOther)
        {
            var rot = rb.rotation;
            rot.z += 100 * Time.fixedDeltaTime;
            rb.rotation.Set(rot.x, rot.y, rot.z, rot.w);

            explodeInSec -= Time.fixedDeltaTime;
            destroyInSec -= Time.fixedDeltaTime;
            if (explodeInSec < 0)
            {
                audioSource.Stop();
                explodeRocket();
                explodeInSec = 1000;
            }

            if (destroyInSec < 0)
            {
                RocketFactory.DestroyRocket(gameObject);
                DexplodeRocket();

                destroyInSec = 1000;
            }
        }
    }
Esempio n. 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(DestroyKey))
     {
         RocketFactory.DestroyRocket(gameObject);
     }
 }
Esempio n. 3
0
 private void OnTriggerEnter(Collider other)
 {
     Debug.Log("Trigger!!! " + other.gameObject.tag);
     if (other.gameObject.tag == "Enemy")
     {
         RocketFactory.DestroyRocket(other.gameObject);
     }
 }
Esempio n. 4
0
    public void Spawn(RocketType type)
    {
        var rocket = RocketFactory.CreateRocket(type);

        rocket.transform.position = gameObject.transform.position;
        rocket.GetComponent <Rocket>().Initialize(type, Target);
        audioSource.PlayOneShot(SoundFX.MissileLaunch);
        //Debug.Log("Rocket Spaned!!!!");
    }
Esempio n. 5
0
    public void Update()
    {
        SetGameMusicLevel(RocketFactory.GetActiveRocketCount());

        if (currentLevel == 0)
        {
            // playing intro music which doesn't get layered

            if (!GameMusicLevels[0].isPlaying)
            {
                // stop all the other music layers
                for (int i = 1; i < GameMusicLevels.Length; i++)
                {
                    GameMusicLevels[i].Stop();
                }
                GameMusicLevels[0].Play();
            }
        }
        else
        {
            // playing in play music which is layered so loop through the layers to turn the right ones on
            GameMusicLevels[0].Stop();

            if (!GameMusicLevels[1].isPlaying)
            {
                GameMusicLevels[1].Play();
            }

            if (GameMusicLevels[1].time > StartPlayingAtSec)
            {
                return;
            }

            // do turn on/off correct music level at the beginning of the music loop
            for (int i = 2; i < GameMusicLevels.Length; i++)
            {
                if (i <= currentLevel)
                {
                    if (!GameMusicLevels[i].isPlaying)
                    {
                        GameMusicLevels[i].Play();
                        GameMusicLevels[i].time = GameMusicLevels[1].time;
                    }
                }
                else
                {
                    GameMusicLevels[i].Stop();
                }
            }
        }
    }
Esempio n. 6
0
        // Protected.

        protected override async void Start()
        {
            base.Start();

            this.LeftCamera.Node.Name = "MainCamera";

            EnableGestureManipulation = true;
            EnableGestureTapped       = true;

            DirectionalLight.Node.SetWorldPosition(new Vector3(0, 1.5f, 0));
            DirectionalLight.Brightness = 1f;
            DirectionalLight.Node.SetDirection(new Vector3(0, -1, 0));

            var physics = this.Scene.GetOrCreateComponent <PhysicsWorld>();

            physics.SetGravity(new Vector3(0, 0, 0));
            physics.PhysicsCollisionStart += this.OnCollisionStart;

            this.voiceRecognition = this.Scene.CreateComponent <VoiceRecognition>();
            this.voiceRecognition.SetRegisterCallback(this.RegisterCortanaCommands);

            this.onScreenMenu = this.Scene.CreateComponent <OnScreenMenu>();

            this.focusManager = this.Scene.CreateComponent <FocusManager>();
            this.focusManager.DefaultFocus = this;
            this.focusManager.SetFocus(this);

            this.joystickServer = this.Scene.CreateComponent <JoystickServer>();

            this.planetFactory = this.Scene.CreateComponent <PlanetFactory>();

            this.rocketFactory = this.Scene.CreateComponent <RocketFactory>();

            this.grid = this.Scene.CreateComponent <Grid>();

            var listener = this.LeftCamera.Node.CreateComponent <SoundListener>();

            Audio.Listener = listener;

            // TODO: Spatial mapping. Way too slow
            //this.spatialMaterial = new Material();
            //this.spatialMaterial.SetTechnique(0, CoreAssets.Techniques.NoTextureUnlitVCol, 1, 1);
            //this.environmentNode = this.Scene.CreateChild("Environment");
            //var spatialMappingAllowed = await StartSpatialMapping(new Vector3(3, 3, 2), 1);
            //if (!spatialMappingAllowed)
            //    throw new InvalidOperationException("SpatialMapping is not allowed");

            await ShowSplash();
        }
Esempio n. 7
0
    //public GliderFactory gliderFactory;
    //public AircraftFactory aircraftFactory;
    //public RocketFactory rocketFactory;

    public IPlane createItem(Requirements reqs)
    {
        if (reqs.rocket)
        {
            RocketFactory rocketFactory = new RocketFactory();
            return(rocketFactory.ManufactureRocket(reqs));
        }
        else if (reqs.numberOfEngines > 0)
        {
            AircraftFactory aircraftFactory = new AircraftFactory();
            return(aircraftFactory.ManufacturePoweredAircraft(reqs));
        }
        else
        {
            GliderFactory gliderFactory = new GliderFactory();
            return(gliderFactory.ManufactureGlider(reqs));
        }
    }
Esempio n. 8
0
    private void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;

            factory = new Dictionary <RocketType, GameObjectFactory>();

            factory.Add(RocketType.Simple, new GameObjectFactory("rocket_simple"));
            factory.Add(RocketType.Guided, new GameObjectFactory("rocket_guided"));
            factory.Add(RocketType.HitByBat, new GameObjectFactory("rocket_hitbybat"));
            factory.Add(RocketType.HitByOther, new GameObjectFactory("rocket_hitbyother"));

            graveyardPosition = new Vector3(0, -2000, 0);
        }
    }
Esempio n. 9
0
    public override void _Ready()
    {
        rf = (RocketFactory)GetChild(0);
        of = (ObstacleFactory)GetChild(1);
        tf = (TargetFactory)GetChild(2);

        rockets            = rf.createPopulation(References.populationSize);
        obstacles          = of.createPopulation(References.obstaclePopulationSize);
        target             = tf.createTarget();
        populationDead     = false;
        time               = 0;
        maxFitnessAchieved = 0;

        for (int i = 0; i < rockets.Length; i++)
        {
            rockets[i].SetTarget(target);
        }

        genePool       = new List <Instruction[]>();
        fitnessHistory = new List <string>();

        infoText = (RichTextLabel)GetNode("/root/MainScene/UI/InfoText");
    }