示例#1
0
        public static UnitOrder GenerateTargetOrder(InteractingComponent newTarget)
        {
            UnitOrder tmp = new UnitOrder();

            tmp.commandName = Commands.TARGET;
            tmp.p.AddParameter <InteractingComponent>("Target", newTarget);
            return(tmp);
        }
示例#2
0
 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);
     }
 }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        // 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);
        }
示例#7
0
        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;
            }
        }
示例#8
0
 public override void StartInteraction(InteractingComponent unit, ActionType actionIndex)
 {
     base.StartInteraction(unit, actionIndex);
 }
示例#9
0
        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);
        }