Exemple #1
0
        private void DrawActionbox(SpriteBatch a_spriteBatch, GameAssets a_gameAssets, ModelClasses.Game a_game)
        {
            //draws actionbox
            for (int y = 0; y < m_actionboxButtons.GetLength(0); y++)
            {
                for (int x = 0; x < m_actionboxButtons.GetLength(1); x++)
                {
                    if (a_game.m_player.m_focusedTarget != null)
                    {
                        //TEMP the real solution should use focusedUnit and depending on what it is, it will draw something different
                        a_spriteBatch.Draw(a_gameAssets.m_emptybox,
                                           m_actionboxButtons[x, y].m_rectangle,
                                           Color.White);

                        if (a_game.m_player.m_focusedTarget.m_moveBehavior != null)
                        {
                            a_spriteBatch.Draw(a_gameAssets.m_move,
                                               m_actionboxButtons[0, 0].m_rectangle,
                                               Color.White);

                            a_spriteBatch.Draw(a_gameAssets.m_hold,
                                               m_actionboxButtons[0, 1].m_rectangle,
                                               Color.White);

                            a_spriteBatch.Draw(a_gameAssets.m_hold,
                                               m_actionboxButtons[1, 0].m_rectangle,
                                               Color.White);
                        }

                        if (a_game.m_player.m_focusedTarget.m_type == ThingType.C_Cube)
                        {
                            a_spriteBatch.Draw(a_gameAssets.m_factory,
                                               m_actionboxButtons[0, 2].m_rectangle,
                                               Color.White);

                            a_spriteBatch.Draw(a_gameAssets.m_igloo,
                                               m_actionboxButtons[1, 2].m_rectangle,
                                               Color.White);

                            a_spriteBatch.Draw(a_gameAssets.m_factory,
                                               m_actionboxButtons[2, 2].m_rectangle,
                                               Color.White);
                        }
                        else if (a_game.m_player.m_focusedTarget.m_type == ThingType.C_Barrack)
                        {
                            if (a_game.m_player.m_focusedTarget.m_thingState != ThingState.BeingBuilt)
                            {
                                a_spriteBatch.Draw(a_gameAssets.m_barbarian,
                                                   m_actionboxButtons[0, 2].m_rectangle,
                                                   Color.White);

                                a_spriteBatch.Draw(a_gameAssets.m_cancel,
                                                   m_actionboxButtons[0, 0].m_rectangle,
                                                   Color.White);

                                a_spriteBatch.Draw(a_gameAssets.m_cancelAll,
                                                   m_actionboxButtons[1, 0].m_rectangle,
                                                   Color.White);

                                a_spriteBatch.Draw(a_gameAssets.m_cancelBuild,
                                                   m_actionboxButtons[2, 2].m_rectangle,
                                                   Color.White);
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
 private void HandleRotation()
 {
     mouse = GameAssets.ToMouseDirection(transform.position, Input.mousePosition);
     angle = Mathf.Atan2(mouse.y, mouse.x) * Mathf.Rad2Deg * Time.timeScale;
     transform.rotation = Quaternion.AngleAxis(angle - 180, Vector3.forward);
 }
 private void Awake()
 {
     instance = this;
 }
Exemple #4
0
    private void SpawnInitialPlaftorm()
    {
        Transform plaformTransform;

        plaformTransform = Instantiate(GameAssets.GetInstance().platform_ground_array[0].transform, new Vector3(0, 0, 0), Quaternion.identity);
        plaformTransform.transform.parent = GameObject.Find("Level").transform;

        PlatformControllerList = new List <PlatformController>();
        PlatformController platformController = new PlatformController(plaformTransform, GameAssets.GetInstance().platform_ground_array[0].tilemap);

        PlatformControllerList.Add(platformController);
    }
	static IList<Area> InstantiateAreas(Plot plot)
	{
		var areas = new List<Area>();


		// define a position to put the vertical road
		var randomVerticalRoadPosition = Random.Range(0, plot.Size.x -1);
		var leftExitPosition = Random.Range(0, plot.Size.y - 1);
		var rightExitPosition = Random.Range(0, plot.Size.y - 1);


		// loop into each possible Area
		for (int i = 0; i < plot.Size.x; i++)
		{
			for (int j = 0; j < plot.Size.y; j++)
			{
			AreaTypeEnum type;
			GameObject prefab = null;


			// add the road area type, the entrance and exit
			if (i == randomVerticalRoadPosition)
			{
				type = AreaTypeEnum.Road;
				if (j == 0 && plot.Exits[(int)ExitEnum.Bottom]) // first on bottom
				{
					var prefab1 = GameAssets.GetRandomPrefab(GameAssets.i.p_exit_bottom);
					areas.Add(new Area() { Position = new Vector2Int(i, j - 1), Type = type, Prefab = prefab1, IsEntrance = true });
				} else if (j == plot.Size.y - 1 && plot.Exits[(int)ExitEnum.Top]) // last on top
				{
					var prefab1 = GameAssets.GetRandomPrefab(GameAssets.i.p_exit_top);
					areas.Add(new Area() { Position = new Vector2Int(i, j + 1), Type = type, Prefab = prefab1, IsExit = true });
				}
			}
			else
			{
			// take a random take different of road
				do
				{
				type = (AreaTypeEnum)Random.Range(0, Enum.GetValues(typeof(AreaTypeEnum)).Length);
				} while (type == AreaTypeEnum.Road);
				}


				// get an random prefab based on the type
				if (type == AreaTypeEnum.Road)
				{
					prefab = GameAssets.GetRandomPrefab(GameAssets.i.p_verticalRoads);
				} else if (type == AreaTypeEnum.GreenArea)
				{
					prefab = GameAssets.GetRandomPrefab(GameAssets.i.p_smallGreenAreas);
				} else if (type == AreaTypeEnum.Building)
				{
					prefab = GameAssets.GetRandomPrefab(GameAssets.i.p_smallBuildings);
				}
				areas.Add(new Area() { Position = new Vector2Int(i, j), Type = type, Prefab = prefab });
			}
		}

		return areas;
		}
Exemple #6
0
 void Start() => i = this;
Exemple #7
0
 private void PlayerControl_OnDeath(object sender, System.EventArgs e)
 {
     Debug.Log("Death!");
     PlayerPrefs.SetInt("highScore", GameAssets.GetInstance().getScore());
     state = State.Dead;
 }
Exemple #8
0
 //Updates the save/load menus to populate new saves
 public void UpdateSlots(GameAssets a_assets, ModelClasses.Save a_save)
 {
     InitializeItems(a_assets, a_save);
 }
Exemple #9
0
    /**
     * Creating single pipe
     */
    private void CreatePipe(float height, float xPosition, bool createBottom)
    {
        Transform pipeHead = Instantiate(GameAssets.GetInstance().pfPipeHead);
        float     pipeHeadYPosition;

        if (createBottom)
        {
            pipeHeadYPosition = -CAMERA_ORTHO_SIZE + height - PIPE_HEAD_HEIGHT * .5f;
        }
        else
        {
            pipeHeadYPosition = +CAMERA_ORTHO_SIZE - height + PIPE_HEAD_HEIGHT * .5f;
        }
        pipeHead.position = new Vector3(xPosition, pipeHeadYPosition);

        Transform pipeBodySample = Instantiate(GameAssets.GetInstance().pfPipeMainSample);
        float     pipeBodySampleYPosition;
        float     pipeBodyYPosition;

        if (height < 16.7f)
        {
            if (createBottom)
            {
                pipeBodySampleYPosition = -CAMERA_ORTHO_SIZE;
            }
            else
            {
                pipeBodySampleYPosition   = +CAMERA_ORTHO_SIZE;
                pipeBodySample.localScale = new Vector3(1, -1, 1);
            }
            pipeBodySample.position = new Vector3(xPosition, pipeBodySampleYPosition);

            SpriteRenderer pipeBodySampleSpriteRenderer = pipeBodySample.GetComponent <SpriteRenderer>();
            pipeBodySampleSpriteRenderer.size = new Vector2(PIPE_WIDTH, height);

            BoxCollider2D pipeBodySampleBoxCollider = pipeBodySample.GetComponent <BoxCollider2D>();
            pipeBodySampleBoxCollider.size   = new Vector2(PIPE_WIDTH, height);
            pipeBodySampleBoxCollider.offset = new Vector2(0f, height * .5f);

            Pipe pipe = new Pipe(pipeHead, pipeBodySample, createBottom);
            pipeList.Add(pipe);
        }
        else
        {
            Transform pipeBody = Instantiate(GameAssets.GetInstance().pfPipeMain);
            if (createBottom)
            {
                pipeBodyYPosition       = -CAMERA_ORTHO_SIZE;
                pipeBodySampleYPosition = -CAMERA_ORTHO_SIZE + 16.7f;
            }
            else
            {
                pipeBodyYPosition         = +CAMERA_ORTHO_SIZE - 16.7f;
                pipeBodySampleYPosition   = +CAMERA_ORTHO_SIZE - 16.7f;
                pipeBodySample.localScale = new Vector3(1, -1, 1);
            }
            pipeBody.position       = new Vector3(xPosition, pipeBodyYPosition);
            pipeBodySample.position = new Vector3(xPosition, pipeBodySampleYPosition);

            SpriteRenderer pipeBodySpriteRenderer       = pipeBody.GetComponent <SpriteRenderer>();
            SpriteRenderer pipeBodySampleSpriteRenderer = pipeBodySample.GetComponent <SpriteRenderer>();
            pipeBodySpriteRenderer.size       = new Vector2(PIPE_WIDTH, 16.7f);
            pipeBodySampleSpriteRenderer.size = new Vector2(PIPE_WIDTH, height - 16.7f);

            BoxCollider2D pipeBodySampleBoxCollider = pipeBodySample.GetComponent <BoxCollider2D>();
            BoxCollider2D pipeBodyBoxCollider       = pipeBodySample.GetComponent <BoxCollider2D>();
            pipeBodyBoxCollider.size         = new Vector2(PIPE_WIDTH, 16.7f);
            pipeBodySampleBoxCollider.size   = new Vector2(PIPE_WIDTH, height - 16.7f);
            pipeBodyBoxCollider.offset       = new Vector2(0f, 16.7f * .5f);
            pipeBodySampleBoxCollider.offset = new Vector2(0f, (height - 16.7f) * .5f);

            Pipe pipe = new Pipe(pipeHead, pipeBodySample, pipeBody, createBottom);
            pipeList.Add(pipe);
        }
    }
        public static Arena Generate(GameAssets gameAssets, int seed, int biome_count)
        {
            // Prepare stuff
            Arena arena = new Arena(WIDTH, HEIGHT);

            arena.Biomes = new Biome[biome_count];
            arena.Seed   = seed;
            List <int>[] biome_tiles_list = new List <int> [biome_count];

            Random    rnd = new Random(seed);
            HaltonSet hlt = new HaltonSet(seed);    // halton sequence is used for generating evenly distributed points

            // generate temperature map
            double[] heatmap = GenerateNoise(seed, 3);
            for (int i = 0; i < arena.Heatmap.Length; i++)
            {
                arena.Heatmap[i] = (int)((heatmap[i] - 0.5) * 30 + 0.8 * (i % arena.Width));
            }

            // set locations of biome pivots
            for (int i = 0; i < biome_count; i++)
            {
                double halton2 = hlt.Seq2(i + 1);
                double halton3 = hlt.Seq3(i + 1);

                arena.Biomes[i]     = new Biome((int)(halton2 * arena.Width), (int)(halton3 * arena.Height));
                biome_tiles_list[i] = new List <int>();
            }

            // calc which tile belongs in which biome
            for (int i = 0; i < arena.Tiles.Length; i++)
            {
                Point tile_pos = new Point(i % arena.Width, i / arena.Width);

                int minDist2 = 40 * 40;
                int owner    = 0;

                // go thru all the pivots and pick the closest to current tile
                for (int p = 0; p < biome_count; p++)
                {
                    Point pivot = new Point(arena.Biomes[p].Pivot.X, arena.Biomes[p].Pivot.Y);

                    // add a bit of noise
                    Point noise = new Point((int)((rnd.NextDouble() - 0.5) * 2.5), (int)((rnd.NextDouble() - 0.5) * 2));
                    pivot += noise;

                    int dist2 = tile_pos.distanceSquared(pivot);
                    if (dist2 < minDist2)
                    {
                        minDist2 = dist2;
                        owner    = p;
                    }
                }

                biome_tiles_list[owner].Add(i);
            }

            // assign the calculated tiles to actual biomes
            for (int i = 0; i < biome_count; i++)
            {
                int pivotPos = arena.Biomes[i].Pivot.X + arena.Biomes[i].Pivot.Y * arena.Width;

                arena.Biomes[i].TilesOwned = biome_tiles_list[i].ToArray();
                arena.Biomes[i].Asset      = gameAssets.PickBiomeAmountBased(rnd, arena.Heatmap[pivotPos]);
            }

            // time to populate   *BIOMES*
            // (with tiles)
            for (int b = 0; b < biome_count; b++)
            {
                Biome      biome       = arena.Biomes[b];
                BiomeAsset biome_asset = gameAssets.BiomeAssets[biome.AssetName];

                List <TileAsset> special_tiles = new List <TileAsset>();
                foreach (TileAsset t in gameAssets.TileAssets.Values)
                {
                    if (t.SpawnDestinations.Length > 0 &&
                        t.SpawnDestinations.Where(a => a.Name == biome_asset.AssetName).Count() > 0)
                    {
                        special_tiles.Add(t);
                    }
                }

                for (int t = 0; t < biome.TilesOwned.Length; t++)
                {
                    Tile tile = biome_asset.GenerateTile(rnd);

                    // test, if current tile shouldn't be special tile
                    foreach (TileAsset ta in special_tiles)
                    {
                        SpawnDestination local = ta.SpawnDestinations.Where(a => a.Name == biome_asset.AssetName).First();

                        int amt = local.Amount.Evaluate(rnd);
                        if (amt > 0)
                        {
                            tile = ta.GenerateTile(rnd);
                        }
                    }

                    arena.Tiles[biome.TilesOwned[t]] = tile;
                }
            }

            // time to populate   *TILES*
            for (int i = 0; i < arena.Tiles.Length; i++)
            {
                Tile  tile      = arena.Tiles[i];
                Asset tileAsset = null;

                // tileAsset can be a regular biome asset or a special tile asset
                tileAsset = gameAssets.GetAssetByName(tile.AssetName);

                foreach (string spwnHere in tileAsset.SpawnsHere)
                {
                    // following asset will be spawned in current tile
                    SpawnableAsset assetToSpawn = (SpawnableAsset)gameAssets.GetAssetByName(spwnHere);

                    SpawnDestination local = assetToSpawn.SpawnDestinations.Where(a => a.Name == tile.AssetName).First();

                    if (assetToSpawn is ItemAsset)
                    {
                        int amt = local.Amount.Evaluate(rnd);
                    }
                }
            }

            return(arena);
        }
Exemple #11
0
        //Draws the buttons and checkboxes for respective screen
        private void DrawMenuItems(SpriteBatch a_spriteBatch, GameAssets a_gameAssets, Array a_array = null)
        {
            //The main menu hera you can start a game, load or change options
            if (m_menuState == MenuState.Main)
            {
                m_menu.Height = 350;

                foreach (Button button in a_array)
                {
                    DrawObject(a_spriteBatch, a_gameAssets.m_button, button.m_rectangle, Color.Transparent);
                    DrawString(a_spriteBatch, a_gameAssets.m_normalFont, button.m_rectangle, button.m_buttonText, Color.Red);
                }
            }
            //This screen is after you've pressed New Game and allows u to choose observe and fight
            else if (m_menuState == MenuState.PreGame)
            {
                m_menu.Height       = 200;
                m_ret.m_rectangle.X = m_observer.m_rectangle.Left;
                m_ret.m_rectangle.Y = m_observer.m_rectangle.Bottom + (padding * 2);

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_play.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_play.m_rectangle, m_play.m_buttonText, Color.Red);

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_observer.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_observer.m_rectangle, m_observer.m_buttonText, Color.Red);

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "To Main", Color.Red);
            }
            //This state is for the InGame menu That u open and close with f1
            else if (m_menuState == MenuState.InGameMenu)
            {
                m_menu.Height       = 350;
                m_ret.m_rectangle.X = m_menuButtons[4].m_rectangle.Left;
                m_ret.m_rectangle.Y = m_menuButtons[4].m_rectangle.Bottom + (padding * 2);

                foreach (Button button in a_array)
                {
                    DrawObject(a_spriteBatch, a_gameAssets.m_button, button.m_rectangle, Color.Transparent);
                    DrawString(a_spriteBatch, a_gameAssets.m_normalFont, button.m_rectangle, button.m_buttonText, Color.Red);
                }

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "Quit game", Color.Red);
            }
            //Where all options is and for now there is only one Menu here Debug for debug purposes
            else if (m_menuState == MenuState.Options)
            {
                m_menu.Height       = 350;
                m_ret.m_rectangle.Y = m_menu.Bottom - (padding * 4);

                foreach (Button button in a_array)
                {
                    DrawObject(a_spriteBatch, a_gameAssets.m_button, button.m_rectangle, Color.Transparent);
                    DrawString(a_spriteBatch, a_gameAssets.m_normalFont, button.m_rectangle, button.m_buttonText, Color.Red);
                }

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "To Menu", Color.Red);
            }
            //This screen holds options to help debugging while ingame
            else if (m_menuState == MenuState.DebugMenu)
            {
                m_menu.Height       = 410;
                m_ret.m_rectangle.Y = m_menu.Bottom - (padding * 4);

                foreach (CheckBox checkbox in a_array)
                {
                    if (checkbox.m_state == CheckBox.ChkState.Checked)
                    {
                        DrawObject(a_spriteBatch, a_gameAssets.m_checked, checkbox.m_rectangle, Color.White);
                    }
                    else
                    {
                        DrawObject(a_spriteBatch, a_gameAssets.m_emptybox, checkbox.m_rectangle, Color.White);
                    }

                    DrawString(a_spriteBatch, a_gameAssets.m_smallFont, checkbox.m_rectangle, checkbox.m_checkBoxText, Color.Red);
                }

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "To Options", Color.Red);
            }
            //This menu is where u save your current game and is only accesible while playing the game
            else if (m_menuState == MenuState.Save)
            {
                m_menu.Height       = 390;
                m_ret.m_rectangle.X = m_saves[4].m_rectangle.Left;
                m_ret.m_rectangle.Y = m_menu.Bottom - (padding * 4);

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_newSave.m_rectangle, Color.Transparent);

                DrawObject(a_spriteBatch, a_gameAssets.m_up, m_Sup.m_rectangle, Color.White);
                DrawObject(a_spriteBatch, a_gameAssets.m_down, m_Sdown.m_rectangle, Color.White);

                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_newSave.m_rectangle, m_newSave.m_buttonText, Color.Red);

                foreach (Button item in a_array)
                {
                    DrawObject(a_spriteBatch, a_gameAssets.m_button, item.m_rectangle, Color.Transparent);

                    DrawString(a_spriteBatch, a_gameAssets.m_normalFont, item.m_rectangle, item.m_buttonText, Color.Red);
                }

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "To Menu", Color.Red);
            }
            //The Load Menu
            else if (m_menuState == MenuState.Load)
            {
                m_menu.Height       = 380;
                m_ret.m_rectangle.X = m_loaded[4].m_rectangle.Left;
                m_ret.m_rectangle.Y = m_menu.Bottom - (padding * 4);

                DrawObject(a_spriteBatch, a_gameAssets.m_up, m_Lup.m_rectangle, Color.White);
                DrawObject(a_spriteBatch, a_gameAssets.m_down, m_Ldown.m_rectangle, Color.White);

                foreach (Button item in a_array)
                {
                    DrawObject(a_spriteBatch, a_gameAssets.m_button, item.m_rectangle, Color.Transparent);

                    DrawString(a_spriteBatch, a_gameAssets.m_normalFont, item.m_rectangle, item.m_buttonText, Color.Red);
                }

                DrawObject(a_spriteBatch, a_gameAssets.m_background, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "To Menu", Color.Red);
            }
            //The screen that comes upp after youv'e won
            else if (m_menuState == MenuState.Win)
            {
                m_menu.Height       = 200;
                m_ret.m_rectangle.Y = m_menu.Bottom - (padding * 5);

                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_menu, "You Won!", Color.Red);

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "OK!", Color.Red);
            }
            //The screen that comes upp after youv'e lost
            else if (m_menuState == MenuState.Lose)
            {
                m_menu.Height       = 200;
                m_ret.m_rectangle.Y = m_menu.Bottom - (padding * 5);

                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_menu, "You Lose!", Color.Red);

                DrawObject(a_spriteBatch, a_gameAssets.m_button, m_ret.m_rectangle, Color.Transparent);
                DrawString(a_spriteBatch, a_gameAssets.m_normalFont, m_ret.m_rectangle, "OK!", Color.Red);
            }
        }
