public void ShowRubbleOptions(RubbleScript rubble) { CloseMenu(); if (rubble == null) { return; } MenuOpen = true; _rubbleMenu.GetComponent <RubbleOptionsMenu>().Open(rubble); }
void SelectUI() { if (!HasSelection()) { return; } SelectionData Single = CurrentSelectionObjects[0]; if (Single.IsWorker()) { if (_hit.transform.tag == TagLibrary.HQ_TAG) { //RadialMenuScript.instance.ShowToolOptions(Single._Worker, _hit.transform.position); if (_hit.transform.GetComponent <Tile>() != null || _hit.transform.GetComponent <HQTileTagScript>() != null) { ExecuteOrderOnAll(UnitTask.TaskType.Walk); } } else if (_hit.transform.tag == TagLibrary.VEHICLE_TAG) { if (!_hit.transform.GetComponent <Vehicle>().GetOccupied()) { RadialMenuScript.instance.ShowEmptyVehicleOptions(Single._Worker, _hit.transform.GetComponent <Vehicle>()); } } else if (_hit.transform.tag == TagLibrary.WORKER_TAG) { Worker worker = _hit.transform.gameObject.GetComponentInParent <Worker>(); List <Worker> workers = new List <Worker>(); for (int i = 0; i < CurrentSelectionObjects.Count; i++) { workers.Add(CurrentSelectionObjects[i]._Worker); } RadialMenuScript.instance.ShowWorkerOptions(workers, worker); } else { ExecuteOrderOnAll(UnitTask.TaskType.Walk); } } else { switch (_hit.transform.tag) { case TagLibrary.ROCK_TAG: RockScript rock = _hit.transform.gameObject.GetComponentInParent <RockScript>(); RadialMenuScript.instance.ShowRockOptions(rock); break; case TagLibrary.RUBBLE_TAG: RubbleScript rubble = _hit.transform.gameObject.GetComponentInParent <RubbleScript>(); RadialMenuScript.instance.ShowRubbleOptions(rubble); break; case TagLibrary.MONSTER_TAG: Monster monster = _hit.transform.GetComponentInParent <Monster>(); RadialMenuScript.instance.ShowEnemyOptions(monster); break; case TagLibrary.HQ_TAG: HQ hq = _hit.transform.GetComponentInParent <HQ>(); RadialMenuScript.instance.ShowHQOptions(hq); break; case TagLibrary.OUTPOST_TAG: Outpost outpost = _hit.transform.GetComponentInParent <Outpost>(); RadialMenuScript.instance.ShowOutpostOptions(outpost); break; case TagLibrary.GARAGE_TAG: Garage garage = _hit.transform.GetComponentInParent <Garage>(); RadialMenuScript.instance.ShowGarageOptions(garage); break; case TagLibrary.GEN_TAG: case TagLibrary.SKIP_TAG: case TagLibrary.BLOCK_TAG: case TagLibrary.TURRET_TAG: case TagLibrary.POWERGEN_TAG: Building building = _hit.transform.GetComponentInParent <Building>(); RadialMenuScript.instance.ShowBuildingOptions(building); break; case TagLibrary.ORE_TAG: Ore ore = _hit.transform.GetComponentInParent <Ore>(); RadialMenuScript.instance.ShowResourceOptionsOre(ore); break; case TagLibrary.ENERGYCRYSTAL_TAG: EnergyCrystal energyCrystal = _hit.transform.GetComponentInParent <EnergyCrystal>(); RadialMenuScript.instance.ShowResourceOptionsEnergyCrystal(energyCrystal); break; case TagLibrary.VEHICLE_TAG: Vehicle vehicle = _hit.transform.GetComponent <Vehicle>(); if (vehicle.GetOccupied()) { RadialMenuScript.instance.ShowVehicleOptions(_hit.transform.GetComponent <Vehicle>()); } else { RadialMenuScript.instance.ShowEmptyVehicleOptions(null, _hit.transform.GetComponent <Vehicle>()); } break; case TagLibrary.BURN_TAG: MushroomCluster mushroomCluster = _hit.transform.GetComponentInParent <MushroomCluster>(); RadialMenuScript.instance.ShowMushroomOptions(mushroomCluster); break; } } if (!Single.IsWorker()) { ClearSelectedObjects(false); } SetMode(CurrentSelectionMode.RadialMenu); }
/// <summary> /// Open rubble radial dial, store rubble /// </summary> /// <param name="rubble">Rubble selected</param> public void Open(RubbleScript rubble) { _rubble = rubble; DoUpdateChecks(); gameObject.SetActive(true); }
public UnitTask CreateTask(UnitTask.TaskType t, Vector3 pos, GameObject Data) { UnitTask newTask = null; switch (t) { case UnitTask.TaskType.Mine: RockScript Rock = Data.GetComponentInParent <RockScript>(); if (CanMineTarget(Rock)) { newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.Mine, _targetRock = Rock, _requiredTool = Unit.UnitTool.MiningTool, _taskDescription = "Mining " + Rock.RockType }; } break; case UnitTask.TaskType.Pickup: Ore O = Data.GetComponent <Ore>(); newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.Pickup, _itemToPickUp = Data, _itemType = (O != null) ? UnitTask.ItemType.Ore : UnitTask.ItemType.EnergyCrystal, _taskDescription = (O != null) ? "Transporting an Ore" : "Transporting an Energy crystal", _requiredTool = Unit.UnitTool.none }; break; case UnitTask.TaskType.Walk: newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.Walk, _taskDescription = "Walking to location", _requiredTool = Unit.UnitTool.none }; break; case UnitTask.TaskType.Attack: Monster tempMonster = Data.GetComponent <Monster>(); newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.Attack, _requiredTool = Unit.UnitTool.Weapon, _taskDescription = "Attacking " + tempMonster._type, _targetMonster = Data.GetComponent <Monster>() }; break; case UnitTask.TaskType.flameTarget: MushroomCluster mushroom = Data.GetComponentInParent <MushroomCluster>(); if (mushroom == null) { return(null); } newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.flameTarget, _requiredTool = Unit.UnitTool.FlameThrower, _taskDescription = "Burning things", _targetMushroom = mushroom }; break; case UnitTask.TaskType.Reinforce: break; case UnitTask.TaskType.Build: Building tempBuilding = Data.GetComponentInParent <Building>(); newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.Build, _targetBuilding = Data.GetComponentInParent <Building>(), _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Building a " + tempBuilding.name }; break; case UnitTask.TaskType.GetTool: newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.GetTool, _taskDescription = "Getting " + RadialMenuScript.instance.NewTool.ToString(), _requiredTool = RadialMenuScript.instance.NewTool }; break; case UnitTask.TaskType.RefillOxygen: Building closestOxyGen = null; foreach (Building building in WorldController.GetWorldController._buildings) { if (building.tag == TagLibrary.GEN_TAG && building._Built) { if (closestOxyGen == null || Vector3.Distance(Data.transform.position, building.transform.position) < Vector3.Distance(Data.transform.position, closestOxyGen.transform.position)) { closestOxyGen = building; } } } if (closestOxyGen == null) { return(null); } newTask = new UnitTask { _location = closestOxyGen.transform.position, _taskType = UnitTask.TaskType.RefillOxygen, _taskDescription = "Refilling Oxygen", _targetBuilding = closestOxyGen }; break; case UnitTask.TaskType.RefillEnergy: Building tempBuidling = Data.GetComponent <Building>(); newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.RefillEnergy, _targetBuilding = tempBuidling, _taskDescription = "Refilling " + tempBuidling.name + " energy" }; break; case UnitTask.TaskType.ClearRubble: RubbleScript tempRubble = Data.GetComponentInParent <RubbleScript>(); if (tempRubble == null) { return(null); } newTask = new UnitTask { _location = tempRubble.transform.position, _taskType = UnitTask.TaskType.ClearRubble, _targetRubble = tempRubble, _requiredTool = Unit.UnitTool.Shovel, _taskDescription = "Clearing rubble" }; break; case UnitTask.TaskType.GetInVehicle: Vehicle tempVehicle = Data.GetComponent <Vehicle>(); newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.GetInVehicle, _targetVehicle = tempVehicle, _taskDescription = "Entering vehicle" }; break; case UnitTask.TaskType.RechargeVehicle: newTask = new UnitTask { _location = pos, _taskType = UnitTask.TaskType.RechargeVehicle, _taskDescription = "Recharging vehicle" }; break; case UnitTask.TaskType.Idle: case UnitTask.TaskType.none: default: Debug.LogError("Invalid Task for Create Task: " + t.ToString()); break; } if (newTask == null || !newTask.IsValid()) { return(null); } return(newTask); }
// Update is called once per frame void Update() { _ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (_currentSelectedObject != null) { _selectionRing.transform.position = _currentSelectedObject.transform.position; } else { _selectionRing.transform.position = new Vector3(0, -100, 0); } if (Physics.Raycast(_ray, out _hit)) { Debug.DrawRay(_ray.origin, _ray.direction * _hit.distance, Color.yellow); _mouseWorldLocation = _hit.point; if (ControlScript.instance.GetControl("Select").InputDown) { if (!EventSystem.current.IsPointerOverGameObject()) { RadialMenuScript.instance.CloseMenu(); } switch (_hit.transform.tag) { case TagLibrary.WORKER_TAG: if (_currentSelectedObject != null) { _currentSelectedObject._selected = false; _currentSelectedObject = null; } _currentSelectedObject = _hit.transform.gameObject.GetComponent <SelectableObject>(); _currentSelectedObject._selected = true; WorkerInfoPanelScript.instance.Open(_hit.transform.GetComponent <Worker>()); break; default: if (_currentSelectedObject != null) { _currentSelectedObject._selected = false; _currentSelectedObject = null; } WorkerInfoPanelScript.instance.Close(); break; } } else if (ControlScript.instance.GetControl("Order Modifier").AnyInput&& ControlScript.instance.GetControl("Order").InputDown) { if (_currentSelectedObject != null) { switch (_hit.transform.tag) { case "Floor": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); UnitTask tempTask = new UnitTask { _location = _mouseWorldLocation, _taskType = UnitTask.TaskType.Walk, _taskDescription = "Walking to location", _requiredTool = Unit.UnitTool.none }; tempWorker.AddTask(tempTask); } break; case "RockTile": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.gameObject.GetComponent <Worker>(); RockScript tempRock = _hit.transform.gameObject.GetComponentInParent <RockScript>(); if (tempWorker._currentTool == Unit.UnitTool.Hammer) { UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Reinforce, _targetRock = tempRock, _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Reinforcing a wall" }; tempWorker.AddTask(tempTask); } else { if (tempRock.RockType == RockScript.Type.Dirt || (tempRock.RockType == RockScript.Type.LooseRock && (int)WorldController.GetWorldController._miningLevel >= 1) || (tempRock.RockType == RockScript.Type.HardRock && (int)WorldController.GetWorldController._miningLevel == 2)) { UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Mine, _targetRock = tempRock, _requiredTool = Unit.UnitTool.MiningTool, _taskDescription = "Mining a wall" }; tempWorker.SetTask(tempTask); } } } break; case "Rubble": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.gameObject.GetComponent <Worker>(); RubbleScript tempRubble = _hit.transform.gameObject.GetComponentInParent <RubbleScript>(); UnitTask tempTask = new UnitTask { _location = tempRubble.transform.position, _taskType = UnitTask.TaskType.ClearRubble, _targetRubble = tempRubble, _requiredTool = Unit.UnitTool.Shovel, _taskDescription = "Clearing rubble" }; tempWorker.SetTask(tempTask); } break; case "Ore": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Pickup, _itemToPickUp = _hit.transform.gameObject, _itemType = UnitTask.ItemType.Ore, _taskDescription = "Transporting Ore", _requiredTool = Unit.UnitTool.none }; tempWorker.AddTask(tempTask); } break; case "EnergyCrystal": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Pickup, _itemToPickUp = _hit.transform.gameObject, _itemType = UnitTask.ItemType.EnergyCrystal, _taskDescription = "Transporting an Energy crystal", _requiredTool = Unit.UnitTool.none }; tempWorker.AddTask(tempTask); } break; case "HQ": if (_currentSelectedObject.transform.tag == "Worker") { //RadialMenuScript.instance.ShowToolOptions(_currentSelectedObject.transform.gameObject.GetComponent<Worker>(), _hit.transform.position); } break; case "SKIP": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); //check if building needs building UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Build, _itemToPickUp = _hit.transform.gameObject, _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Building A Skip" }; tempWorker.AddTask(tempTask); } break; case "GEN": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); //check if building needs building UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Build, _itemToPickUp = _hit.transform.gameObject, _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Building An Oxegen Generator" }; tempWorker.AddTask(tempTask); } break; case "Monster": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); if ((int)WorldController.GetWorldController._miningLevel >= 1) { UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Attack, _requiredTool = Unit.UnitTool.Weapon, _taskDescription = "Attacking monster" }; tempWorker.SetTask(tempTask); } } break; } } } else if (ControlScript.instance.GetControl("Order").InputDown) { if (_currentSelectedObject == null || (_currentSelectedObject != null && _currentSelectedObject == _hit.transform.GetComponentInParent <SelectableObject>())) { switch (_hit.transform.tag) { case "Worker": Worker worker = _hit.transform.GetComponent <Worker>(); //RadialMenuScript.instance.ShowWorkerOptions(worker); break; case "RockTile": RockScript rock = _hit.transform.gameObject.GetComponentInParent <RockScript>(); RadialMenuScript.instance.ShowRockOptions(rock); break; case "Rubble": RubbleScript rubble = _hit.transform.gameObject.GetComponentInParent <RubbleScript>(); RadialMenuScript.instance.ShowRubbleOptions(rubble); break; case "Monster": Monster monster = _hit.transform.GetComponentInParent <Monster>(); RadialMenuScript.instance.ShowEnemyOptions(monster); break; case "HQ": HQ hq = _hit.transform.GetComponentInParent <HQ>(); RadialMenuScript.instance.ShowHQOptions(hq); break; case "GEN": case "BLOCK": Building building = _hit.transform.GetComponentInParent <Building>(); RadialMenuScript.instance.ShowBuildingOptions(building); break; case "Ore": Ore ore = _hit.transform.GetComponentInParent <Ore>(); RadialMenuScript.instance.ShowResourceOptionsOre(ore); break; case "EnergyCrystal": EnergyCrystal energyCrystal = _hit.transform.GetComponentInParent <EnergyCrystal>(); RadialMenuScript.instance.ShowResourceOptionsEnergyCrystal(energyCrystal); break; } } else if (_currentSelectedObject != null) { switch (_hit.transform.tag) { case "Floor": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); UnitTask tempTask = new UnitTask { _location = _mouseWorldLocation, _taskType = UnitTask.TaskType.Walk, _taskDescription = "Walking to location", _requiredTool = Unit.UnitTool.none }; tempWorker.SetTask(tempTask); } break; case "RockTile": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.gameObject.GetComponent <Worker>(); RockScript tempRock = _hit.transform.gameObject.GetComponentInParent <RockScript>(); if (tempWorker._currentTool == Unit.UnitTool.Hammer) { UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Reinforce, _targetRock = tempRock, _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Reinforcing a wall" }; tempWorker.SetTask(tempTask); } else { if (tempRock.RockType == RockScript.Type.Dirt || (tempRock.RockType == RockScript.Type.LooseRock && (int)WorldController.GetWorldController._miningLevel >= 1) || (tempRock.RockType == RockScript.Type.HardRock && (int)WorldController.GetWorldController._miningLevel == 2)) { UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Mine, _targetRock = tempRock, _requiredTool = Unit.UnitTool.MiningTool, _taskDescription = "Mining a wall" }; tempWorker.SetTask(tempTask); } } } break; case "Rubble": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.gameObject.GetComponent <Worker>(); RubbleScript tempRubble = _hit.transform.gameObject.GetComponentInParent <RubbleScript>(); if (tempWorker._currentTool == Unit.UnitTool.Shovel) { UnitTask tempTask = new UnitTask { _location = tempRubble.transform.position, _taskType = UnitTask.TaskType.ClearRubble, _targetRubble = tempRubble, _requiredTool = Unit.UnitTool.Shovel, _taskDescription = "Clearing rubble" }; tempWorker.SetTask(tempTask); } else { UnitTask tempTask = new UnitTask { _location = _mouseWorldLocation, _taskType = UnitTask.TaskType.Walk, _taskDescription = "Walking to location", _requiredTool = Unit.UnitTool.none }; tempWorker.SetTask(tempTask); } } break; case "Ore": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Pickup, _itemToPickUp = _hit.transform.gameObject, _itemType = UnitTask.ItemType.Ore, _taskDescription = "Transporting Ore", _requiredTool = Unit.UnitTool.none }; tempWorker.SetTask(tempTask); } break; case "EnergyCrystal": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Pickup, _itemToPickUp = _hit.transform.gameObject, _itemType = UnitTask.ItemType.EnergyCrystal, _taskDescription = "Transporting an Energy crystal", _requiredTool = Unit.UnitTool.none }; tempWorker.SetTask(tempTask); } break; case "HQ": if (_currentSelectedObject.transform.tag == "Worker") { //RadialMenuScript.instance.ShowToolOptions(_currentSelectedObject.transform.gameObject.GetComponent<Worker>(), _hit.transform.position); } break; case "SKIP": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); //check if building needs building UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Build, _itemToPickUp = _hit.transform.gameObject, _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Building A Skip" }; tempWorker.AddTask(tempTask); } break; case "GEN": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); //check if building needs building UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Build, _itemToPickUp = _hit.transform.gameObject, _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Building An Oxegen Generator" }; tempWorker.AddTask(tempTask); } break; case "Monster": if (_currentSelectedObject.transform.tag == "Worker") { Worker tempWorker = _currentSelectedObject.transform.gameObject.GetComponent <Worker>(); if ((int)WorldController.GetWorldController._miningLevel >= 1) { UnitTask tempTask = new UnitTask { _location = _hit.transform.position, _taskType = UnitTask.TaskType.Attack, _requiredTool = Unit.UnitTool.Weapon, _taskDescription = "Attacking monster" }; tempWorker.SetTask(tempTask); } } break; } } } } }