bool HasWork() //смена одежды и всего остального для рабочего пня
 {
     if (earthpony.work == null)
     {
         SetAllSRorder(earthpony.myOrder);
         if (!clothAnimator.enabled)
         {
             HoodAnimator.gameObject.SetActive(true);
             clothAnimator.enabled = true;
             gotRed = true;
         }
         return(false);
     }
     else if (earthpony.work.gameObject.name == "WeaponBuilding" &&
              Vector2.Distance(earthpony.transform.position, earthpony.work.transform.position) < 2.5f && earthpony.sit && !earthpony.hunter)
     {
         SetAllSRorder(4);
         HoodAnimator.gameObject.SetActive(false);
         clothAnimator.enabled = false;
         SpriteRenderer clothSR    = clothAnimator.GetComponent <SpriteRenderer>();
         WeaponBuilding weaponWork = earthpony.work.GetComponent <WeaponBuilding>();
         if (weaponWork.worker != earthpony)
         {
             print("эта херня опять произошла - работник вылетел из кузни");
             weaponWork.worker = earthpony;
             return(false);
         }
         clothSR.sprite = weaponWork.form;
         clothSR.color  = Color.white;
         return(true);
     }
     else if (earthpony.work.gameObject.name == "Farm" &&
              Vector2.Distance(earthpony.transform.position, earthpony.work.transform.position) < 3f && earthpony.sit)
     {
         SetAllSRorder(4);
         HoodAnimator.gameObject.SetActive(false);
         clothAnimator.enabled = false;
         SpriteRenderer clothSR = clothAnimator.GetComponent <SpriteRenderer>();
         clothSR.sprite = earthpony.work.GetComponent <FarmBuild>().form;
         clothSR.color  = Color.white;
         return(true);
     }
     else
     {
         SetAllSRorder(earthpony.myOrder);
         HoodAnimator.gameObject.SetActive(true);
         clothAnimator.enabled = true;
         return(false);
     }
 }
Пример #2
0
 void CheckWork()
 {
     if (RunTo(work.transform.position, 1.6f)) //если понь близко к работе
     {
         TreeBuild tempWork = work.GetComponent <TreeBuild>();
         if (tempWork)
         {
             if (tempWork.progress >= 100)
             {
                 axing          = false;
                 tempWork.axing = false;
                 work           = null;
             }
             else
             {
                 axing          = true;
                 tempWork.axing = true;
             }
             return;
         }
         WeaponBuilding tempWork1 = work.GetComponent <WeaponBuilding>();
         if (tempWork1)
         {
             anim.SetBool("sit", true);
             sit = true;
             transform.position = tempWork1.workerPosition.position;
             positionY          = tempWork1.workerPosition.position.y;
             return;
         }
         FarmBuild tempWork2 = work.GetComponent <FarmBuild>();
         if (tempWork2)
         {
             anim.SetBool("sit", true);
             sit = true;
             transform.position = tempWork2.workerPosition.position;
             positionY          = tempWork2.workerPosition.position.y;
             return;
         }
     }
     else //если понь далеко от работы
     {
         axing = false;
         GetUp();
         maxSpeed = 4f;
     }
 }