示例#1
0
        public void Setup()
        {
            comun   = new Comun(2);
            red     = new Red(10);
            bomb    = new Bomb(3);
            chuck   = new Chuck(4);
            terence = new Terence(3, 2);
            matilda = new Matilda(4, new List <Huevo>()
            {
                new Huevo(2), new Huevo(3), new Huevo(1), new Huevo(4)
            });

            madera       = new Madera(3);
            vidrio       = new Vidrio(1);
            piedra       = new Piedra(2);
            obrero       = new Obrero();
            armadoEscudo = new Armado(new Escudo(2));
            armadoCasco  = new Armado(new Casco(4));

            isla = new Isla(new List <Pajaro>()
            {
                comun, red, bomb, chuck, terence, matilda
            });
            islaCerditos = new Isla_Cerdo(new List <Obstaculo>()
            {
                madera, vidrio, piedra, obrero, armadoCasco, armadoEscudo
            });
        }
示例#2
0
 void DestruirObstaculos()
 {
     Obstaculo[] Obstaculos = FindObjectsOfType <Obstaculo>();
     foreach (Obstaculo Obstaculo in Obstaculos)
     {
         Obstaculo.Destruir();
     }
 }
示例#3
0
 public ActionResult Edit([Bind(Include = "Id,Descripcion,Estado,FechaDeInicio,FechaDeFin")] Obstaculo obstaculo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(obstaculo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(obstaculo));
 }
示例#4
0
        public ActionResult RealDeleteConfirmed(int id)
        {
            Obstaculo obstaculo = db.Obstaculo.Find(id);

            db.Obstaculo.Remove(obstaculo);
            db.SaveChanges();
            TempData["Type"]    = "error";
            TempData["Message"] = "El registro se eliminó correctamente";
            return(RedirectToAction("Index"));
        }
示例#5
0
        // GET: Obstaculoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Obstaculo obstaculo = db.Obstaculo.Find(id);

            if (obstaculo == null)
            {
                return(HttpNotFound());
            }
            return(View(obstaculo));
        }