Exemple #12
0
 public static void setInstance(GameAssets gameAssets)
 {
     instance = gameAssets;
 }
Exemple #13
0
 private void DrawHUDBackground(SpriteBatch a_spriteBatch, GameAssets a_gameAssets)
 {
     //TEMP to see the HUD area
     a_spriteBatch.Draw(a_gameAssets.m_button, m_area, Color.Black);
 }
Exemple #14
0
        //Draws a selected units stats
        private void DrawInfo(SpriteBatch a_spriteBatch, GameAssets a_gameAssets, ModelClasses.Player a_player)
        {
            //TEMP to see the info area  - I c wut u did thar /Tiger!
            a_spriteBatch.Draw(a_gameAssets.m_button, m_infoArea, Color.Violet);

            if (a_player.m_focusedTarget != null)
            {
                //Format text
                string f_info = string.Format("HP: {0}/{1}\n",
                                              a_player.m_focusedTarget.HP,
                                              a_player.m_focusedTarget.m_maxHP);

                if (a_player.m_focusedTarget.m_builtTimer < a_player.m_focusedTarget.m_requiredBuildTime)
                {
                    m_buildProgress.SetProgress(a_player.m_focusedTarget.m_builtTimer / a_player.m_focusedTarget.m_requiredBuildTime);

                    string f_buildingInfo = string.Format("{0:0.0} / {1:0.0} {2:0.0}% \nBuilding: {3}", a_player.m_focusedTarget.m_builtTimer,
                                                          a_player.m_focusedTarget.m_requiredBuildTime, m_buildProgress.Percentage * 100, GetUnitName(a_player.m_focusedTarget.m_type));

                    a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_rectangle, Color.DarkGray);
                    a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_progressArea, Color.Green);

                    a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_buildingInfo, m_buildInfo, Color.White);
                }

                //Special hud info for special types, like extractor needs to write how many sols it has left
                switch (a_player.m_focusedTarget.m_type)
                {
                case ModelClasses.Units.ThingType.C_Extractor:
                    Extractor f_tempExtractor = (Extractor)a_player.m_focusedTarget;
                    if (f_tempExtractor.m_SoL != null && f_tempExtractor.m_SoL.m_resources >= 0)
                    {
                        f_info += "SoLs: " + f_tempExtractor.m_SoL.m_resources;
                    }
                    else
                    {
                        f_info += "SoLs: Depleted";
                    }
                    break;
                }

                if (a_player.m_focusedTarget.m_buildBehavior != null)
                {
                    if (a_player.m_focusedTarget.m_buildBehavior.IsBuilding())
                    {
                        ThingType f_type = a_player.m_focusedTarget.m_buildBehavior.GetBuildingType();
                        float     a_requiredBuildTime = a_player.m_thingsAssets.GetThing(f_type).m_requiredBuildTime;

                        m_buildProgress.SetProgress(a_player.m_focusedTarget.m_buildBehavior.GetBuildTimer() / a_requiredBuildTime);

                        string f_buildingInfo = string.Format("Building: {0}\n{1:0.0} / {2:0.0} {3:0.0}% ", HUD.GetUnitName(f_type), a_player.m_focusedTarget.m_buildBehavior.GetBuildTimer(), a_requiredBuildTime, m_buildProgress.Percentage * 100);

                        a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_rectangle, Color.DarkGray);
                        a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_progressArea, Color.Green);

                        a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_buildingInfo, m_buildInfo, Color.White);
                    }

                    if (a_player.m_focusedTarget.m_buildBehavior is ModelClasses.BehaviorInterfaces.StandardBuild)
                    {
                        f_info += "Workers: " + a_player.m_focusedTarget.m_buildBehavior.GetSacrificeCount();
                    }
                }

                //Checks if the attack behavior is null or not! to write out that data!
                if (a_player.m_focusedTarget.m_attackBehavior != null)
                {
                    f_info += string.Format("Damage: {0} \nRange: {1}", a_player.m_focusedTarget.m_attackBehavior.GetDamage(), a_player.m_focusedTarget.m_attackBehavior.GetAttackRange());
                }

                if (a_player.m_selectedThings.Count > 1)
                {
                    //Should have draw portraits or something here instead, just temp stuff.. I wanna see selected info!!!
                    //Extremely temp code
                    if (a_player.m_focusedTarget.m_isUnit)
                    {
                        string f_selectedInfo = string.Format("Units selected: {0}", a_player.m_selectedThings.Count);
                        a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_selectedInfo, new Vector2(m_infoAreaPadded.X + m_infoArea.Width * 0.5f, m_area.Bottom - 45), Color.White);
                    }
                    else
                    {
                        string f_selectedInfo = string.Format("Buildings selected: {0}", a_player.m_selectedThings.Count);
                        a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_selectedInfo, new Vector2(m_infoAreaPadded.X + m_infoArea.Width * 0.5f, m_area.Bottom - 45), Color.White);
                    }
                }

                //Draw text
                a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_info, m_infoAreaPadded, Color.White);
            }
            else if (a_player.m_selectedWorldObject != null)
            {
                if (a_player.m_selectedWorldObject.m_type == WorldObjectType.SoL)
                {
                    //Creates a sol variable to access the SoL variables
                    SoL f_SoL = (SoL)a_player.m_selectedWorldObject;

                    string f_info = string.Format("SoLs: {0}", f_SoL.m_resources);

                    a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_info, m_infoAreaPadded, Color.White);
                }
            }
        }
