Ejemplo n.º 1
0
        public IHttpActionResult PutMunition(string id, Munition munition)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != munition.MunitionID)
            {
                return(BadRequest());
            }

            if (munition.MunitionName == null || munition.MunitionName.Trim() == "")
            {
                return(BadRequest("Invalid Munition Name: " + munition.MunitionName));
            }

            if (!IsValidMunitionRole(munition.MunitionRole))
            {
                return(BadRequest("Invalid Munition Role: " + munition.MunitionRole));
            }

            if (!IsValidMOS(munition.MunitionMOS1))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS1));
            }

            if (!IsValidMOS(munition.MunitionMOS2))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS2));
            }

            if (!IsValidMOS(munition.MunitionMOS3))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS3));
            }

            db.Entry(munition).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MunitionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PostMunition()
        {
            Munition munition = await UpdateDataWithFile();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (munition.MunitionName == null || munition.MunitionName.Trim() == "")
            {
                return(BadRequest("Invalid Munition Name: " + munition.MunitionName));
            }

            if (!IsValidMunitionRole(munition.MunitionRole))
            {
                return(BadRequest("Invalid Munition Role: " + munition.MunitionRole));
            }

            if (!IsValidMOS(munition.MunitionMOS1))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS1));
            }

            if (!IsValidMOS(munition.MunitionMOS2))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS2));
            }

            if (!IsValidMOS(munition.MunitionMOS3))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS3));
            }

            munition.MunitionID = Guid.NewGuid().ToString();
            munition.LastUpdate = DateTime.Now;
            db.Munitions.Add(munition);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (MunitionExists(munition.MunitionID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApiPost", new { id = munition.MunitionID }, munition));
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetMunition(string id)
        {
            Munition munition = db.Munitions.Find(id);

            if (munition == null)
            {
                return(NotFound());
            }

            return(Ok(munition));
        }
Ejemplo n.º 4
0
        public IHttpActionResult DeleteMunition(string id)
        {
            Munition munition = db.Munitions.Find(id);

            if (munition == null)
            {
                return(NotFound());
            }

            db.Munitions.Remove(munition);
            db.SaveChanges();

            return(Ok(munition));
        }
Ejemplo n.º 5
0
    //Use this for initialization
    new void Start()
    {
        base.Start();

        if (null != m_source && null != m_destination)
        {
            SetSourceAndTarget(m_source, m_destination);
        }

        m_munition     = gameObject.GetComponent <Munition>();
        m_lineRenderer = gameObject.AddComponent <LineRenderer>();

        m_attackTimer      = new Timer();
        m_attackTimer.time = m_munition.attack_time + Random.Range(0, m_munition.attack_time_variance);
    }
Ejemplo n.º 6
0
 public override void ShootAt(Vector3 target)
 {
     if (bulletPoolReady.Count > 0)
     {
         projectile = (GameObject)bulletPoolReady[0];
         activeBullet = projectile.GetComponent(typeof(Munition)) as Munition;
         activeBullet.speed = this.speed;
         activeBullet.baseDamage = this.damage;
         activeBullet.duration = this.duration;
         activeBullet.NbCollision = this.nbCollision;
         activeBullet.color = this.color;
         activeBullet.joueur = this.joueur;
         activeBullet.Spawner = this.weaponHolder.transform;
     }
 }
Ejemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        rigid2d = GetComponent<Rigidbody2D> ();
        rigid2d.isKinematic = true;

        m = GetComponentInParent<Munition> ();

        xDirection = (goXPositiv ? 1 : -1);

        var logger = Eventlogger.getInstance();
        logger.StartEvent("mehrhuhn_spawn");
        logger.Writer.WriteElementString("points",points.ToString());
        logger.Writer.WriteElementString("direction",(goXPositiv?"rigth":"left"));
        logger.WritePositon(transform.position);
        logger.EndEvent();
    }
Ejemplo n.º 8
0
 public void FixedUpdate()
 {
     for (int i = 0; i < bulletPoolActive.Count; i++)
     {
         projectile = (GameObject)bulletPoolActive[i];
         activeBullet = projectile.GetComponent(typeof(Munition)) as Munition;
         if (activeBullet.Actif)
         {
             if (activeBullet.Expirer)
             {
                 activeBullet.Actif = false;
                 activeBullet.transform.position = bulletPool.position;
                 bulletPoolActive.RemoveAt(i);
                 bulletPoolReady.Add(projectile);
             }
         }
     }
 }
Ejemplo n.º 9
0
    protected void Start()
    {
		icon = Resources.Load("Sprites/bubble") as Texture2D;

        imageProjectile = LoadBullet("Bulle");
        projectile = MonoBehaviour.Instantiate(imageProjectile, transform.position, transform.rotation) as GameObject;
        projectile.transform.Translate(0, 0, 0, Space.Self);
        projectile.transform.parent = this.transform;
        particule = projectile.GetComponent(typeof(Munition)) as Munition;
        particule.speed = this.speed;
        particule.baseDamage = this.damage;
        particule.duration = this.duration;
        particule.emissionRate = this.emissionRate;
        particule.emissionAngle = this.emissionAngle;
        particule.color = this.color;
        particule.joueur = this.joueur;
        particule.Spawner = this.weaponHolder.transform;
    }
Ejemplo n.º 10
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        Capturable cap = collision.gameObject.GetComponent <Capturable>();

        if (cap != null)
        {
            cap.landMans(res, team);
            Destroy(gameObject);
        }
        else
        {
            Munition mun = collision.gameObject.GetComponent <Munition>();
            if (mun == null)
            {
                Destroy(gameObject);
            }
        }
    }
        public IHttpActionResult GetMunition(string id)
        {
            Munition munition = db.Munitions.Find(id);

            if (munition == null)
            {
                return(NotFound());
            }

            munition.AddUrl(munition.GetType().GetProperties().Where(p => properties.Contains(p.Name)).ToArray(), this.Request);
            //object uploadUrl;
            //Request.Properties.TryGetValue("uploadUrl", out uploadUrl);
            //munition.MunitionWireframe = uploadUrl + munition.MunitionWireframe;
            //munition.MunitionPhoto = uploadUrl + munition.MunitionPhoto;
            //munition.Munition3D = uploadUrl + munition.Munition3D;
            //munition.MunitionIcon = uploadUrl + munition.MunitionIcon;
            //munition.MunitionDatasheet = uploadUrl + munition.MunitionDatasheet;
            return(Ok(munition));
        }
        public IHttpActionResult DeleteMunition(string id)
        {
            Munition munition = db.Munitions.Find(id);

            if (munition == null)
            {
                return(NotFound());
            }

            if (db.MunitionsInventory.Any(x => x.metaDataID == munition.MunitionID))
            {
                return(BadRequest("This specification cannot be deleted -- there are inventory items that use this specification."));
            }

            db.Munitions.Remove(munition);
            db.SaveChanges();
            munition.DeleteFiles(munition.GetType().GetProperties().Where(p => properties.Contains(p.Name)).ToArray(), "Munition");
            return(Ok(munition));
        }
        public async Task <IHttpActionResult> PutMunition(string id)
        {
            Munition munition = await UpdateDataWithFile();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != munition.MunitionID)
            {
                return(BadRequest());
            }

            if (munition.MunitionName == null || munition.MunitionName.Trim() == "")
            {
                return(BadRequest("Invalid Munition Name: " + munition.MunitionName));
            }

            if (!IsValidMunitionRole(munition.MunitionRole))
            {
                return(BadRequest("Invalid Munition Role: " + munition.MunitionRole));
            }

            if (!IsValidMOS(munition.MunitionMOS1))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS1));
            }

            if (!IsValidMOS(munition.MunitionMOS2))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS2));
            }

            if (!IsValidMOS(munition.MunitionMOS3))
            {
                return(BadRequest("Invalid MOS: " + munition.MunitionMOS3));
            }

            munition.RemoveUrl(munition.GetType().GetProperties().Where(p => properties.Contains(p.Name)).ToArray(), this.Request);
            munition.LastUpdate      = DateTime.Now;
            db.Entry(munition).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MunitionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 14
