public void CreateViewObject(WorldView view) { switch(view) { case WorldView.Agent: if( m_agentViewPrefab != null) m_gameObject = UnityEngine.GameObject.Instantiate(m_agentViewPrefab) as GameObject; break; case WorldView.Admin: if( m_adminViewPrefab != null) m_gameObject = UnityEngine.GameObject.Instantiate(m_adminViewPrefab) as GameObject; break; } if(m_gameObject == null) { Debug.LogError("Failed to create " + System.Enum.GetName(typeof(WorldView), GameFlow.Instance.View) + " for type: " + name); return; } m_viewObject = m_gameObject.GetComponent<WorldViewObject>(); if(m_viewObject == null) { Debug.LogError("Cannot add view of type: " + m_gameObject.name + " as the type does not contain a WorldViewObject script"); m_gameObject = null; return; } m_viewObject.SetWorldObject(this); //m_gameObject.name = ; m_gameObject.transform.parent = transform; m_gameObject.transform.position = transform.position; m_gameObject.transform.rotation = transform.rotation; }
void BergSkillTree() { this.currentWorldView = WorldView.Berg; GUI.Box(new Rect(0,10,250,90), "Great at taking a hit. \n Your go to tank."); if (GUI.Button (new Rect (20,Screen.height - 50,200,50), "Back")){ Armory(); } }
void ClarkSkillTree() { this.currentWorldView = WorldView.Clark; GUI.Box(new Rect(0,10,250,90), "Well rounded fighter. \n Can both dish out and absorb damage."); if (GUI.Button (new Rect (20,Screen.height - 50,200,50), "Back")){ Armory(); } }
void DaleSkillTree() { this.currentWorldView = WorldView.Dale; GUI.Box(new Rect(0,10,250,90), "Jack of all trades. \n Good blend of mobility and durability"); if (GUI.Button (new Rect (20,Screen.height - 50,200,50), "Back")){ Armory(); } }
//add a box with gui text explaining the characters strengths and weaknesses void AceSkillTree() { this.currentWorldView = WorldView.Ace; GUI.Box(new Rect(0,10,250,90), "A fast, high damage striker. " + "\n"+ "Great for taking out enimies," +"\n"+"but suffers from glass canon syndrome."); if (GUI.Button (new Rect (20,Screen.height - 50,200,50), "Back")){ Armory(); } }
private Tuple<Activity, Behaviour> ReturnHome(WorldView state) { int dx = state.Location.X < home.X ? 1 : (state.Location.X > home.X ? -1 : 0); int dy = state.Location.Y < home.Y ? 1 : (state.Location.Y > home.Y ? -1 : 0); if (dx == 0 && dy == 0) { return Do.DropOff<Wood>(me.Carrying<Wood>()).Then(CollectWood); } return Move.By(dx, dy).Then(ReturnHome); }
public BuildNewBase() { AddControl(new Background(Backgrounds.Geoscape, 0)); worldView = new WorldView(OnChooseLocation); AddControl(worldView); AddControl(new WorldControls(worldView)); AddControl(new Border(0, 0, 256, 28, ColorScheme.Green, Backgrounds.Title, 0)); AddControl(new Label(10, 8, "SELECT SITE FOR NEW BASE", Font.Normal, ColorScheme.Green)); if (GameState.Current.Data.Bases.Count > 0) AddControl(new Button(8, 186, 53, 12, "CANCEL", ColorScheme.Green, Font.Normal, OnCancel)); AddControl(new TimeDisplay()); }
public SelectDestination(Craft craft) { this.craft = craft; AddControl(new Background(Backgrounds.Geoscape, 0)); worldView = new WorldView(OnChooseDestination); AddControl(worldView); AddControl(new WorldControls(worldView)); AddControl(new Border(0, 0, 256, 28, ColorScheme.Green, Backgrounds.Title, 0)); AddControl(new Label(10, 8, "SELECT DESTINATION", Font.Normal, ColorScheme.Green)); AddControl(new Button(8, 110, 53, 12, "CANCEL", ColorScheme.Aqua, Font.Normal, OnCancel)); AddControl(new TimeDisplay()); }
public override void Act(Actor actor, WorldView world) { if (destination != null) { dx = world.Location.X < destination.X ? 1 : world.Location.X > destination.X ? -1 : 0; dy = world.Location.Y < destination.Y ? 1 : world.Location.Y > destination.Y ? -1 : 0; } Location newLocation = world.Location.Offset(dx, dy); if (world.IsAccessibleTo(newLocation, actor)) { world.MoveTo(newLocation); } }
public Geoscape() { AddControl(new Background(Backgrounds.Geoscape, 0)); AddControl(new Button(0, 257, 63, 11, "INTERCEPT", ColorScheme.Blue, Font.Small, OnIntercept)); AddControl(new Button(12, 257, 63, 11, "BASES", ColorScheme.Blue, Font.Small, OnBases)); AddControl(new Button(24, 257, 63, 11, "GRAPHS", ColorScheme.Blue, Font.Small, OnGraphs)); AddControl(new Button(36, 257, 63, 11, "UFOPAEDIA", ColorScheme.Blue, Font.Small, OnUfoPaedia)); AddControl(new Button(48, 257, 63, 11, "OPTIONS", ColorScheme.Blue, Font.Small, OnOptions)); AddControl(new Button(60, 257, 63, 11, "FUNDING", ColorScheme.Blue, Font.Small, OnFunding)); AddControl(new TimeDisplay()); AddControl(gameSpeed); worldView = new WorldView(OnClick); AddControl(worldView); AddControl(new WorldControls(worldView)); }
public Tuple<Activity, Behaviour> CollectWood(WorldView state) { if (state.Location != home && state.CanCollect<Wood>() > 0) { lastWoodSource = state.Location; return Do.Collect<Wood>().Then(ReturnHome); } if (state.CanHarvest<Wood>() > 0) { return Do.Harvest<Wood>().Then(CollectWood); } if (lastWoodSource != null && lastWoodSource != state.Location) { return Move.Towards(lastWoodSource).Then(CollectWood); } lastWoodSource = null; return FindWood(state); }
void Armory() { this.currentWorldView = WorldView.Armory; if(GUI.Button(new Rect(20,40,200,20), "Ace")) { AceSkillTree(); } // Make the second button. if(GUI.Button(new Rect(20,70,200,20), "Berg")) { BergSkillTree(); } if(GUI.Button(new Rect(20,100,200,20), "Clark")) { ClarkSkillTree(); } if(GUI.Button(new Rect(20,130,200,20), "Dale")) { DaleSkillTree(); } if (GUI.Button (new Rect (20,Screen.height - 50,200,50), "Back")){ MenuGUI(); } }
private Tuple<Activity, Behaviour> FindWood(WorldView state) { return Tuple.Create((Activity)Move.By(Random.Next(-1, 2), Random.Next(-1, 2)), new Behaviour(CollectWood)); }
/// <summary> /// Creates a new GameView and its subcomponents. /// </summary> /// <param name="model">The assigned GameModel.</param> /// <returns>The created GameView.</returns> public GameView BuildView(GameModel model) { WorldView worldView = new WorldView(model.World); GameView gameView; int i = 0; // to count the planets in the list of world objects foreach (WorldObject worldObject in model.World.WorldObjects) { if (worldObject is Spaceship) { Player player = GetPlayerOfSpaceship(model, (Spaceship)worldObject); worldView.AddWorldObjectView(new WorldObjectView(gameAssets.GetColoredSpaceship(player.PlayerColor), worldObject)); } else if (worldObject is Planet) { worldView.AddWorldObjectView(new WorldObjectView(gameAssets.GetModelPlanets()[i % gameAssets.GetModelPlanets().Length], worldObject)); i++; } else if (worldObject is Projectile) { worldView.AddWorldObjectView(new WorldObjectView(gameAssets.ModelRocket, worldObject)); } } gameView = new GameView(model, worldView); return gameView; }
/// <summary> /// Creates a new GameView object. /// </summary> /// <param name="gameModel">The assigned GameModel..</param> /// <param name="worldView">The view of the World.</param> public GameView(GameModel gameModel, WorldView worldView) { this.gameModel = gameModel; this.worldView = worldView; }
void MenuGUI() { this.currentWorldView = WorldView.Menu; // Make a background box //GUI.Box(new Rect(100,100,100,90), "Loader Menu"); // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed if(GUI.Button(new Rect(20,40,200,20), "Level 1: The Invasion Begins")) { Application.LoadLevel(1); } // Make the second button. if(GUI.Button(new Rect(20,70,200,20), "Level 2: The Sinking Forest")) { Application.LoadLevel(2); } if(GUI.Button(new Rect(20,100,200,20), "SideQuest: Twin Bridges")) { Application.LoadLevel(3); } if (GUI.Button (new Rect (20,Screen.height - 50,200,50), "Armory")){ Armory (); } }
/// <summary> /// Draw a line in the scene in 3D but scale it such that it appears as a 2D line in the view. /// If drawing lots of lines call with a pre-calculated clipping frustum. /// </summary> /// <param name="world"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="color"></param> /// <param name="doDepthTest"></param> /// <param name="width"></param> public static void Render3DLine(this WorldView world, Vector3 start, Vector3 end, Color color, bool doDepthTest = true, double width = 1) { world.Render3DLine(world.GetClippingFrustum(), start, end, color, doDepthTest, width); }
public void Execute(World model, WorldView view) { Bandit bandit = model.bandits[id]; view.banditViews.Add(id, ViewService.CreateBanditView(bandit)); }
public WorldController() { _world = Object.Instantiate(Resources.Load <WorldView>("World")); }
public abstract void Act(Actor actor, WorldView state);
public void Behave(World state) { var worldView = new WorldView(state, location); behaviour = behaviour.Invoke(actor, worldView); location = worldView.Location; }
public void DrawMap(WorldView view) { int num = view.SAFE_AREA_OFFSET_L + ((UI.numActiveViews > 1) ? 340 : 290); int sAFE_AREA_OFFSET_T = view.SAFE_AREA_OFFSET_T; mapDestH = (short)(540 - view.SAFE_AREA_OFFSET_T - view.SAFE_AREA_OFFSET_B - 36); int num2 = view.viewWidth - view.SAFE_AREA_OFFSET_R - num; if (!isThreadDone) { Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, view.screenProjection); SpriteSheet <_sheetSprites> .Draw(1012, num + (num2 >> 1), sAFE_AREA_OFFSET_T + (mapDestH >> 1), Color.White, (float)((double)Main.frameCounter * (Math.PI / 30.0)), 1f); return; } alpha += 16; if (alpha > 255) { alpha = 255; } int num3 = num + (num2 >> 1); int num4 = sAFE_AREA_OFFSET_T + (mapDestH >> 1); Matrix view2 = Matrix.CreateTranslation(-num3, -num4, 0f) * Matrix.CreateScale(mapScale, mapScale, 1f) * Matrix.CreateTranslation(num3, num4, 0f); view.screenProjection.View = view2; Rectangle scissorRectangle = default(Rectangle); if (view.isFullScreen()) { scissorRectangle.X = num; scissorRectangle.Y = sAFE_AREA_OFFSET_T; scissorRectangle.Width = num2; scissorRectangle.Height = mapDestH; } else { scissorRectangle.X = (num >> 1) + view.activeViewport.X; scissorRectangle.Y = (sAFE_AREA_OFFSET_T >> 1) + view.activeViewport.Y; scissorRectangle.Width = num2 >> 1; scissorRectangle.Height = mapDestH >> 1; } WorldView.graphicsDevice.ScissorRectangle = scissorRectangle; Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, WorldView.scissorTest, view.screenProjection); int num5 = mapX / texWidth; int num6 = (mapX + num2 - 1) / texWidth; if (num6 >= mapTexture.Length) { num6 = mapTexture.Length - 1; } Vector2 position = new Vector2(num, sAFE_AREA_OFFSET_T); Rectangle rectangle = default(Rectangle); rectangle.X = mapX - num5 * texWidth; rectangle.Y = mapY; rectangle.Width = Math.Min(num2, texWidth - rectangle.X); rectangle.Height = mapDestH; Color color = new Color(alpha, alpha, alpha, alpha); for (int i = num5; i <= num6; i++) { Main.spriteBatch.Draw(mapTexture[i], position, rectangle, color); position.X += rectangle.Width; rectangle.X = 0; rectangle.Width = texWidth; } switch (Main.magmaBGFrame) { case 0: rectangle.X = 659; rectangle.Y = 10; break; case 1: rectangle.X = 659; rectangle.Y = 0; break; default: rectangle.X = 759; rectangle.Y = 10; break; } rectangle.Width = 10; rectangle.Height = 10; for (int num7 = 195; num7 >= 0; num7--) { NPC nPC = Main.npc[num7]; if (nPC.active != 0) { int num8 = nPC.aabb.X >> 4; int num9 = nPC.aabb.Y >> 4; if (num8 >= 0 && num9 >= 0 && num8 < Main.maxTilesX && num9 < Main.maxTilesY && (Main.tile[num8, num9].flags & Tile.Flags.VISITED) == Tile.Flags.VISITED) { num8 -= 34 + mapX; if (num8 >= 0 && num8 + 4 < num2) { num9 -= 34 + mapY; if (num9 >= 0 && num9 + 4 < mapDestH) { int headTextureId = nPC.getHeadTextureId(); if (headTextureId < 0) { color = new Color(106, 0, 66, 127); color.R = (byte)(color.R * UI.cursorColor.A >> 8); color.G = (byte)(color.G * UI.cursorColor.A >> 8); color.B = (byte)(color.B * UI.cursorColor.A >> 8); color.A = (byte)(color.A * UI.cursorColor.A >> 8); SpriteSheet <_sheetSprites> .DrawCentered(218, num + num8, sAFE_AREA_OFFSET_T + num9, rectangle, color); } else { SpriteSheet <_sheetSprites> .DrawScaled(1255 + headTextureId, num + num8, sAFE_AREA_OFFSET_T + num9, 0.5f, new Color(248, 248, 248, 248), (nPC.spriteDirection >= 0)?SpriteEffects.FlipHorizontally : SpriteEffects.None); } } } } } } Main.spriteBatch.End(); Matrix world = view.screenProjection.World; float num10 = (float)(0.6875 + 0.0625 * Math.Sin((double)Main.frameCounter * 0.083333333333333329)); view2 = Matrix.CreateTranslation(-10f, -8f, 0f) * Matrix.CreateScale(num10, num10, 1f); for (int num11 = 7; num11 >= 0; num11--) { Player player = Main.player[num11]; if (player.active != 0 && !player.dead) { int num12 = player.aabb.X >> 4; int num13 = player.aabb.Y >> 4; if ((Main.tile[num12, num13].flags & Tile.Flags.VISITED) != 0) { num12 -= 34 + mapX; num13 -= 34 + mapY; Vector2 position2 = player.position; player.position.X = view.screenPosition.X; player.position.Y = view.screenPosition.Y; view.screenProjection.World = view2 * Matrix.CreateTranslation(num + num12, sAFE_AREA_OFFSET_T + num13, 0f); Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, WorldView.scissorTest, view.screenProjection); player.Draw(view, isMenu: true, isIcon: true); Main.spriteBatch.End(); player.position = position2; player.aabb.X = (int)position2.X; player.aabb.Y = (int)position2.Y; } } } view.screenProjection.World = world; view.screenProjection.View = Matrix.Identity; Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, view.screenProjection); }
public ActionController(WorldView worldView) { _worldView = worldView; _queue = new Queue <GodAction>(); _actions = new List <GodAction>(); _actionIndex = 0; _actions.Add(new GodAction("No Action", -1, null)); _actions.Add(new GodAction("Bless Land", 10, (world, x, y) => { var neighbors = world.Land.GetMooreNeighbors(x, y, 3); foreach (var neighbor in neighbors) { neighbor.Food = 1f; neighbor.Animals = 1f; //neighbor.Animals = 1f; } }) { AniNeumann = false, AniRange = 3 }); _actions.Add(new GodAction("Small Earthquake", 10, (world, x, y) => { var neighbors = world.Populations.GetNeumannNeighbors(x, y, 2); foreach (var neighbor in neighbors) { neighbor.PopulationSize = Random.Range(0, neighbor.PopulationSize); } var mooreNeighbors = world.Land.GetMooreNeighbors(x, y, 2); foreach (var neighbor in mooreNeighbors) { neighbor.Food = Random.Range(0f, neighbor.Food); neighbor.Animals = Random.Range(0f, neighbor.Animals); } }) { AniNeumann = true, AniRange = 2 }); _actions.Add(new GodAction("Large Earthquake", 25, (world, x, y) => { var neighbors = world.Populations.GetNeumannNeighbors(x, y, 5); foreach (var neighbor in neighbors) { neighbor.PopulationSize = Random.Range(0, neighbor.PopulationSize / 2); } var mooreNeighbors = world.Land.GetMooreNeighbors(x, y, 5); foreach (var neighbor in mooreNeighbors) { neighbor.Food = Random.Range(0f, neighbor.Food); neighbor.Animals = Random.Range(0f, neighbor.Animals); } }) { AniNeumann = true, AniRange = 5 }); _actions.Add(new GodAction("Send Angel of Death", 40, (world, x, y) => { var neighbors = world.Populations.GetMooreNeighbors(x, y, 3); foreach (var neighbor in neighbors) { neighbor.PopulationSize = 0; } }) { AniNeumann = false, AniRange = 3 }); }
public Behaviour Invoke(Actor actor, WorldView state) { var result = behaviour(state); result.Item1.Act(actor, state); return result.Item2; }
public static void RenderCylinderOutline(this WorldView world, Matrix4X4 worldMatrix, Vector3 center, double diameter, double height, int sides, Color color, double lineWidth = 1, double extendLineLength = 0) { world.RenderCylinderOutline(worldMatrix, center, diameter, height, sides, color, color, lineWidth, extendLineLength); }