Ejemplo n.º 1
0
        public IActionResult Fletcher()
        {
            SolvedModel model    = new SolvedModel();
            int         nNumVars = 2;

            double[] fX = new double[] { 0, 0 };
            model.Start = new List <double>(fX);
            double[]     fParam   = new double[] { 0, 0 };
            int          nIter    = 0;     // contador de iteraciones
            int          nMaxIter = 100;   // limite de iteraciones
            double       fEpsFx   = 0.001; // Toleracion
            int          i;
            double       fBestF;           // Maximo
            string       sErrorMsg = "";
            Fletcher     oOpt;
            MyFxDelegate MyFx = new MyFxDelegate(Fx3);

            oOpt            = new Fletcher();
            model.Tolerace  = fEpsFx;
            model.MaxCycles = nMaxIter;
            fBestF          = oOpt.CalcOptim(nNumVars, ref fX, ref fParam, fEpsFx, nMaxIter, ref nIter, ref sErrorMsg, MyFx);
            if (sErrorMsg.Length > 0)
            {
                model.ErrorMsg = sErrorMsg;
            }
            for (i = 0; i < nNumVars; i++)
            {
                model.X.Add(fX[i]);
            }
            model.Function   = fBestF;
            model.Iterations = nIter;
            return(View(model));
        }
Ejemplo n.º 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Fletcher fletcherScript = collision.collider.GetComponent <Fletcher>();

        //If collectable is touched by Fletcher
        if (fletcherScript)
        {
            //Adds collectable score to total
            scoreObject.AddScore(collectableValue);

            //Gets rid of collectable
            Destroy(gameObject);
        }
    }
Ejemplo n.º 3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //check if the thing we collideded with has Fletcher script
        Fletcher fletcherScript = collision.collider.GetComponent <Fletcher>();

        //if it is Fletcher
        if (fletcherScript != null)
        {
            //deletes Fletcher's position for tt
            PlayerPrefs.DeleteKey("xPos");
            PlayerPrefs.DeleteKey("yPos");
            //kill Fletcher
            fletcherScript.Kill();
        }
    }
Ejemplo n.º 4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //check if the thing we collideded with has Fletcher script
        Fletcher playerScript = collision.collider.GetComponent <Fletcher>();

        //run if ran into by player
        if (playerScript != null)
        {
            //deletes player position for tt
            PlayerPrefs.DeleteKey("xPos");
            PlayerPrefs.DeleteKey("yPos");

            scoreObject.SaveScore();
            //load the next level
            SceneManager.LoadScene(sceneToLoad);
        }
    }
Ejemplo n.º 5
0
        public Map(string fileName, Game1 game, Mapper mapper, List <String> enemyList)
        {
            FileInputHandler fileIn = new FileInputHandler(game);

            tiles          = fileIn.parseToArray(fileName);
            this.gameRef   = game;
            this.mapper    = mapper;
            this.enemyList = enemyList;

            loadList = new List <Sprite>();
            int    dim = 16;
            string s   = "";

            for (int x = 0; x < dim; x++)
            {
                for (int y = 0; y < dim; y++)
                {
                    Vector2 position = new Vector2(x * 64, y * 64);
                    s = this.tiles[y, x];
                    //if (s.Equals("0"))
                    //{
                    //    ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                    //    loadList.Add(ts);
                    //}
                    if (s.Contains("map_"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        loadList.Add(ts);
                        string selectedBoss = s.Substring(s.IndexOf("_") + 1);
                        Enemy  bossObject;
                        switch (selectedBoss)
                        {
                        case "clark":
                            bossObject = new Clark(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "pay":
                            bossObject = new JerryPay(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "fletcher":
                            bossObject = new Fletcher(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "halliday":
                            bossObject = new Halliday(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "king_james":
                            bossObject = new Boss(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        default:
                            bossObject = new Clark(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;
                        }
                        BossSprite combatSprite = new BossSprite(gameRef.Content.Load <Texture2D>(@"Images/map" + s.Substring(s.IndexOf('_'))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero, gameRef, bossObject);
                        loadList.Add(combatSprite);
                    }
                    else if (s.Contains("3d"))
                    {
                        ts          = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        ts.passable = false;
                        loadList.Add(ts);
                    }
                    else if (s.Contains("i"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        Treasure t = new Treasure(gameRef.Content.Load <Texture2D>(@"Images/mapItem"), position, 0, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(t);
                    }
                    else if (s.Contains("d"))
                    {
                        int    i     = 0;
                        string mapID = s.Substring(1, 2);

                        float placeAtX = (float.Parse(s.Substring(s.IndexOf(";") + 1, 2))) * 64;
                        float placeAtY = (float.Parse(s.Substring(s.IndexOf("_") + 1, 2))) * 64;
                        Door  d        = new Door(gameRef.Content.Load <Texture2D>(@"Images/tiled"), position, 0, mapID, mapper, new Vector2(placeAtX, placeAtY), gameRef);
                        d.passable       = false;
                        d.isInteractable = true;
                        loadList.Add(d);
                    }
                    else if (s.Contains("k"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        Key k = new Key(gameRef.Content.Load <Texture2D>(@"Images/key"), position, 0, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(k);
                    }

                    else if (s.Contains("l"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        LockedDoor ld = new LockedDoor(gameRef.Content.Load <Texture2D>(@"Images/lockedDoor"), position, 0, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(ld);
                    }
                    else if (s.Contains("s"))
                    {
                        ts          = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        ts.passable = false;
                        ShopSprite ss = new ShopSprite(gameRef.Content.Load <Texture2D>(@"Images/shop"), position, 25, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(ss);
                    }
                    else if (s == "0")
                    {
                        int wallType = r.Next(0, 9);
                        switch (wallType)
                        {
                        case 0:
                            break;

                        case 1:
                            wallType = 0;
                            break;

                        case 2:
                            wallType = 1;
                            break;

                        case 3:
                            wallType = 1;
                            break;

                        case 4:
                            wallType = 2;
                            break;

                        case 5:
                            wallType = 2;
                            break;

                        case 6:
                            wallType = 3;
                            break;

                        case 7:
                            wallType = 1;
                            break;

                        case 8:
                            wallType = 2;
                            break;
                        }
                        ts          = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/wallTile" + wallType), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        ts.passable = false;
                        loadList.Add(ts);
                    }
                    else
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        if (s == "0" || s == "b")
                        {
                            ts.passable = false;
                        }
                        loadList.Add(ts);
                    }
                }
            }
        }