Exemple #1
0
    public void BuildExit()
    {
        AssetProxy     pr       = new AssetProxy(typeof(GameObject));
        GameObject     exitTile = Object.Instantiate(pr.LoadAsset("Objects/Tiles/ExitTile.prefab"));
        Vector2Int     settings = StaticTestSettings.getMapSize();
        int            stX      = settings.x;
        int            stY      = settings.y;
        List <Vector3> availabeleExitLocation = new List <Vector3>();

        do
        {
            for (int i = -stX / 2; i < stX / 2; i++)
            {
                for (int j = -stY / 2; j < stY / 2; j++)
                {
                    if (tiles.GetIndoorTiles().Contains(mapOperations.GetGroundTile(new Vector3Int(i, j, 0))) && !tiles.GetStructureTiles().Contains(mapOperations.GetStructureTile(new Vector3Int(i, j, 0))))
                    {
                        if (Random.value < 0.1)
                        {
                            availabeleExitLocation.Add(new Vector3(i, j));
                        }
                    }
                }
            }
        }while (availabeleExitLocation.Count == 0);
        int     exitLocationIndex = Random.Range(0, availabeleExitLocation.Count);
        Vector3 exitLocation      = availabeleExitLocation[exitLocationIndex];

        exitTile.transform.Translate(exitLocation);
        exitTile.transform.Translate(new Vector3(0.5f, 0.5f));
    }
