public void placeStopDown() { if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Stops) { TaskObject.GetComponent <Construction_Script>().Contained_Stops++; System_Script.CollectableStops.Remove(Items[0]); var index = TaskObject.GetComponent <Construction_Script>().Workerlist_Stops.IndexOf(this.gameObject); Items[0].transform.rotation = TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints[index].transform.rotation; Items[0].transform.eulerAngles += new Vector3(0, 180, 0); Items[0].transform.position = new Vector3(Items[0].transform.position.x, 0.1f, Items[0].transform.position.z); TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints.RemoveAt(index); TaskObject.GetComponent <Construction_Script>().aquiredObj.Add(Items[0]); Items[0].GetComponent <Collectable>().MakeStatic(); Items[0].GetComponent <Animation>().Play("Open"); } Items.Clear(); CurrentTask = CurrentJob.Nothing; TaskChassis = TaskChassis.Nothing; ItemType = CollectableType.Nothing; }
public void SetToDefault() { CurrentTask = CurrentJob.Nothing; DistFromJob = float.MaxValue; TaskChassis = TaskChassis.Nothing; TaskObject = null; Vehicle = null; UnSelectable = false; this.GetComponent <NavMeshAgent>().enabled = true; }
// this must be set by priorities public void SetNextJob() { if (TaskChassis != TaskChassis.JWalking) { TaskChassis = TaskChassis.Nothing; if (System_Script.CollectableCrystals.Count > 0 && CanCarryCrystals) { TaskChassis = TaskChassis.GatherCrystals; FindAndCollectCrystal(); } if (System_Script.CollectableOre.Count > 0 && CanCarryOre) { TaskChassis = TaskChassis.GatherOre; FindAndCollectOre(); } if (System_Script.DrillRocks.Count > 0 && CanDrill) { TaskChassis = TaskChassis.Drilling; FindAndDrillRocks(); } if (System_Script.ClearRubble.Count > 0 && CanSweep) { FindAndClearRubble(); TaskChassis = TaskChassis.Sweeping; } if (System_Script.CollectableStops.Count > 0 && CanCarryStops) { TaskChassis = TaskChassis.GatherStops; FindAndCollectStops(); } if (System_Script.AllVehicles.Count > 0 && CanDrive) { TaskChassis = TaskChassis.VehicleProperties; FindVehicle(); } } }
//put crystal away public void PutCollectableDownAtBase() { if (CurrentTask != CurrentJob.ConstructionWorker) { // used for collection of resources if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Crystal) { SystemSrpt.CrystalsCollectedCart++; TaskChassis = TaskChassis.GatherCrystals; } if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Ore) { SystemSrpt.OreCollectedCart++; TaskChassis = TaskChassis.GatherOre; } Destroy(Items[0]); } else { // used for building if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Ore) { TaskObject.GetComponent <Construction_Script>().Contained_Ore++; } if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Crystal) { TaskObject.GetComponent <Construction_Script>().Contained_Crystal++; } TaskObject.GetComponent <Construction_Script>().aquiredObj.Add(Items[0]); Items[0].GetComponent <Collectable>().MakeStatic(); } if (Items.Count > 0) { Items.Clear(); CurrentTask = CurrentJob.Nothing; TaskChassis = TaskChassis.Nothing; } }
public void StartClearingProcess() { CurrentTask = CurrentJob.WalkingToRubble; TaskChassis = TaskChassis.Sweeping; DistFromJob = float.MaxValue; }
public void StartDrillingProcess() { TaskChassis = TaskChassis.Drilling; CurrentTask = CurrentJob.WalkingToDrill; DistFromJob = float.MaxValue; }
public void ArrivedAtDest() { var run = true; if (CurrentTask == CurrentJob.DropOffCollectable || CurrentTask == CurrentJob.ConstructionWorker) { if (ItemType != CollectableType.Stops) { PutCollectableDownAtBase(); } } if (CurrentTask == CurrentJob.WalkToPoint && run) { CurrentTask = CurrentJob.Nothing; TaskChassis = TaskChassis.Nothing; run = false; } if (TaskChassis == TaskChassis.PackAwwayJunk) { if (ItemType == CollectableType.Stops && run) { PutCollectableDownAtBase(); run = false; } } //stops drop off //this contains both going to stop position and then to place if (ItemType == CollectableType.Stops && TaskChassis == TaskChassis.GatherStops && run) { var index = 0; run = false; if (TaskObject.GetComponent <Construction_Script>().Workerlist_Stops.Contains(this.gameObject)) { index = TaskObject.GetComponent <Construction_Script>().Workerlist_Stops.IndexOf(this.gameObject); if (index < TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints.Count) { var StopPoint = TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints[index]; var distanceToStop = Vector3.Distance(transform.position, StopPoint.transform.position); this.GetComponent <NavMeshAgent>().SetDestination(StopPoint.transform.position); if (distanceToStop <= 1) { placeStopDown(); } } } } //if the player is wandering with an Item in hand and has reched the end of its journey set by player then find a place to drop it off if (CurrentTask == CurrentJob.WanderAroungWithItem && ItemType != CollectableType.Nothing && run) { CurrentTask = CurrentJob.DropOffCollectable; FindNearestCollectableDropOff(); run = false; } if ((TaskChassis == TaskChassis.JWalking || CurrentTask == CurrentJob.WalkToPoint) && run) { TaskChassis = TaskChassis.Nothing; CurrentTask = CurrentJob.Nothing; run = false; } if (CurrentTask == CurrentJob.WalkingToVehicle && run && TaskChassis == TaskChassis.VehicleProperties) { TaskChassis = TaskChassis.IsDriving; Vehicle.GetComponent <Lego_Character>().DriverIsSeated = true; run = false; } Arrived = false; }
//Pick up resources------------------------------------------------------------------------------------------------------------------------------------------- public void FindNearestCollectableDropOff() { var set = false; //If there is spot Open for stops then build if (System_Script.ConstructionSites.Count > 0 && !set) { var shortestPath = this.ShortestPath(System_Script.ConstructionSites, ExtraCommands.R_Ore_Crystal); GetComponent <NavMeshAgent>().SetPath(shortestPath); if (SystemSrpt.TotalStopsNeeded > 0 && ItemType == CollectableType.Stops) { var index = shortestPath.Object.GetComponent <Construction_Script>().Workerlist_Stops.IndexOf(this.gameObject); var point = shortestPath.Object.GetComponent <Construction_Script>().RequiredStopsListPoints[index]; SystemSrpt.TotalStopsNeeded--; } if (shortestPath.Length != float.MaxValue) { set = true; CurrentTask = CurrentJob.ConstructionWorker; TaskChassis = TaskChassis.GatherStops; } } //If there is no spots open for stops then pack away if (SystemSrpt.TotalStopsNeeded <= 0 && !set && System_Script.AllStops.Count > 0) { var shortestPath = this.ShortestPath(System_Script.ListOfAllToolStores, ExtraCommands.ReturnCrystal); GetComponent <NavMeshAgent>().SetPath(shortestPath); if (shortestPath.Length != float.MaxValue) { set = true; TaskChassis = TaskChassis.PackAwwayJunk; CurrentTask = CurrentJob.DropOffCollectable; } } if (ItemType == CollectableType.Crystal && !set) { var shortestPath = this.ShortestPath(System_Script.AllBuildings, ExtraCommands.ReturnCrystal); GetComponent <NavMeshAgent>().SetPath(shortestPath); if (shortestPath.Length != float.MaxValue) { set = true; CurrentTask = CurrentJob.DropOffCollectable; } } if (ItemType == CollectableType.Ore && !set) { var shortestPath = this.ShortestPath(System_Script.AllBuildings, ExtraCommands.ReturnOre); GetComponent <NavMeshAgent>().SetPath(shortestPath); if (shortestPath.Length != float.MaxValue) { set = true; CurrentTask = CurrentJob.DropOffCollectable; } } }