Exemple #15
0
    /*Função responsável por criar os nossos Pipes(Obstaculos) com uma certa altura, posição no x
     * e em cima ou em baixo*/
    private void CreatePip(float height, float xPos, bool CreateBottom)
    {
        /*Inicializamos as variaveis que guardam a posição do pipeHead e pipeBody que se encontram na classe GameAssets*/
        Transform PipeHead = Instantiate(GameAssets.GetInstance().PipeHead_Pref);

        float PipeHeadYPos;//variavel responsavel por guardar a posicao no y do nosso sprite PipeHead
        float offset = 0.1f;

        if (CreateBottom)
        {
            /*Vamos criar em baixo se estiver true*/
            PipeHeadYPos = -CAMERA_ORTHO_SIZE + height + (PIPEHEAD_HEIGHT * 0.5f - offset);
        }
        else
        {
            /*Vamos criar em cima se estiver falso*/
            PipeHeadYPos = +CAMERA_ORTHO_SIZE - height - (PIPEHEAD_HEIGHT * 0.5f - offset);
        }

        /*A pipeHead vai ter de ser posicionada da seguinte forma:
         * Dependendo da orientação do pipe se é bottom ou upwards
         * ao comprimento total do cano principal somamos ou subtraimos por metade
         * do comprimento da cabeça do pipe (PIPE_HEAD)*/
        PipeHead.position = new Vector3(xPos, PipeHeadYPos);


        /*********************CANO PRINCIPAL******************/
        Transform PipeBody = Instantiate(GameAssets.GetInstance().Pipe_Pref);
        float     PipeBodyYPos;

        if (CreateBottom)
        {
            /*Vamos criar no bottom se estiver true*/
            PipeBodyYPos = -CAMERA_ORTHO_SIZE;
        }
        else
        {
            /*Vamos criar em cima se estiver falso*/
            PipeBodyYPos = +CAMERA_ORTHO_SIZE;

            /*Como o pivot esta definido no bottom temos de invertir
             * para o pipe não sair do screen*/
            PipeBody.localScale = new Vector3(1, -1, 1);
        }
        PipeBody.position = new Vector3(xPos, PipeBodyYPos);


        SpriteRenderer pipeBodySpriteRenderer = PipeBody.GetComponent <SpriteRenderer>();

        /*Estamos a definir a altura do PipeBody no DrawMode -> Size do SpriteRenderer do PipeBody*/
        pipeBodySpriteRenderer.size = new Vector2(PIPE_WIDTH, height);

        /*Definimos que o BoxCollider tenha a mesma altura que o PipeBody e a mesma Width*/
        PipeBody.GetComponent <BoxCollider2D>().size = new Vector2(PIPE_WIDTH, height);

        /*Uma vez que o pivot do spite do PipeBody se encontra no bottom o box collider vai ter como origem
         * aquele pivot por isso que não vai ficar direito o box collider, para contornar este problema adicionamos
         * um offset de metade da altura para assim compensar.*/
        PipeBody.GetComponent <BoxCollider2D>().offset = new Vector2(0f, height / 2);



        Pipe pipe_obj = new Pipe(PipeHead, PipeBody, CreateBottom);

        PipeList.Add(pipe_obj);
    }
