public void ShowMushroomOptions(MushroomCluster mushroomCluster) { CloseMenu(); if (mushroomCluster == null) { return; } MenuOpen = true; _mushroomMenu.GetComponent <MushroomOptionsMenu>().Open(mushroomCluster); }
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); }
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); }
/// <summary> /// Open mushroom radial dial, store mushroom cluster /// </summary> /// <param name="mushroomCluster">Mushroom selected</param> public void Open(MushroomCluster mushroomCluster) { _mushroomCluster = mushroomCluster; DoUpdateChecks(); gameObject.SetActive(true); }