private void Awake() { TileGrid grid = gridInstance.GetInstance(); UnitySceneParser parser = new UnitySceneParser(); grid.Actors.AddRange(parser.GetAllPreplacedActors(grid)); AgentCommander commander = agentCommanderInstance.GetInstance(grid, default); AgentCursorController agentCursor = (AgentCursorController)commander.controller; agentCursor.IsEnabled = true; switch (test) { case TestType.SimpleUnitMove: TestSimpleUnitMove(); break; } void TestSimpleUnitMove() { agentCursor.AddAction(new CursorAction { path = grid.GridToWorld(new Vector2Int[] { new Vector2Int(1, 6), new Vector2Int(1, 5), new Vector2Int(2, 5), new Vector2Int(2, 4) }), holdsClick = true }, OrderPriority.Queued); } }
public void SetMetVictoryCondition(VictoryCondition victoryCondition) { if (!victoryCondition) { return; } metVictoryCondition = victoryCondition; winner = metVictoryCondition.GetWinner(); }
public override bool CommanderMeetsConditions(AgentCommander commander) { RTSAgent[] agents = commander.GetComponentInChildren <RTSAgents>().GetComponentsInChildren <RTSAgent>(); foreach (RTSAgent agent in agents) { if (agent.GetAbility <Convoy>()) { return(commander && !commander.IsDead() && ConvoyInPosition(agent)); } } return(false); }
protected override void OnSetup() { Agent.onSelectedChange += HandleSelectedChange; Agent.onHighlightedChange += HandleHighlightedChange; cachedHealth = Agent.GetAbility <Health>(); cachedHarvest = Agent.GetAbility <Harvest>(); cachedSpawner = Agent.GetAbility <Spawner>(); cachedStructure = Agent.GetAbility <Structure>(); cachedController = PlayerManager.MainController; cachedCommander = cachedController.Commander; }
public override bool CommanderMeetsConditions(AgentCommander commander) { Wonder wonder = commander.GetComponentInChildren <Wonder>(); RTSAgent[] agents = commander.GetComponentInChildren <RTSAgents>().GetComponentsInChildren <RTSAgent>(); foreach (RTSAgent agent in agents) { if (agent.GetAbility <Wonder>()) { return(commander && !commander.IsDead() && agent && !agent.GetAbility <Structure>().UnderConstruction()); } } return(false); }
public static void Initialize() { _cachedCommander = PlayerManager.MainController.Commander; GridBuilder.Initialize(); OrganizerStructures = LSUtility.CreateEmpty().transform; OrganizerStructures.transform.parent = PlayerManager.MainController.Commander.GetComponentInChildren <RTSAgents>().transform; OrganizerStructures.gameObject.name = "OrganizerStructures"; WallPositioningHelper.Initialize(); UserInputHelper.OnSingleLeftTapDown += HandleSingleLeftClick; UserInputHelper.OnSingleRightTapDown += HandleSingleRightClick; }
/// <summary> /// Retrieves the unwrapped agent commander from the scene. /// </summary> /// <returns>The tile grid instance (with no notion of monobehaviour).</returns> public AgentCommander GetInstance(TileGrid grid, DamageTable damageTable) { // Create the new commander and add it to the grid. AgentCommander commander = new AgentCommander(teamID, grid, damageTable, controller.GetInstance(grid)) { ThoughtTime = thoughtTime }; grid.Commanders.Add(commander); // Destroy this script's Monobehaviour baggage, // and return the lightweight instance. Destroy(this); return(commander); }
protected void Setup() { QuickMove = AbilityDataItem.FindInterfacer("Move"); QuickTarget = AbilityDataItem.FindInterfacer("Attack"); QuickHarvest = AbilityDataItem.FindInterfacer("Harvest"); QuickBuild = AbilityDataItem.FindInterfacer("Construct"); QuickRally = AbilityDataItem.FindInterfacer("Spawner"); if (GUIManager == null) { GUIManager = new RTSGUIManager(); } Setted = true; cachedCommander = PlayerManager.MainController.Commander; }
//private static void LoadResources(JsonTextReader reader) //{ // if (reader == null) // { // return; // } // string currValue = "", type = ""; // while (reader.Read()) // { // if (reader.Value != null) // { // if (reader.TokenType == JsonToken.PropertyName) // { // currValue = (string)reader.Value; // } // else if (currValue == "Type") // { // type = (string)reader.Value; // GameObject newObject = (GameObject)GameObject.Instantiate(ResourceManager.GetWorldObject(type)); // Resource resource = newObject.GetComponent<Resource>(); // resource.name = resource.name.Replace("(Clone)", "").Trim(); // resource.LoadDetails(reader); // } // } // else if (reader.TokenType == JsonToken.EndArray) // { // return; // } // } //} private static void LoadPlayers(JsonTextReader reader) { if (reader == null) { return; } while (reader.Read()) { if (reader.TokenType == JsonToken.StartObject) { //need to create via agentcontrollerhelper.... GameObject newObject = (GameObject)GameObject.Instantiate(ResourceManager.GetCommanderObject()); AgentCommander commander = newObject.GetComponent <AgentCommander>(); commander.name = commander.name.Replace("(Clone)", "").Trim(); commander.LoadDetails(reader); } else if (reader.TokenType == JsonToken.EndArray) { return; } } }
public void CreateCommander() { if (Commander != null) { Debug.LogError("A commander called '" + Commander.gameObject.name + "' already exists for '" + this.ToString() + "'."); } if (!UnityEngine.Object.FindObjectOfType <RTSGameManager>()) { Debug.LogError("A game manager has not been initialized!"); } //load from ls db GameObject commanderObject = GameObject.Instantiate(GameResourceManager.GetCommanderObject(), UnityEngine.Object.FindObjectOfType <RTSGameManager>().GetComponentInChildren <AgentCommanders>().transform); commanderObject.name = this.ControllerName; AgentCommander commanderClone = commanderObject.GetComponent <AgentCommander>(); //change to user's selected username commanderClone.username = this.ControllerName; commanderClone.SetController(this); if (PlayerManager.ContainsController(this)) { commanderClone.human = true; } //come up with better way to set selected commander to the current commander if (this == PlayerManager.MainController) { PlayerManager.SelectPlayer(commanderClone.username, 0, this.ControllerID, this.PlayerIndex); } _commander = commanderClone; BehaviourHelperManager.InitializeOnDemand(_commander); }
protected override void Start() { base.Start(); commander = transform.root.GetComponent <AgentCommander>(); }
public void SetCommander(AgentCommander commander) { _cachedCommander = commander; }
public override bool CommanderMeetsConditions(AgentCommander commander) { return(commander && commander.human && !commander.IsDead()); }
// Any child class that extends must provide an implementation for this method. public abstract bool CommanderMeetsConditions(AgentCommander commander);
public override bool CommanderMeetsConditions(AgentCommander commander) { return(commander && !commander.IsDead() && commander.GetResourceAmount(type) >= amount); }
// Use this for initialization private void Start() { cachedCommander = transform.GetComponentInParent <AgentCommander>(); }
public void SetCommander() { cachedCommander = Controller.Commander; }
// Use this for initialization private void Start() { cachedCommander = transform.GetComponentInParent <AgentCommander>(); if (cachedCommander && cachedCommander.human) { // agentController = PlayerManager.GetAgentController(cachedCommander.playerIndex); resourceValues = new Dictionary <ResourceType, long>(); resourceLimits = new Dictionary <ResourceType, long>(); resourceImages = new Dictionary <ResourceType, Texture2D>(); for (int i = 0; i < resources.Length; i++) { switch (resources[i].name) { case "Gold": resourceImages.Add(ResourceType.Gold, resources[i]); resourceValues.Add(ResourceType.Gold, 0); resourceLimits.Add(ResourceType.Gold, 0); break; case "Ore": resourceImages.Add(ResourceType.Ore, resources[i]); resourceValues.Add(ResourceType.Ore, 0); resourceLimits.Add(ResourceType.Ore, 0); break; case "Stone": resourceImages.Add(ResourceType.Stone, resources[i]); resourceValues.Add(ResourceType.Stone, 0); resourceLimits.Add(ResourceType.Stone, 0); break; case "Wood": resourceImages.Add(ResourceType.Wood, resources[i]); resourceValues.Add(ResourceType.Wood, 0); resourceLimits.Add(ResourceType.Wood, 0); break; case "Crystal": resourceImages.Add(ResourceType.Crystal, resources[i]); resourceValues.Add(ResourceType.Crystal, 0); resourceLimits.Add(ResourceType.Crystal, 0); break; case "Food": resourceImages.Add(ResourceType.Food, resources[i]); resourceValues.Add(ResourceType.Food, 0); resourceLimits.Add(ResourceType.Food, 0); break; case "Army": resourceImages.Add(ResourceType.Army, resources[i]); resourceValues.Add(ResourceType.Army, 0); resourceLimits.Add(ResourceType.Army, 0); break; default: break; } } Dictionary <ResourceType, Texture2D> resourceHealthBarTextures = new Dictionary <ResourceType, Texture2D>(); for (int i = 0; i < resourceHealthBars.Length; i++) { switch (resourceHealthBars[i].name) { case "ore": resourceHealthBarTextures.Add(ResourceType.Ore, resourceHealthBars[i]); break; case "stone": resourceHealthBarTextures.Add(ResourceType.Stone, resourceHealthBars[i]); break; case "gold": resourceHealthBarTextures.Add(ResourceType.Gold, resourceHealthBars[i]); break; case "crystal": resourceHealthBarTextures.Add(ResourceType.Crystal, resourceHealthBars[i]); break; case "food": resourceHealthBarTextures.Add(ResourceType.Food, resourceHealthBars[i]); break; case "wood": resourceHealthBarTextures.Add(ResourceType.Wood, resourceHealthBars[i]); break; default: break; } } ResourceManager.SetResourceHealthBarTextures(resourceHealthBarTextures); ResourceManager.StoreSelectBoxItems(selectBoxSkin, healthy, damaged, critical); buildAreaHeight = Screen.height - RESOURCE_BAR_HEIGHT - SELECTION_NAME_HEIGHT - 2 * BUTTON_SPACING; SetCursorState(CursorState.Select); List <AudioClip> sounds = new List <AudioClip>(); List <float> volumes = new List <float>(); sounds.Add(clickSound); volumes.Add(clickVolume); audioElement = new AudioElement(sounds, volumes, "HUD", null); } }
// Use this for initialization public void Setup() { _cachedCommander = GetComponentInParent <AgentCommander>(); _resources = InitResourceList(); _resourceLimits = InitResourceList(); }