Esempio n. 1
0
 private void ExecuteTask_TaskWeaponToWeaponSlot(Task.TaskWeaponToWeaponSlot task)
 {
     worker.MoveTo(task.weaponPosition, () =>
     {
         task.grabWeapon(this);
         worker.MoveTo(task.weaponSlotPosition, () =>
         {
             task.dropWeapon();
             state = State.WaitingForNextTask;
         });
     });
 }
Esempio n. 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            type = 1;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            type = 2;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            type = 3;
        }
        if (Input.GetMouseButtonDown(0))
        {
            switch (type)
            {
            case 1:
                GameObject weapon = CreateWeapon(UtilityClass.GetMouseWorldPos());
                taskSystem.EnqueueTask(() =>
                {
                    if (weaponSlot.IsEmpty())
                    {
                        weaponSlot.SetHasWeaponIncoming(true);
                        Task task = new Task.TaskWeaponToWeaponSlot
                        {
                            weaponPosition     = weapon.transform.position,
                            weaponSlotPosition = weaponSlot.GetPosition(),
                            grabWeapon         = (WorkerTaskAI workerAI) =>
                            {
                                weapon.transform.SetParent(workerAI.transform);
                            },
                            dropWeapon = () =>
                            {
                                weaponSlot.SetWeaponTransform(weapon.transform);
                            }
                        };
                        return(task);
                    }
                    else
                    {
                        return(null);
                    }
                });
                break;

            case 2: CreateWeaponSlot(UtilityClass.GetMouseWorldPos()); break;

            case 3: CreateTask(); break;

            default:
                break;
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            Task task = new Task.Victory
            {
            };
            taskSystem.AddTask(task);
        }
    }