Exemple #2
0
    void Start()
    {
        Canvas canvas_ui = GetComponent <Canvas>();

        animator = GameObject.Find("Fader").GetComponentInChildren <Animator>();


        //Actions
        Action start = () =>
        {
            PlayerPrefs.SetInt("Health", 200);
            PlayerPrefs.SetInt("Damage", 10);
            PlayerPrefs.SetInt("LevelCleared", 0);
            animator.SetTrigger("LoadGame");
        };
        Action load = () =>
        {
            animator.SetTrigger("LoadGame");
        };
        Action quit = () =>
        {
            Application.Quit();
        };
        Action setResolutionHD = () =>
        {
            Screen.SetResolution(1920, 1080, false);
        };
        Action setResolution = () =>
        {
            Screen.SetResolution(1440, 900, false);
        };
        Action setResolutionbad = () =>
        {
            Screen.SetResolution(500, 500, false);
        };
        Action setlocForest = () =>
        {
            StaticTestSettings.setLocation(Locations.Forest);
        };
        Action setlocDesert = () =>
        {
            StaticTestSettings.setLocation(Locations.Desert);
        };
        Action setlocVillage = () =>
        {
            StaticTestSettings.setLocation(Locations.Village);
        };
        Action setmapSmall = () =>
        {
            StaticTestSettings.setMapSize(new Vector2Int(50, 50));
        };
        Action setmapMed = () =>
        {
            StaticTestSettings.setMapSize(new Vector2Int(100, 100));
        };
        Action setmapLarge = () =>
        {
            StaticTestSettings.setMapSize(new Vector2Int(200, 200));
        };
        Action setTypeDungeon = () =>
        {
            StaticTestSettings.SetMapType(MapType.Dungeon);
        };
        Action setTypeVillage = () =>
        {
            StaticTestSettings.SetMapType(MapType.Village);
        };
        Action setTypeRuins = () =>
        {
            StaticTestSettings.SetMapType(MapType.Ruins);
        };

        AMC_Factory f  = new AMC_Factory(buttonPrefab, canvas_ui);
        MenuElement r1 = new MenuElement("HD", setResolutionHD);
        MenuElement r2 = new MenuElement("Okay", setResolution);
        MenuElement r3 = new MenuElement("Bad", setResolutionbad);



        MenuElement newGame  = new MenuElement("New Game", start);
        MenuElement loadGame = new MenuElement("Load", load);
        MenuElement quitGame = new MenuElement("Quit", quit);

        AbstractMenuComposite settings = f.createSubmenu("Settings", new List <AbstractMenuComposite>
        {
            r1,
            r2,
            r3
        });

        List <AbstractMenuComposite> list = new List <AbstractMenuComposite>
        {
            newGame,
            loadGame,
            settings,
            quitGame
        };
        AbstractMenuComposite backToMenu = f.createSubmenu("Back", list);

        settings.AddComponent(backToMenu);

        AbstractMenuComposite play = f.createSubmenu("Play", list);


        MenuElement SetLocForest  = new MenuElement("Forest", setlocForest);
        MenuElement SetLocDesert  = new MenuElement("Desert", setlocDesert);
        MenuElement SetLocVillage = new MenuElement("Village", setlocVillage);

        MenuElement setMapSizeSmall  = new MenuElement("50x50", setmapSmall);
        MenuElement setMapSizeMedium = new MenuElement("100x100", setmapMed);
        MenuElement setMapSizeLarge  = new MenuElement("200x200", setmapLarge);

        MenuElement setTypeDung = new MenuElement("Dungeon", setTypeDungeon);
        MenuElement setTypeRuin = new MenuElement("Ruins", setTypeRuins);
        MenuElement setTypeVill = new MenuElement("Village", setTypeVillage);

        AbstractMenuComposite testMapTypes = f.createSubmenu(StaticTestSettings.GetMapType().ToString(), new List <AbstractMenuComposite>
        {
            setTypeDung,
            setTypeRuin,
            setTypeVill,
        });
        Action updateTypeName = () =>
        {
            testMapTypes.ButtonName = StaticTestSettings.GetMapType().ToString();
        };

        AbstractMenuComposite testLocations = f.createSubmenu(StaticTestSettings.getLocation().ToString(), new List <AbstractMenuComposite>
        {
            SetLocForest,
            SetLocDesert,
            SetLocVillage,
        });
        Action updateLocName = () =>
        {
            testLocations.ButtonName = StaticTestSettings.getLocation().ToString();
        };


        AbstractMenuComposite testMapSize = f.createSubmenu(StaticTestSettings.getMapSize().ToString(), new List <AbstractMenuComposite>
        {
            setMapSizeSmall,
            setMapSizeMedium,
            setMapSizeLarge,
        });

        Action updateSizeName = () =>
        {
            testMapSize.ButtonName = StaticTestSettings.getMapSize().ToString();
        };


        MenuElement testStart = new MenuElement("Test start", start);


        List <AbstractMenuComposite> testList = new List <AbstractMenuComposite>
        {
            testLocations,
            testMapSize,
            testMapTypes,
            testStart
        };
        AbstractMenuComposite test = f.createSubmenu("Test", testList);

        Action back = () =>
        {
            test.ClickOperation();
        };

        setTypeDung.AppendFunction(updateTypeName);
        setTypeRuin.AppendFunction(updateTypeName);
        setTypeVill.AppendFunction(updateTypeName);
        setTypeDung.AppendFunction(back);
        setTypeRuin.AppendFunction(back);
        setTypeVill.AppendFunction(back);

        SetLocForest.AppendFunction(updateLocName);
        SetLocDesert.AppendFunction(updateLocName);
        SetLocVillage.AppendFunction(updateLocName);
        SetLocForest.AppendFunction(back);
        SetLocDesert.AppendFunction(back);
        SetLocVillage.AppendFunction(back);

        setMapSizeSmall.AppendFunction(updateSizeName);
        setMapSizeMedium.AppendFunction(updateSizeName);
        setMapSizeLarge.AppendFunction(updateSizeName);
        setMapSizeSmall.AppendFunction(back);
        setMapSizeMedium.AppendFunction(back);
        setMapSizeLarge.AppendFunction(back);

        List <AbstractMenuComposite> l2 = new List <AbstractMenuComposite> {
            play, test
        };
        AbstractMenuComposite menuTop = f.createSubmenu("Start Menu", l2);

        play.AddComponent(menuTop);
        test.AddComponent(menuTop);

        menuTop.ClickOperation();
    }