Пример #1
0
 private void DepositCargo()
 {
     pathfinder.Stop();
     state = DroneStates.Idle;
     Destroy(cargo.gameObject);
     Target.GetComponentInParent <Building>().IncreaseCompletion(0.1f);
     Debug.Log("capsule delivered");
     GameData.Instance.Capsules += 1;
     xpHandler.AddExperience(10);
 }
Пример #2
0
    IEnumerator DroneAppearDelay()
    {
        DroneState = DroneStates.NotReady;
        yield return(new WaitForSeconds(Random.Range(timeBeforeRepairMin, timeBeforeRepairMax)));

        timeBeforeRepairMin += ProgressionTime;
        timeBeforeRepairMax += ProgressionTime;
        CreateRepairTarget();
        DroneState = DroneStates.Ready;
    }
Пример #3
0
    protected override void SetupAttributes()
    {
        Name          = "Drone";
        elevation     = 0.5f;
        baseSpeed     = 7f;
        baseTurnSpeed = 15f;

        task  = WorkerTasks.Gather;
        state = DroneStates.Idle;

        Friendly   = true;  // TODO set somewhere else (on spawn)
        UnitActive = true;
    }
Пример #4
0
 private void CheckTargetsExist()
 {
     if (Target == null && state == DroneStates.Gathering)
     {
         state = DroneStates.Idle;
     }
     if (Target == null && state == DroneStates.Building)
     {
         Target = FindFacilityEntry();
         pathfinder.FindPath();
     }
     if (cargo == null && state == DroneStates.Building)
     {
         state = DroneStates.Idle;
     }
 }
Пример #5
0
    public override void TargetReached()
    {
        switch (state)
        {
        case DroneStates.Gathering:
            state = DroneStates.Building;
            cargo = Target;
            cargo.GetComponent <Collider>().enabled = false;
            Target = FindFacilityEntry();
            pathfinder.FindPath();
            break;

        case DroneStates.Building:
            DepositCargo();
            break;
        }
    }
Пример #6
0
 private void CancelActionsIfSetToIdle()
 {
     if (task == WorkerTasks.Idle && state != DroneStates.Idle)
     {
         if (Target != null && Target.GetComponent <Capsule>() != null)
         {
             Target.GetComponent <Capsule>().Assigned = false;
             Target = null;
         }
         if (cargo != null && cargo.GetComponent <Capsule>() != null)
         {
             cargo.GetComponent <Capsule>().Assigned = false;
             cargo.GetComponent <Collider>().enabled = false;
             cargo = null;
         }
         pathfinder.Stop();
         state = DroneStates.Idle;
     }
 }
Пример #7
0
    private void FindResourceToGather()
    {
        GameObject[] resources = GameObject.FindGameObjectsWithTag("Resource");
        if (resources.Length == 0)
        {
            return;
        }

        for (int i = 0; i < resources.Length; i++)
        {
            if (!resources[i].GetComponent <Capsule>().Assigned&& resources[i].GetComponent <Capsule>().Landed)
            {
                Target = resources[i].transform;
                Target.GetComponent <Capsule>().Assigned = true;
                state = DroneStates.Gathering;

                pathfinder.FindPath();
                break;
            }
        }
    }
Пример #8
0
 public override void FindAnotherPath()
 {
     Target = null;
     state  = DroneStates.Idle;
 }
Пример #9
0
 void KillDrone()
 {
     CurrentState = DroneStates.Dead;
     DroneAnimation.Play("Dissolve");
     DissolveCo = StartCoroutine(KillDroneCO());
 }