Exemple #16
0
 private void Start()
 {
     i = this;
 }
 private IEnumerator InitUIFramework()
 {
     yield return(GameAssets.LoadAssetAsync <GameObject>("load_preload$s_ui$ui_root.assetbundle", "UI_Root", InitUIFrameworkInternal));
 }
Exemple #18
0
 public void Awake()
 {
     i = this;
 }
Exemple #19
0
    // This method spawns an obstacle
    private void spawnObstacle(float xPos)
    {
        SetDifficulty(GetDifficulty());
        int obstacleType = Random.Range(1, 6);

        Debug.Log("Current Difficulty: " + GetDifficulty());

        // Obstacles to jump over
        if (obstacleType == 1 || obstacleType == 4)
        {
            Transform jumpObstacle;
            float     yPos;
            bool      running;
            if (obstacleType == 1)
            {
                jumpObstacle = Instantiate(GameAssets.GetInstance().jumpObsBody);
                yPos         = -3.5f;
                running      = false;
            }
            else
            {
                jumpObstacle = Instantiate(GameAssets.GetInstance().jumpObs2Body);
                yPos         = -4f;
                running      = true;
            }

            jumpObstacle.position = new Vector3(xPos, yPos); // Initial position for obstacle
            obstacleList.Add(new Obstacle(jumpObstacle, running));
        }


        // Obstacles to dive through
        if (obstacleType == 2)
        {
            Transform diveObstacle = Instantiate(GameAssets.GetInstance().diveObsBody);
            diveObstacle.position = new Vector3(xPos, -1.7f); // Initial position for obstacle
            obstacleList.Add(new Obstacle(diveObstacle, false));
            if (GetDifficulty() == Difficulty.Hard || GetDifficulty() == Difficulty.Hardest)
            {
                spawnTimer += 1f;
            }
        }

        // Obstacles to duck under
        if (obstacleType == 3 || obstacleType == 5)
        {
            Transform duckObstacle;
            float     yPos;
            bool      moving;
            if (obstacleType == 3)
            {
                duckObstacle = Instantiate(GameAssets.GetInstance().duckObsBody);
                yPos         = -3.5f;
                moving       = false;
            }
            else
            {
                duckObstacle = Instantiate(GameAssets.GetInstance().duckObs2Body);
                yPos         = 0f;
                moving       = true;
            }

            //duckObstacle.position = new Vector3(xPos, -2.0f); // Initial position for obstacle
            duckObstacle.position = new Vector3(xPos, yPos); // Initial position for obstacle
            obstacleList.Add(new Obstacle(duckObstacle, moving));
        }
    }