示例#6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Obstaculo obstaculo = db.Obstaculo.Find(id);

            if (obstaculo.Estado == "I")
            {
                obstaculo.Estado = "A";
            }
            else
            {
                obstaculo.Estado = "I";
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#7
0
    void createObstacles(Level level)
    {
        for (int i = 0; i < level.heights.Length; i++)
        {
            int       height = level.heights [i];
            Obstaculo obj    = level.obstaculos [i];
            if (obj == Obstaculo.NADA)
            {
                Instantiate(chao, new Vector3(level.x + i, height - 1, 0), Quaternion.identity);
            }
            else if (obj == Obstaculo.SLIDE)
            {
                Instantiate(parede, new Vector3(level.x + i, height + 1, 0), Quaternion.identity);
                Instantiate(parede, new Vector3(level.x + i, height + 2, 0), Quaternion.identity);

                Instantiate(chao, new Vector3(level.x + i, height - 1, 0), Quaternion.identity);
            }
            else if (obj == Obstaculo.JUMP)
            {
                Instantiate(parede, new Vector3(level.x + i, height, 0), Quaternion.identity);
                Instantiate(parede, new Vector3(level.x + i, height + 1, 0), Quaternion.identity);

                Instantiate(chao, new Vector3(level.x + i, height - 1, 0), Quaternion.identity);
            }
            else if (obj == Obstaculo.BOX)
            {
                Instantiate(caixa, new Vector3(level.x + i, height, 0), Quaternion.identity);

                Instantiate(chao, new Vector3(level.x + i, height - 1, 0), Quaternion.identity);
            }
            else if (obj == Obstaculo.HOLE)
            {
            }
            else if (obj == Obstaculo.SPIKE)
            {
                Instantiate(spike, new Vector3(level.x + i, height, 0), Quaternion.identity);

                Instantiate(chao, new Vector3(level.x + i, height - 1, 0), Quaternion.identity);
            }
        }
    }
示例#8
0
        public void Cargar_Obstaculo_Crecido()
        {
            this.zgc.GraphPane.CurveList.Clear();

            var       px1  = new double[] { 40, 50, 30 };
            var       py1  = new double[] { 30, 50, 50 };
            var       pol1 = new TMPoligon(1, px1, py1);
            GraphPane pane = zgc.GraphPane;

            foreach (TMSegment seg in pol1.Segments)
            {
                var x = new[] { seg.Point_1.X, seg.Point_2.X };
                var y = new[] { seg.Point_1.Y, seg.Point_2.Y };
                pane.AddCurve(null, x, y, Color.Blue, SymbolType.None);
            }

            var ax = new double[] { 48, 35 }; //new double[] { 5, 0 }; //new double[] { 0, -5 }; // new double[] {-5, 0}; // new[] { 0.0, 5 };
            var ay = new double[] { 30, 78 }; //new double[] { -10, 0 }; //new double[] { 0, 10 };  //new double[] { -10, 0 }; //new[] { 0.0, 10 };

            pane.AddCurve(null, ax, ay, Color.Black, SymbolType.None);

            var       obs = new Obstaculo(px1, py1);
            Obstaculo oc  = obs.obstaculo_crecido(new Segment(new PointD(ax[0], ay[0]), new PointD(ax[1], ay[1])));

            for (int i = 0; i < oc.xVector.Length - 1; i++)
            {
                var x = new[] { oc.xVector[i], oc.xVector[i + 1] };
                var y = new[] { oc.yVector[i], oc.yVector[i + 1] };
                pane.AddCurve(null, x, y, Color.Red, SymbolType.None);
            }

            var xf = new[] { oc.xVector[oc.xVector.Length - 1], oc.xVector[0] };
            var yf = new[] { oc.yVector[oc.yVector.Length - 1], oc.yVector[0] };

            pane.AddCurve(null, xf, yf, Color.Red, SymbolType.None);

            zgc.AxisChange();
            this.zgc.Refresh();
        }
示例#9
0
    private void generaPiscinaObstaculos()
    {
        piscinaObstaculos = new Obstaculo[4][][];
        //se genera una piscina de obstaculos para evitar instanciar o eliminar objetos
        for (int i = 0; i < obstaculosBase.Length - 1; i++)
        {
            piscinaObstaculos [i] = new Obstaculo[obstaculosBase [i].Length][];
            for (int j = 0; j < obstaculosBase[i].Length; j++)
            {
                piscinaObstaculos[i][j] = new Obstaculo[5];
                for (int k = 0; k < 5; k++)
                {
                    piscinaObstaculos [i] [j] [k] = new Obstaculo(GameObject.Instantiate(obstaculosBase [i] [j]), i);
                    piscinaObstaculos[i][j][k].GetObject().SetActive(false);
                }
            }
        }

        //PUERTA:
        piscinaObstaculos[ESPECIALES]       = new Obstaculo[1][];
        piscinaObstaculos[ESPECIALES][0]    = new Obstaculo[1];
        piscinaObstaculos[ESPECIALES][0][0] = new Obstaculo(GameObject.Instantiate(obstaculosBase[ESPECIALES][0]), ESPECIALES);
        piscinaObstaculos[ESPECIALES][0][0].GetObject().SetActive(false);
        CombinacionManager.target = piscinaObstaculos[ESPECIALES][0][0].GetObject().GetComponent <Transform>();

        /*    #if DEBUG
         *  for (int i = 0; i < piscinaObstaculos.Length; i++)
         *  {
         *      for (int j = 0; j < piscinaObstaculos[i].Length; j++)
         *      {
         *          for (int k = 0; k < piscinaObstaculos[i][j].Length; k++)
         *          {
         *              Debug.Log(System.Convert.ToInt32(i) + "/" + System.Convert.ToInt32(j) + "/" + System.Convert.ToInt32(k) + "/" + piscinaObstaculos[i][j][k].GetObject().name);
         *          }
         *      }
         *  }
         #endif*/
    }
示例#10
0
        public ActionResult Create([Bind(Include = "Id,Descripcion,Estado,FechaDeInicio,FechaDeFin")] Obstaculo obstaculo)
        {
            if (ModelState.IsValid)
            {
                db.Obstaculo.Add(obstaculo);
                string mensaje = Verificar(obstaculo.Id);
                if (mensaje == "")
                {
                    db.SaveChanges();
                    TempData["Type"]    = "success";
                    TempData["Message"] = "El registro se realizó correctamente";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Type    = "warning";
                    ViewBag.Message = mensaje;
                    return(View(obstaculo));
                }
            }

            return(View(obstaculo));
        }
示例#11
0
    private void prepararObstaculo(Obstaculo obs, int tipo)
    {
        obs.GetObject().SetActive(true);

        if (tipo != ESPECIALES)
        {
            obs.GetObject().transform.position = new Vector3(Random.Range(valoresFrontera[X_MIN], valoresFrontera[X_MAX]),
                                                             Random.Range(valoresFrontera[Y_MIN], valoresFrontera[Y_MAX]), Z_INICIAL);
        }
        if (obs.GetTipo() == ESPECIALES)
        {
            obs.GetObject().transform.position = new Vector3(3.1f, 0, 240);
        }
        obs.usandose = true;

/*#if DEBUG
 *      Debug.Log(obs.GetObject().transform.position);
 #endif*/
        switch (tipo)
        {
        case NORMALES:
            obs.velocidad.z = velocidadBase.z * Random.Range(0.8f, 1.1f) + (Time.time - tiempoInicial) * 0.01f;
            break;

        case RAPIDOS:
            obs.velocidad.z = velocidadBase.z * Random.Range(1.8f, 2.2f) + (Time.time - tiempoInicial) * 0.01f;
            break;

        case GRANDES:
            obs.velocidad.z = velocidadBase.z * Random.Range(0.3f, 0.6f) + (Time.time - tiempoInicial) * 0.01f;
            break;

        case ESPECIALES:
            obs.velocidad.z = velocidadBase.z + (Time.time - tiempoInicial) * 0.01f;
            break;
        }
    }
示例#12
0
 bool pode(Obstaculo a, Obstaculo b)
 {
     if (a == Obstaculo.NADA || b == Obstaculo.NADA)
     {
         return(true);
     }
     if (a == b)
     {
         return(true);
     }
     if (a == Obstaculo.SLIDE || b == Obstaculo.SLIDE)
     {
         return(false);
     }
     if (a == Obstaculo.JUMP)
     {
         return(b != Obstaculo.HOLE && b != Obstaculo.SPIKE);
     }
     if (b == Obstaculo.JUMP)
     {
         return(a != Obstaculo.HOLE && a != Obstaculo.SPIKE);
     }
     return(true);
 }
示例#13
0
    Level genLevel(int level, int x)
    {
        Level lvl = new Level();

        lvl.x = x;
        int       aux = level;
        ArrayList possibleObstacles = new ArrayList();

        if ((aux & 1) == 1)
        {
            possibleObstacles.Add(Obstaculo.SLIDE);
        }
        aux = aux >> 1;
        if ((aux & 1) == 1)
        {
            possibleObstacles.Add(Obstaculo.JUMP);
        }
        aux = aux >> 1;
        if ((aux & 1) == 1)
        {
            possibleObstacles.Add(Obstaculo.BOX);
        }
        aux = aux >> 1;
        if ((aux & 1) == 1)
        {
            possibleObstacles.Add(Obstaculo.HOLE);
        }
        aux = aux >> 1;
        if ((aux & 1) == 1)
        {
            possibleObstacles.Add(Obstaculo.SPIKE);
        }


        int lvlsize = obstacleLength + offset;

        lvl.heights = new int[lvlsize];
        //generate heights
        for (int i = 0; i < offset; i++)
        {
            lvl.heights [i] = lastHeight;
        }
        for (int i = offset; i < lvlsize; i++)
        {
            lvl.heights [i] = (int)Mathf.Round(noise.nextVal());
        }
        lastHeight = lvl.heights [lvlsize - 1];
        //TODO generate obstacles
        Obstaculo last = Obstaculo.NADA;

        lvl.obstaculos = new Obstaculo[lvlsize];


        if (possibleObstacles.Count == 0)
        {
            return(lvl);
        }
        for (int i = offset; i < lvlsize - 1; i++)
        {
            if (lvl.heights [i - 1] == lvl.heights [i] && lvl.heights [i] == lvl.heights [i + 1])
            {
                float prob = 0.3f - 1f / (level + 3);

                if (Random.Range(0f, 1f) < prob)
                {
                    int t = Random.Range(0, possibleObstacles.Count);
                    int u = t;
                    while (true)
                    {
                        if (pode(lvl.obstaculos[i - 1], (Obstaculo)possibleObstacles [u]))
                        {
                            Debug.Log(possibleObstacles [u]);
                            lvl.obstaculos [i] = (Obstaculo)possibleObstacles [u];
                            break;
                        }
                        else
                        {
                            u = (u + 1) % possibleObstacles.Count;
                            if (u == t)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
        return(lvl);
    }