private void Start()
    {
        _transform = transform;
        _gun       = GetComponent <TurretGun>();

        _target = GameObject.FindWithTag("Player").transform;
    }
Example #2
0
 /// <summary>
 /// Create the a TurretEnemy with the default score value
 /// </summary>
 public TurretEnemy(Texture2D texture, Vector2 position, Rectangle boundingBox, int health = 10, int moveSpeed = 0) : base(health, moveSpeed, texture, position, boundingBox)
 {
     origin        = new Vector2(texture.Width / 2, texture.Height / 2);
     drawPos       = new Vector2(this.X + (BoundingBox.Width / 2), this.Y + (BoundingBox.Height / 2));
     gun           = WeaponManager.Instance.TurretGun;
     gun.X         = this.X + (BoundingBox.Width / 2);
     gun.Y         = this.Y + (BoundingBox.Height / 2);
     knockBackable = false;
 }
    public Machinegun(int x, int y)
    {
        Turret.transform.position = new Vector2(x, y);

        TurretBase.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("TurretBase");
        TurretGun.GetComponent <SpriteRenderer>().sprite  = Resources.Load <Sprite>("TurretGun");

        Cost = 70;
        TurretGun.AddComponent <MachinegunScript>();
    }
Example #4
0
    public Slowtower(int x, int y)
    {
        Turret.name  = "SlowTower";
        Turret.layer = LayerMask.NameToLayer("Tower");
        Turret.transform.position = new Vector2(x, y);

        TurretGun.AddComponent <CircleCollider2D>().isTrigger = true;
        TurretGun.GetComponent <CircleCollider2D>().radius    = 2f;

        Debug.Log(LayerMask.NameToLayer("Slowarea"));
        TurretGun.layer = LayerMask.NameToLayer("Slowarea");
        TurretBase.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("TurretBase");
        TurretGun.GetComponent <SpriteRenderer>().sprite  = Resources.Load <Sprite>("Slowturret");

        Cost = 100;
        TurretGun.AddComponent <SlowtowerScript>();
    }
Example #5
0
    public Laserbeam(int x, int y)
    {
        Turret.name    = "Laserbeam";
        TurretGun.name = "Laserbeam";

        Turret.transform.position = new Vector2(x, y);

        TurretGun.AddComponent <LineRenderer>().material   = Resources.Load <Material>("laser");
        TurretGun.GetComponent <LineRenderer>().startWidth = 0.06f;
        TurretGun.GetComponent <LineRenderer>().endWidth   = 0.06f;
        TurretGun.GetComponent <LineRenderer>().startColor = Color.white;
        TurretGun.GetComponent <LineRenderer>().endColor   = Color.cyan;

        TurretBase.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("TurretBase");
        TurretGun.GetComponent <SpriteRenderer>().sprite  = Resources.Load <Sprite>("Laserbeam");

        Cost = 70;
        TurretGun.AddComponent <LaserbeamScript>();
    }
Example #6
0
 public void Setup(TurretGun origin)
 {
     rb          = GetComponent <Rigidbody2D>();
     this.origin = origin;
     rb.AddForce(transform.up * force, forceMode);
 }
 private void Awake()
 {
     base.Awake();
     gun = transform.parent.GetComponentInChildren<TurretGun>();
 }
Example #8
0
 /// <summary>
 /// Create the a TurretEnemy with a manual score value
 /// </summary>
 public TurretEnemy(int health, int moveSpeed, Texture2D texture, Vector2 position, Rectangle boundingBox, int scoreValue) : base(health, moveSpeed, texture, position, boundingBox, scoreValue)
 {
     gun   = WeaponManager.Instance.TurretGun;
     gun.X = this.X + (BoundingBox.Width / 2);
     gun.Y = this.Y + (BoundingBox.Height / 2);
 }
    /// <summary>
    /// Inicia a máquina de estados.
    /// </summary>
    public TurretStateMachine(Transform pMyTransform)
    {
        this._idTurret = ++TURRET_ID;
        this._currentState = FiniteStateMachineType.IDLE;
        //SetNewState(FiniteStateMachineType.PATROL);

        this._distanceLimitToChasing = DISTANCELIMITTOCHASE;
        this._distanceLimitToEvade = DISTANCELIMITTOEVADE;
        this._idleTime = Random.Range(MINVALUEIDLE, MAXVALUEIDLE);
        this._patrolTIme = Random.Range(MINVALUEPATROL, MAXVALUEPATROL);

        this._myTransform = pMyTransform;
        this._tracer = new TurretTracer(this._myTransform.FindChild("Cabeca").FindChild("Camera"));
        this._target = GameObject.FindGameObjectWithTag("Player").transform;

        this._waypointSystem = new WaypointSystem(this._myTransform, this._target);
        this._navigationMesh = new TurretNavigationMesh(this._myTransform, this._myTransform.GetComponent<NavMeshAgent>());

        this._gunObject = this._myTransform.FindChild("Cabeca").FindChild("Camera").gameObject;
        this._gun = new TurretGun(this._gunObject);
    }