Exemple #20
0
 private void Awake()
 {
     spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
     gameAssets     = GameAssets.Instance;
     Idle(new Vector3(0, -1));
 }
    void CreateVisualTree()
    {
        string[] guids = AssetDatabase.FindAssets("t:GameAssets");
        //foreach (string guid in guids)
        //{
        //    //Debug.Log("ScriptObj: " + AssetDatabase.GUIDToAssetPath(guid));
        //}

        if (guids != null && guids.Length > 0)
        {
            //allGameAssets = ScriptableObject.CreateInstance<GameAssets>();
            allGameAssets = (GameAssets)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guids[0]), typeof(GameAssets));
        }
        else
        {
            if (AssetDatabase.IsValidFolder("Assets/Export"))
            {
                //Debug.Log("Exists");
            }
            else
            {
                string ret;

                ret = AssetDatabase.CreateFolder("Assets", "Export");
                if (AssetDatabase.GUIDToAssetPath(ret) != "")
                {
                    Debug.Log("Folder asset created");
                }
                else
                {
                    Debug.Log("Couldn't find the GUID for the path");
                }
            }
            AssetDatabase.Refresh();
            if (AssetDatabase.IsValidFolder("Assets/Export/Assets"))
            {
                //Debug.Log("Exists");
            }
            else
            {
                string ret;

                ret = AssetDatabase.CreateFolder("Assets/Export", "Assets");
                if (AssetDatabase.GUIDToAssetPath(ret) != "")
                {
                    Debug.Log("Folder asset created");
                }
                else
                {
                    Debug.Log("Couldn't find the GUID for the path");
                }
            }
            if (AssetDatabase.IsValidFolder("Assets/Export/Assets/Data"))
            {
                //Debug.Log("Exists");
            }
            else
            {
                string ret;

                ret = AssetDatabase.CreateFolder("Assets/Export/Assets", "Data");
                if (AssetDatabase.GUIDToAssetPath(ret) != "")
                {
                    Debug.Log("Folder asset created");
                }
                else
                {
                    Debug.Log("Couldn't find the GUID for the path");
                }
            }
            AssetDatabase.Refresh();
            allGameAssets = ScriptableObject.CreateInstance <GameAssets>();
            AssetDatabase.CreateAsset(allGameAssets, "Assets/Export/Data/allGameAssets.asset");
        }


        var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/EditorComponents/AssetManager.uxml");
        var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Editor/LevelEditorWindow.uss");

        assetManager = visualTree.CloneTree();

        addAssetContainer = assetManager.Q <Box>("addAssetContainer");

        //search field
        var popupSearchField = new ToolbarSearchField();

        popupSearchField.AddToClassList("asset-manager-searchfield");
        popupSearchField.RegisterValueChangedCallback(OnSearchTextChanged);

        assetTypeSelection = new EnumField(AssetType.Texture);
        assetTypeSelection.RegisterValueChangedCallback(AssetTypeChange);

        assetSelectionField = new ObjectField {
            objectType = typeof(UnityEngine.Texture)
        };

        addAssetButton      = new Button();
        addAssetButton.text = "Add Asset";
        addAssetButton.RegisterCallback <MouseUpEvent>(AddAsset);

        saveAssetsButton      = new Button();
        saveAssetsButton.text = "Export All Assets";
        saveAssetsButton.RegisterCallback <MouseUpEvent>(SaveAssets);

        assetListBox = new Box();
        assetListBox.style.height = 777;

        assetListBoxContainer = new ScrollView();
        assetListBoxContainer.showHorizontal = false;
        assetListBox.Add(assetListBoxContainer);

        addAssetContainer.Add(popupSearchField);
        addAssetContainer.Add(assetTypeSelection);
        addAssetContainer.Add(assetSelectionField);
        addAssetContainer.Add(addAssetButton);
        addAssetContainer.Add(assetListBox);
        addAssetContainer.Add(saveAssetsButton);

        #region LoadAssetsFromAssetData
        foreach (Texture t in allGameAssets.gameTextures)
        {
            assetListBoxContainer.Add(CreateAsset(t.name));
        }
        foreach (AudioClip ac in allGameAssets.gameAudioClips)
        {
            assetListBoxContainer.Add(CreateAsset(ac.name));
        }
        foreach (Font f in allGameAssets.gameFonts)
        {
            assetListBoxContainer.Add(CreateAsset(f.name));
        }
        #endregion
    }
