public void MoveUnitsTowards(RaycastHit hit) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { List <Vector3> possiblePositions = NavMeshPositionGenerator.GetInstance.ObtainPositions(unitSelected.Count, hit.point, unitSelected); debugPositionSpawner.PlaceVectorBalls(unitSelected.Count, possiblePositions); for (int i = 0; i < unitSelected.Count; i++) { unitSelected[i].ReceiveOrder(UnitOrder.GenerateMoveOrder(possiblePositions[i])); } } }
// Check Interaction Requirements public virtual void InitializeInteraction(ActionType actionChoice, List <UnitBaseBehaviourComponent> interactors) { // First check if action choice is inside the potnetialActionTypes if (!potentialActionTypes.Contains(actionChoice)) { Debug.LogError("Action Type not within the possible actions, did you pass the wrong type?"); return; } // Second Check the distance for every interactors if (interactors.Count > 0) { foreach (UnitBaseBehaviourComponent item in interactors) { float dist = Vector3.Distance(item.transform.position, this.transform.position); if (dist < 0.5f) { Debug.Log("Start Cutting!"); } else { List <UnitOrder> tmp = new List <UnitOrder>(); // Made it like this since there are other ActionTypes that does not need to be near. switch (actionChoice) { case ActionType.Converse: tmp.Add(UnitOrder.GenerateMoveOrder(transform.position, item)); tmp.Add(UnitOrder.GenerateInteractOrder(this, actionChoice)); break; case ActionType.Gather: tmp.Add(UnitOrder.GenerateMoveOrder(transform.position, item)); tmp.Add(UnitOrder.GenerateGatherResourceOrder(this, actionChoice)); break; case ActionType.Wait: tmp.Add(UnitOrder.GenerateMoveOrder(transform.position, item)); tmp.Add(UnitOrder.GenerateInteractOrder(this, actionChoice)); break; case ActionType.Target: tmp.Add(UnitOrder.GenerateTargetOrder(this)); break; } // Deliver the Orders to the unit involved. for (int i = 0; i < tmp.Count; i++) { if (i <= 0) { PlayerUnitController.GetInstance.OrderManualSelected(tmp[i]); } else { PlayerUnitController.GetInstance.OrderManualSelected(tmp[i], false); } } } } } else { Debug.LogError("Sent Wrong list of Interactors! Check it Again!"); } }