Exemplo n.º 1
0
 public override void deactivate(AttackerStats attacker)
 {
     this.gameObject.transform.GetChild(0).gameObject.GetComponent <ParticleSystem>().Stop();
     if (FindObjectOfType <SoundManagers>().IsPlaying("level_up"))
     {
         FindObjectOfType <SoundManagers>().Stop("level_up");
     }
 }
Exemplo n.º 2
0
 public override void updateZone(AttackerStats attacker)
 {
     attacker.crystals += attacker.miningValue * Time.deltaTime;
     if (!FindObjectOfType <SoundManagers>().IsPlaying("level_up"))
     {
         FindObjectOfType <SoundManagers>().Play("level_up");
     }
 }
 private void Awake()
 {
     if (instance != null)
     {
         Debug.LogWarning("There is another AttackerStats instance");
         return;
     }
     instance = this;
 }
    // Update is called once per frame
    void Update()
    {
        AttackerStats attacker = GetComponentInParent(typeof(AttackerStats)) as AttackerStats;



        if (Input.GetKey(KeyCode.Z))          //forward
        {
            GetComponent <Rigidbody2D>().AddForce(transform.up * acceleration_amount * attacker.moveSpeedCoeff * Time.deltaTime);
        }
        // if (Input.GetKey(KeyCode.S)) {//back
        //  GetComponent<Rigidbody2D>().AddForce((-transform.up) * acceleration_amount * attacker.moveSpeedCoeff * Time.deltaTime);

        // }
        if (slideAttaque == true)
        {
            if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.Q))              //slide left
            {
                GetComponent <Rigidbody2D>().AddForce((-transform.right) * acceleration_amount * attacker.moveSpeedCoeff * 0.6f * Time.deltaTime);
                //print ("strafeing");
            }
            if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))              //slide right
            {
                GetComponent <Rigidbody2D>().AddForce((transform.right) * acceleration_amount * attacker.moveSpeedCoeff * 0.6f * Time.deltaTime);
            }
        }

        if (!Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))          //turn right
        {
            GetComponent <Rigidbody2D>().AddTorque(-rotation_speed * attacker.rotateSpeedCoeff * Time.deltaTime);
        }
        if (!Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.Q))          //turn left
        {
            GetComponent <Rigidbody2D>().AddTorque(rotation_speed * attacker.rotateSpeedCoeff * Time.deltaTime);
        }
        if (Input.GetKey(KeyCode.S))          //stop move
        {
            GetComponent <Rigidbody2D>().angularVelocity = Mathf.Lerp(GetComponent <Rigidbody2D>().angularVelocity, 0, rotation_speed * attacker.rotateSpeedCoeff * 0.06f * Time.deltaTime);
            GetComponent <Rigidbody2D>().velocity        = Vector2.Lerp(GetComponent <Rigidbody2D>().velocity, Vector2.zero, acceleration_amount * attacker.moveSpeedCoeff * 0.06f * Time.deltaTime);
        }


        Vector3 upLeft    = Camera.main.ScreenToWorldPoint(new Vector3(0, Screen.height, 0));
        Vector3 downLeft  = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0));
        Vector3 downRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0));
        Vector3 upRight   = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
        Vector3 vel       = GetComponent <Rigidbody2D>().velocity;

        // Debug.Log("transform.position.y ALO: " + transform.position.y);
        // Debug.Log("transform.position.z ALO: " + transform.position.z);
        // Debug.Log("transform.position.x ALO: " + transform.position.x);
        // X axis
        if (transform.position.x <= upLeft.x)
        {
            Debug.Log("CC");
            transform.position = new Vector3(upLeft.x, transform.position.y, 0);
        }
        else if (transform.position.x >= upRight.x)
        {
            transform.position = new Vector3(upRight.x, transform.position.y, 0);
        }

        // Y axis
        if (transform.position.y <= downLeft.y)
        {
            transform.position = new Vector3(transform.position.x, downLeft.y, 0);
        }
        else if (transform.position.y >= upLeft.y)
        {
            transform.position = new Vector3(transform.position.x, upLeft.y, 0);
        }
    }
Exemplo n.º 5
0
 private void Start()
 {
     stats = AttackerStats.instance;
 }
Exemplo n.º 6
0
 public virtual void activate(AttackerStats attacker)
 {
 }
Exemplo n.º 7
0
 public virtual void updateZone(AttackerStats attacker)
 {
 }