Ejemplo n.º 1
0
        public void CheckOrder()
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                // Interactable Items / Units
                if (hit.transform.GetComponent <UnitBaseBehaviourComponent>())
                {
                    UnitBaseBehaviourComponent interactWith;
                    interactWith = hit.transform.GetComponent <UnitBaseBehaviourComponent>();
                    if (interactWith.objectType == ObjectType.Unit)
                    {
                        if (interactWith.unitAffiliation == UnitAffiliation.Enemy)
                        {
                            InteractingPopups.GetInstance.ShowInteractWithPopup(manualControlledUnit, interactWith);
                        }
                        // Check Relationship with the person clicked
                        // if Enemy you Attack
                        // if neutral, try to spawn Popup to possibly start conversation
                        return;
                    }
                    else if (interactWith.objectType == ObjectType.WorldObject)
                    {
                        if (manualControlledUnit != null)
                        {
                            InteractingPopups.GetInstance.ShowInteractWithPopup(manualControlledUnit, interactWith);
                        }
                        return;
                    }
                }
                else
                {
                    // Non-Unit Clicks (items)
                    if (hit.transform.GetComponent <ItemDrop>())
                    {
                        ItemDrop tmp = hit.transform.GetComponent <ItemDrop>();
                        MoveUnitsTowards(hit);
                        manualControlledUnit.ReceiveOrder(UnitOrder.GenerateGetItemOrder(hit.transform.position, manualControlledUnit, tmp));
                    }
                    else
                    {
                        MoveUnitsTowards(hit);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void StartSkillCasting()
        {
            startAiming = false;
            if (targetPosition == null)
            {
                targetPosition = transform.position;
            }
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                targetPosition = hit.point;
                targetPosition = new Vector3(targetPosition.x, owner.transform.position.y, targetPosition.z);
            }
            transform.position = targetPosition;

            if (spawnType == SpawnSkillType.FromCaster)
            {
                Debug.Log("FROM CASTER!");
                transform.position = new Vector3(owner.transform.position.x, owner.transform.position.y, owner.transform.position.z);
                activate           = true;
            }
            else
            {
                activate = true;
            }
            owner.ReceiveOrder(UnitOrder.GenerateIdleOrder(), true);
            owner.MakeUnitLookAt(targetPosition);
            transform.rotation = owner.transform.rotation;
        }
Ejemplo n.º 3
0
 public override void EndIndividualInteraction(UnitBaseBehaviourComponent unit)
 {
     if (gathererStats.Contains(gathererStats.Find(x => x.unitSaved == unit)))
     {
         gathererStats.Remove(gathererStats.Find(x => x.unitSaved == unit));
         interactingUnit.Remove(unit);
         if (unit.interactWith == this)
         {
             unit.ReceiveOrder(UnitOrder.GenerateIdleOrder());
         }
     }
 }