Exemple #22
0
 void Awake()
 {
     _instance = this;
 }
Exemple #23
0
    private void SpawnPlaftorm(float xPos, float yPos, int platform)
    {
        Transform plaformTransform;

        plaformTransform = Instantiate(GameAssets.GetInstance().platform_ground_array[platform].transform, new Vector3(20, yPos, 0), Quaternion.identity);
        plaformTransform.transform.parent = GameObject.Find("Level").transform;

        PlatformController platformController = new PlatformController(plaformTransform, GameAssets.GetInstance().platform_ground_array[platform].tilemap);

        PlatformControllerList.Add(platformController);
        plaformTransform.position = new Vector3((xPos + platformController.GetWidth() / 2), yPos, 0);
        // print("ADDED");
    }
Exemple #24
0
    public void RenderSnake()
    {
        if (Dead)
        {
            return;
        }

        // DRAW TAIL
        LinkedListNode <SnakeBody> node = Bodies.Last;

        Material   mat = IsPlayer ? GameAssets.Material.Player : GameAssets.GetTierMaterial(Tier);
        Mesh       mesh;
        Quaternion quat;

        if (node != null)
        {
            while (node != null)
            {
                // DRAW SNAKE TRAIL LINE
                switch (node.Value.FacingHead)
                {
                case MoveDir.Right:
                    quat = Quaternion.identity;
                    break;

                case MoveDir.Up:
                    quat = Quaternion.Euler(0, 0, 90f);
                    break;

                case MoveDir.Left:
                    quat = Quaternion.Euler(0, 0, 180f);
                    break;

                case MoveDir.Down:
                    quat = Quaternion.Euler(0, 0, 270f);
                    break;

                default:
                    quat = Quaternion.identity;
                    Debug.LogError("Drawing snake trace line: Invalid Facing direction detected");
                    break;
                }

                GameController.DrawMeshOnGrid(GameController.Meshes["SnakeLineMesh"], GameAssets.Material.Line, node.Value.Position, quat);


                // DRAW SNAKE BODY

                Mesh OutlineMesh;
                if (node.Value.Engorged)
                {
                    mesh        = GameController.Meshes["EngorgedMesh"];
                    OutlineMesh = GameController.Meshes["SnakeEngorgedBodyOutline"];
                }
                else
                {
                    mesh        = GameController.Meshes["SnakeBody"];
                    OutlineMesh = GameController.Meshes["SnakeBodyOutline"];
                }

                GameController.DrawMeshOnGrid(mesh, mat, node.Value.Position, Quaternion.identity);

                if (!IsPlayer)
                {
                    // DRAW ENEMY SNAKE OUTLINE
                    Material OutlineMaterial = GameAssets.Material.EnemyOutline;
                    GameController.DrawMeshOnGrid(OutlineMesh, OutlineMaterial, node.Value.Position, Quaternion.Euler(0f, 0f, 0f));
                    GameController.DrawMeshOnGrid(OutlineMesh, OutlineMaterial, node.Value.Position, Quaternion.Euler(0f, 0f, 90f));
                    GameController.DrawMeshOnGrid(OutlineMesh, OutlineMaterial, node.Value.Position, Quaternion.Euler(0f, 0f, 180f));
                    GameController.DrawMeshOnGrid(OutlineMesh, OutlineMaterial, node.Value.Position, Quaternion.Euler(0f, 0f, 270f));
                }

                if (node.Value.Engorged)
                {
                    // DRAW EATEN MATERIAL
                    Material EatenMat;
                    if (node.Value.Digestion == SnakeBody.FoodType.Food)
                    {
                        EatenMat = GameAssets.Material.Food;
                    }
                    else
                    {
                        EatenMat = GameAssets.GetTierMaterial(node.Value.FoodTier);
                    }
                    GameController.DrawMeshOnGrid(GameController.Meshes["ArenaSquareMesh"], EatenMat, node.Value.Position, Quaternion.Euler(0f, 0f, 0f));
                }

                node = node.Previous;
            }
        }

        switch (Facing)
        {
        case MoveDir.Right:
            quat = Quaternion.identity;
            break;

        case MoveDir.Up:
            quat = Quaternion.Euler(0, 0, 90f);
            break;

        case MoveDir.Left:
            quat = Quaternion.Euler(0, 0, 180f);
            break;

        case MoveDir.Down:
            quat = Quaternion.Euler(0, 0, 270f);
            break;

        default:
            quat = Quaternion.identity;
            Debug.LogError("Drawing snake trace line: Invalid Facing direction detected");
            break;
        }

        // DRAW HEAD
        if (!Dying)
        {
            GameController.DrawMeshOnGrid(GameController.Meshes["SnakeHeadMesh"], mat, HeadPosition, quat);
            GameController.DrawMeshOnGrid(GameController.Meshes["SnakeSnoutOutline"], GameAssets.Material.EnemyOutline, HeadPosition, quat);
        }
    }
