Beispiel #1
0
        public ActionResult Nuevo(ListaArmas model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (poligonoEntities db = new poligonoEntities())
                    {
                        var oArma = new arma();
                        oArma.nombre_arma  = model.nombrearma;
                        oArma.modelo       = model.modelo;
                        oArma.foto         = model.foto;
                        oArma.numero_serie = model.numeroserie;

                        db.arma.Add(oArma);
                        db.SaveChanges();
                    }
                    return(Redirect("~/Armas/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public ActionResult Nuevo(ListaArmas model, HttpPostedFileBase foto)

        {
            try
            {
                if (ModelState.IsValid)
                {
                    /*if (imagen.ContentLength > 0)
                     * {
                     *  string relativePath = "~/Temp/" + Path.GetFileName(imagen.FileName);
                     *  string physicalPath = Server.MapPath(relativePath);
                     *  imagen.SaveAs(physicalPath);
                     *  //return View((object)relativePath);
                     * }*/

                    if (foto != null)
                    {
                        string image1 = foto.FileName;
                        model.foto = image1;
                        var image1Path = Path.Combine(Server.MapPath("~/Temp"), image1);
                        foto.SaveAs(image1Path);
                    }

                    using (Context db = new Context())

                    {
                        var oArma = new arma();
                        oArma.nombre_arma  = model.nombrearma;
                        oArma.modelo       = model.modelo;
                        oArma.foto         = model.foto;
                        oArma.numero_serie = model.numeroserie;

                        db.Arma.Add(oArma);
                        db.SaveChanges();
                    }
                    return(Redirect("~/Armas/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #3
0
    private void Start()
    {
        trans       = GetComponent <Transform>();
        rigi        = GetComponent <Rigidbody2D>();
        audioSource = GetComponent <AudioSource>();
        if (gun == null)
        {
            gun = new List <arma>();
        }
        for (int i = 0; i < gunM.Count; i++)
        {
            gun.Add((arma)gunM[i]);
        }
        for (int i = 0; i < gunR.Count; i++)
        {
            gun.Add((arma)gunR[i]);
        }
        armaAtual = gun[armaInicial];
        animator  = GetComponent <Animator>();
        GetComponent <PlayerAnimationHandler>().setSkinVariation(skinIndex);

        if (!isLocalPlayer)
        {
            GameObject toSpawn = GameObject.Instantiate(prefabHealthBar);
            toSpawn.GetComponent <Follower>().target = transform;
            UnityEngine.UI.Slider slider = toSpawn.GetComponentInChildren <UnityEngine.UI.Slider>();
            GetComponent <Health>().setBar(slider);
        }
        else
        {
            if (playerID != -1)
            {
                changedID(playerID);
            }

            GetComponent <Health>().setBar(PlayerManager.instance.playerSlider);
            ammoText = PlayerManager.instance.ammoText;
        }

        Debug.Log("Started: " + playerID);
    }
Beispiel #4
0
 private void RpcEquip(int id)
 {
     armaAtual.lugarDaArma.GetComponent <SpriteRenderer>().sprite = null;
     armaAtual = gun[id];
     GetComponent <PlayerAnimationHandler>().setHandStance(armaAtual.handstances);
     if (isLocalPlayer)
     {
         ammoAtual = armaAtual.maxAmmo;
         maxAmmo   = armaAtual.maxAmmo;
         if (maxAmmo > 500)
         {
             shouldShowAmmo = false;
         }
         else
         {
             shouldShowAmmo = true;
         }
         updateAmmoText();
     }
     audioSource.clip = armaAtual.soundClip;
     armaAtual.lugarDaArma.GetComponent <SpriteRenderer>().sprite = armaAtual.img;
 }
Beispiel #5
0
 // Start is called before the first frame update
 void Start()
 {
     rgPlayer     = GetComponent <Rigidbody2D>();
     controleArma = FindObjectOfType(typeof(arma)) as arma;
     animPlayer   = GetComponent <Animator>();
 }