public static UnitOrder GenerateTargetOrder(InteractingComponent newTarget) { UnitOrder tmp = new UnitOrder(); tmp.commandName = Commands.TARGET; tmp.p.AddParameter <InteractingComponent>("Target", newTarget); return(tmp); }
public void RemoveCurrentInteraction() { if (interactWith != null) { Debug.Log(this.transform.name + " ends Interaction with : " + interactWith.transform.name); InteractingComponent tmp = interactWith; interactWith = null; tmp.EndIndividualInteraction(this); } }
public static UnitOrder GenerateInteractOrder(InteractingComponent interactWith, ActionType action) { UnitOrder tmp = new UnitOrder(); tmp.commandName = Commands.INTERACT; tmp.p.AddParameter <ActionType>("Action", action); tmp.p.AddParameter <InteractingComponent>("InteractWith", interactWith); return(tmp); }
public void MakeUnitLookAt(InteractingComponent unit) { if (unit == null) { return; } Vector3 newLookAt = unit.transform.position; newLookAt = new Vector3(newLookAt.x, transform.position.y, newLookAt.z); transform.LookAt(newLookAt); }
public static UnitOrder GenerateGatherResourceOrder(InteractingComponent interactWith, ActionType action) { UnitOrder tmp = new UnitOrder(); tmp.commandName = Commands.GATHER_RESOURCES; tmp.actionType = ActionType.Gather; tmp.p.AddParameter <ActionType>("Action", action); tmp.p.AddParameter <InteractingComponent>("InteractWith", interactWith); return(tmp); }
// 1 public override void StartInteraction(InteractingComponent newUnit, ActionType actionIndex) { if (!canInteract) { return; } UnitBaseBehaviourComponent unit = newUnit.GetComponent <UnitBaseBehaviourComponent>(); // Obtain Interacting Unit if (unit.objectType == ObjectType.PlayerControlled || unit.objectType == ObjectType.Unit) { Debug.Log("Adding : " + newUnit.transform.name); interactingUnit.Add(unit); } UnitGatheringResourceStats tmp = new UnitGatheringResourceStats(); InitializeGathererStats(unit, tmp); ReceiveDamage(tmp.unitDamage_C, unit); }
public void ReceiveOrder(UnitOrder newOrder, bool forceOrder = true) { //Debug.Log("receiving order :" + newOrder.commandName.ToString()); if (!forceOrder) { //Debug.Log(this.gameObject.name + " Queueing Order : " + newOrder.commandName); QueueOrder(newOrder); } else { //Debug.Log(this.gameObject.name + " Forcing New Order : " + newOrder.commandName); unitOrders.Clear(); currentOrder = newOrder; } currentOrder.doingOrder = true; ActionType nextOrder = ActionType.Wait; Vector3 nextPos = transform.position; switch (currentOrder.commandName) { case Commands.INTERACT: // TODO interactWith = newOrder.p.GetWithKeyParameterValue <InteractingComponent>("InteractWith", null); if (interactWith == null) { return; } MakeUnitLookAt(interactWith); nextOrder = newOrder.p.GetWithKeyParameterValue <ActionType>("Action", ActionType.Wait); // Implement Converse / Pull Lever / Open door shit like that ( for NPCs, since player will use POPUPs). break; case Commands.MOVE_TOWARDS: RemoveCurrentInteraction(); if (!canMove) { return; } currentCommand = Commands.MOVE_TOWARDS; nextPos = currentOrder.p.GetWithKeyParameterValue <Vector3>("NextPos", transform.position); MoveTowards(nextPos); break; case Commands.WAIT_FOR_COMMAND: interactWith = null; currentCommand = Commands.WAIT_FOR_COMMAND; MoveTowards(nextPos); break; case Commands.GATHER_RESOURCES: interactWith = newOrder.p.GetWithKeyParameterValue <InteractingComponent>("InteractWith", null); currentCommand = Commands.GATHER_RESOURCES; if (interactWith == null) { return; } MakeUnitLookAt(interactWith); // Start Sending Damage to the tree if (IsInteractionAllowed(ActionType.Gather, interactWith)) { interactWith.StartInteraction(this, currentOrder.actionType); } break; case Commands.GATHER_ITEMS: nextPos = currentOrder.p.GetWithKeyParameterValue <Vector3>("NextPos", transform.position); interactWith = newOrder.p.GetWithKeyParameterValue <InteractingComponent>("InteractWith", null); currentCommand = Commands.GATHER_ITEMS; MoveTowards(nextPos); MakeUnitLookAt(interactWith); break; case Commands.TARGET: targetUnit = newOrder.p.GetWithKeyParameterValue <InteractingComponent>("Target", null); MakeUnitLookAt(targetUnit); break; } }
public override void StartInteraction(InteractingComponent unit, ActionType actionIndex) { base.StartInteraction(unit, actionIndex); }
public static UnitOrder GenerateGetItemOrder(Vector3 basePosition, UnitBaseBehaviourComponent unit, InteractingComponent interactWith) { UnitOrder tmp = new UnitOrder(); tmp.commandName = Commands.GATHER_ITEMS; tmp.p.AddParameter <Vector3>("NextPos", NavMeshPositionGenerator.GetInstance.GenerateCandidatePosition(basePosition, 0.75f, unit, false)); tmp.p.AddParameter <InteractingComponent>("InteractWith", interactWith); return(tmp); }