示例#1
0
    public override void Reload()
    {
        if (!rocket && NumberOfRockets > 0)
        {
            float offset = 1f;
            if (prefabSlot.amunition == WeaponObject.AMUNITONTYPE.Rocket)
            {
                offset = 15f;
            }
            if ((countdown -= Time.deltaTime) <= 0f)
            {
                rocket = (GameObject.Instantiate(prefabSlot, new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y + offset, this.gameObject.transform.position.z), this.gameObject.transform.rotation) as RocketObject).GetComponent <RocketObject>();

                NumberOfRockets--;

                if (prefabSlot.amunition == WeaponObject.AMUNITONTYPE.Missiles)
                {
                    rocket.transform.forward = (rocket.transform.forward + new Vector3(Random.Range(-0.2f, 0.2f), 0.85f, Random.Range(-0.2f, 0.2f))).normalized;
                }
                //    rocket.transform.forward = (rocket.transform.forward + new Vector3(0, 1f, 0)).normalized;
                //  rocket.transform.forward = Vector3.up;
                else if (prefabSlot.amunition == WeaponObject.AMUNITONTYPE.Rocket)
                {
                    rocket.transform.up = -((rocket.transform.forward + new Vector3(Random.Range(-0.25f, 0.25f), 1f, Random.Range(-0.25f, 0.25f))).normalized);
                }
            }
        }
    }
示例#2
0
 public override void Engage(Vector3 targetPoint)
 {
     if (rocket)
     {
         rocket.SetTarget(targetPoint, UNIT.GoodOrEvil);
         rocket.LaunchButton = true;
         rocket = null;
         countdown = Interval;
     }
 }
示例#3
0
 public override void Engage(Vector3 targetPoint)
 {
     if (rocket)
     {
         rocket.SetTarget(targetPoint, UNIT.GoodOrEvil);
         rocket.LaunchButton = true;
         rocket    = null;
         countdown = Interval;
     }
 }
示例#4
0
        protected override void OnInitialize()
        {
            SphereModel sphere = new SphereModel(_coder, SPHERE_BREAKUPS);

            GlProgram wProgram = new GlProgram(
                new Shader(ShaderTypes.Vertex, File.ReadAllText(Path.Combine(SHADERS_DIR, WORLD_SHADERS, "vertex.glsl"))),
                new Shader(ShaderTypes.Fragment, File.ReadAllText(Path.Combine(SHADERS_DIR, WORLD_SHADERS, "fragment.glsl")))
                );

            GlProgram gProgram = new GlProgram(
                new Shader(ShaderTypes.Vertex, File.ReadAllText(Path.Combine(SHADERS_DIR, GUI_SHADERS, "vertex.glsl"))),
                new Shader(ShaderTypes.Fragment, File.ReadAllText(Path.Combine(SHADERS_DIR, GUI_SHADERS, "fragment.glsl")))
                );

            _universe.Add(new SpaceObject(2, 100000, sphere)
            {
                Position = new Vector3(0, 0, 0)
            });
            _universe.Add(new SpaceObject(8, 50, sphere)
            {
                Position = new Vector3(-500, -500, 0), Velocity = new Vector3(30f, 0, -5f)
            });
            _universe.Add(new SpaceObject(0, 250, sphere)
            {
                Position = new Vector3(500, -500, 0), Velocity = new Vector3(30f, 0, 5f)
            });
            _universe.Add(_rocket = new RocketObject(55, new RocketModel(_coder))
            {
                Position = new Vector3(500, 500, 500), Velocity = new Vector3(-30f, 0f, 0f)
            });

            RenderHandle handle = new RenderHandle(this, wProgram);

            _layer = new SceneLayer(_universe, handle);
            AddLayer(_layer);
            _cam = new OrbitalCamera(_layer.Camera)
            {
                Distance = 250
            };
            Font fnt = new Font(Path.Combine(ASSETS_DIR, FONT_DIR, FONT_FILE));

            AddLayer(new GuiFuelLayer(_rocket, this, gProgram, new GuiVertexCoder(), fnt));
            GuiLayer tutorial = new GuiLayer(this, gProgram, new GuiVertexCoder(), fnt);

            tutorial.Add(_tutorialLbl);
            AddLayer(tutorial);
            Background = new Color(50, 50, 50, 255);
            base.OnInitialize();
        }
示例#5
0
    public override void Reload()
    {
        if (!rocket && NumberOfRockets > 0)
        {
            float offset = 1f;
            if (prefabSlot.amunition == WeaponObject.AMUNITONTYPE.Rocket)
                offset = 15f;
            if ((countdown -= Time.deltaTime) <= 0f)
            {
                rocket = (GameObject.Instantiate(prefabSlot, new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y + offset, this.gameObject.transform.position.z), this.gameObject.transform.rotation) as RocketObject).GetComponent<RocketObject>();

                NumberOfRockets--;
                
                if (prefabSlot.amunition == WeaponObject.AMUNITONTYPE.Missiles)
                {
                    rocket.transform.forward = (rocket.transform.forward + new Vector3(Random.Range(-0.2f, 0.2f), 0.85f, Random.Range(-0.2f, 0.2f))).normalized;
                }
                //    rocket.transform.forward = (rocket.transform.forward + new Vector3(0, 1f, 0)).normalized;
                //  rocket.transform.forward = Vector3.up;
                else if (prefabSlot.amunition == WeaponObject.AMUNITONTYPE.Rocket)
                    rocket.transform.up = -((rocket.transform.forward + new Vector3(Random.Range(-0.25f, 0.25f), 1f, Random.Range(-0.25f, 0.25f))).normalized);
            }
        }
    }
示例#6
0
 public GuiFuelLayer(RocketObject rkt, Window w, GlProgram pgm, IVertexCoder <GuiVertex> coder, Font fnt) : base(w, pgm, coder, fnt)
 {
     _rkt     = rkt ?? throw new ArgumentNullException(nameof(rkt));
     _fuelPbr = new ProgressBar();
     Add(_fuelPbr);
 }