Exemple #25
0
    public static void ChangeApplicationColorTheme(ColorTheme newTheme)
    {
        switch (newTheme)
        {
        case ColorTheme.Blue:
        {
            const string blueThemeXamlPath = "/UserInterface/Styles/Themes/Blue.xaml";

            var newDict = new ResourceDictionary
            {
                Source = new Uri(blueThemeXamlPath, UriKind.Relative)
            };

            foreach (var mergedDict in newDict.MergedDictionaries)
            {
                Application.Current.Resources.MergedDictionaries.Add(mergedDict);
            }

            foreach (var key in newDict.Keys)
            {
                Application.Current.Resources[key] = newDict[key];
            }

            break;
        }

        case ColorTheme.Orange:
        {
            const string orangeThemeXamlPath = "/UserInterface/Styles/Themes/Orange.xaml";

            var newDict = new ResourceDictionary
            {
                Source = new Uri(orangeThemeXamlPath, UriKind.Relative)
            };

            foreach (var mergedDict in newDict.MergedDictionaries)
            {
                Application.Current.Resources.MergedDictionaries.Add(mergedDict);
            }

            foreach (var key in newDict.Keys)
            {
                Application.Current.Resources[key] = newDict[key];
            }

            break;
        }

        case ColorTheme.Pink:
        {
            const string pinkThemeXamlPath = "/UserInterface/Styles/Themes/Pink.xaml";

            var newDict = new ResourceDictionary
            {
                Source = new Uri(pinkThemeXamlPath, UriKind.Relative)
            };

            foreach (var mergedDict in newDict.MergedDictionaries)
            {
                Application.Current.Resources.MergedDictionaries.Add(mergedDict);
            }

            foreach (var key in newDict.Keys)
            {
                Application.Current.Resources[key] = newDict[key];
            }

            break;
        }
        }

        GameAssets.RefreshPages();
    }
Exemple #26
0
 public static void LoadBundleGB(string assetBundleName, string assetName, LuaTable instance, Action <GameObject> OnLoadDone)
 {
     Game.StartCoroutine(GameAssets.LoadAssetAsync <GameObject>(assetBundleName, assetName, OnLoadDone));
 }
Exemple #27
0
 private void Awake()
 {
     i = this;
 }
Exemple #28
0
 void Awake()
 {
     gameAssets = this;
 }
Exemple #29
0
 public void Awake()
 {
     instance = this;
 }
Exemple #30
0
 void Start()
 {
     i = this;
 }