Ejemplo n.º 1
0
 public void OnMouseDown()
 {
     //Debug.Log("try to build");
     if (Taken == false &&
         !SMaster.gameObject.GetComponent <Script_SceneMaster>().Pause&&
         SMaster.gameObject.GetComponent <Script_SceneMaster>().ActiveFoundation == null &&
         SMaster.gameObject.GetComponent <Script_SceneMaster>().FoundationPlaceable)
     {
         GameObject Panel = Instantiate(PanelPre, PanelPre.transform.position, PanelPre.transform.rotation);
         SMaster.GetComponent <Script_SceneMaster>().SetFoundation(this.gameObject);
         Panel.GetComponent <Script_Towerselect>().pos = this.transform.position;
         anim.SetBool("Pressed", true);
     }
 }
Ejemplo n.º 2
0
    void Update()
    {
        if (countdown > 0)
        {
            countdown -= 1 * Time.deltaTime * SMaster.GetComponent <Script_SceneMaster>().GameSpeed;
        }
        if (countdown < 0)
        {
            countdown = 0;
        }

        if ((target == null))
        {
            SetTarget();
        }
        else if (Preference == 4 && target.gameObject.GetComponent <Script_enemie01>().SlowTimer > 0)
        {
            SetTarget();
        }
        else
        {
            if (Vector3.Distance(target.transform.position, this.transform.parent.transform.position) <= range * RangeSearchAddition)
            {
                Vector3 AimAt = target.transform.position;
                AimAt.x -= this.transform.position.x;
                AimAt.y -= this.transform.position.y;

                angle = (Mathf.Atan2(AimAt.x, AimAt.y) * Mathf.Rad2Deg);
                if (angle < 0)
                {
                    angle += 360;
                }


                if (Checkrot(lookangle, angle, 5f))
                {
                    if (countdown <= 0)
                    {
                        Shoot();
                    }
                }
                else
                {
                    float diff = angle - lookangle;
                    if (diff < 0f)
                    {
                        diff += 360f;
                    }
                    if (diff >= 180f)
                    {
                        lookangle -= 5;
                        if (lookangle <= -1f)
                        {
                            lookangle = 359f;
                        }
                    }
                    else
                    {
                        lookangle += 5;
                        if (lookangle >= 360f)
                        {
                            lookangle = 0f;
                        }
                    }
                }
            }
            else
            {
                target = null;
            }
        }


        for (int i = 0; i <= 7; i++)
        {
            if (Checkrot(lookangle, ((float)i * 45), 22.5f))
            {
                AniWeapon.SetInteger("Facing", i);
            }
        }
    }