0
        public override void Draw()
        {
            ImGui.Columns(2);
            ImGui.BeginChild("##munitions");
            foreach (var m in projectileList)
            {
                if (ImGui.Selectable(m.Nickname, currentMunition == m))
                {
                    currentMunition = m;
                    constEffect     = effects.FindEffect(m.ConstEffect);
                    bolt            = effects.BeamBolts.FirstOrDefault(x =>
                                                                       x.Nickname.Equals(constEffect.VisBeam, StringComparison.OrdinalIgnoreCase));
                    beam = effects.BeamSpears.FirstOrDefault(x =>
                                                             x.Nickname.Equals(constEffect.VisBeam, StringComparison.OrdinalIgnoreCase));
                    viewport.ResetControls();
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            ImGui.BeginChild("##rendering");
            ViewerControls.DropdownButton("Camera Mode", ref cameraMode, camModes);
            viewport.Mode = (CameraModes)camModes[cameraMode].Tag;
            ImGui.SameLine();
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                viewport.ResetControls();
            }
            viewport.Begin();
            Matrix4x4 rot = Matrix4x4.CreateRotationX(viewport.CameraRotation.Y) *
                            Matrix4x4.CreateRotationY(viewport.CameraRotation.X);
            var dirRot = Matrix4x4.CreateRotationX(viewport.ModelRotation.Y) * Matrix4x4.CreateRotationY(viewport.ModelRotation.X);
            var norm   = Vector3.TransformNormal(-Vector3.UnitZ, dirRot);
            var dir    = Vector3.Transform(-Vector3.UnitZ, rot);
            var to     = viewport.CameraOffset + (dir * 10);

            if (viewport.Mode == CameraModes.Arcball)
            {
                to = Vector3.Zero;
            }
            camera.Update(viewport.RenderWidth, viewport.RenderHeight, viewport.CameraOffset, to, rot);
            mw.Commands.StartFrame(mw.RenderState);
            beams.Begin(mw.Commands, mw.Resources, camera);
            var position = Vector3.Zero;

            if (beam != null)
            {
                beams.AddBeamSpear(position, norm, beam);
            }
            else if (bolt != null)
            {
                Vector2 tl, tr, bl, br;
                //CoordsFromTexture(bolt.HeadTexture, out tl, out tr, out bl, out br);
            }
            beams.End();
            fxPool.Draw(camera, null, mw.Resources, null);
            mw.Commands.DrawOpaque(mw.RenderState);
            mw.RenderState.DepthWrite = false;
            mw.Commands.DrawTransparent(mw.RenderState);
            mw.RenderState.DepthWrite = true;
            if (constEffect != null)
            {
                mw.Renderer2D.Start(viewport.RenderWidth, viewport.RenderHeight);
                var debugText = new StringBuilder();
                debugText.AppendLine($"ConstEffect: {constEffect.Nickname}");
                if (bolt != null)
                {
                    debugText.AppendLine($"Bolt: {bolt.Nickname}");
                }
                if (beam != null)
                {
                    debugText.AppendLine($"Beam: {beam.Nickname}");
                }
                mw.Renderer2D.DrawString("Arial", 10, debugText.ToString(), Vector2.One, Color4.White);
                mw.Renderer2D.Finish();
            }
            viewport.End();
            ImGui.EndChild();
        }