Exemplo n.º 1
0
 private void Awake()
 {
     m_Anim        = GetComponent <Animator>();
     MyRigidbody2D = GetComponent <Rigidbody2D>();
     MyControl     = GetComponent <MinionControl2D>();
     MyShooter     = GetComponent <Shooter>();
     MyFog         = GetComponent <FoW.FogOfWarUnit>();
     if (IsShowHealthBar)
     {
         if (MyHealthBar == null && HealthBarPrefab)
         {
             GameObject HealthBarObject = Instantiate(HealthBarPrefab, transform);
             HealthBarObject.transform.localPosition = new Vector3(0, 0.4f, 0);
             MyHealthBar = HealthBarObject.GetComponent <HealthBar>();
             HideCharacterInFog MyHideInFog = transform.GetChild(0).GetComponent <HideCharacterInFog>();
             if (MyHideInFog)
             {
                 MyHideInFog.MyHealthBar = MyHealthBar;
             }
         }
         MyHealthBar.gameObject.SetActive(true);
         MyHealthBar.SetHealthBars(Health);
     }
     MaxHealth = Health;
     OnUpdatedAttackSpeed();
     OnUpdatedRange();
     OnUpdatedVision();
 }
Exemplo n.º 2
0
 public void AttackClosest()
 {
     if (MyBehaviour != MinionBehaviour.Attack)
     {
         MinionControl2D[] MyObjects       = GameObject.FindObjectsOfType <MinionControl2D>();
         float             ClosestDistance = MaxAttackDistance;
         MinionControl2D   ClosestObject   = null;
         for (int i = 0; i < MyObjects.Length; i++)
         {
             if (MyObjects[i] != this)
             {
                 float ThisDistance = Vector3.Distance(transform.position, MyObjects[i].transform.position);
                 if (ThisDistance < ClosestDistance)
                 {
                     ClosestDistance = ThisDistance;
                     ClosestObject   = MyObjects[i];
                 }
             }
         }
         if (ClosestObject != null)
         {
             MinimumDistanceToTarget = 0f;
             BeforeAttackBehaviour   = MyBehaviour;
             MyBehaviour             = MinionBehaviour.Attack;
             AttackTransform         = ClosestObject.transform;
         }
         else
         {
             // keep following?! or wandering
         }
     }
 }
Exemplo n.º 3
0
        private IEnumerator DisableCharacterForTime(Character2D PossibleUser)
        {
            //PossibleUser.gameObject.SetActive(false);
            UserControl2D   MyUser   = PossibleUser.gameObject.GetComponent <UserControl2D>();
            MinionControl2D MyMinion = PossibleUser.gameObject.GetComponent <MinionControl2D>();

            PossibleUser.enabled = false;
            PossibleUser.transform.GetChild(0).gameObject.SetActive(false);
            if (MyUser)
            {
                MyUser.enabled = false;
            }
            else if (MyMinion)
            {
                MyMinion.enabled = false;
            }
            yield return(new WaitForSeconds(1f));

            PossibleUser.transform.GetChild(0).gameObject.SetActive(true);
            float   TimeBegun      = Time.time;
            Vector3 OriginalVector = PossibleUser.transform.localScale;

            while (Time.time - TimeBegun <= 1.5f)
            {
                PossibleUser.transform.localScale = Vector3.Lerp(new Vector3(0.1f, 0.1f, 0.1f), OriginalVector, (Time.time - TimeBegun) / 1.5f);
                yield return(null);
            }
            PossibleUser.transform.localScale = OriginalVector;
            //PossibleUser.gameObject.SetActive(true);
            PossibleUser.enabled = true;
            if (MyUser)
            {
                MyUser.enabled = true;
            }
            else if (MyMinion)
            {
                MyMinion.enabled = true;
            }
        }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     MyController = GetComponent <MinionControl2D>();
     LastScanTime = Time.time;
 }