public Weapon_2 UsePlatina()
 {
     if (xtime <= 0)
     {
         xtime = PlatinaTime;
         int      a      = Random.Range(0, platinas_weapons.Length);
         Weapon_2 create = platinas_weapons[a];
         create.onStand  = true;
         create.standPos = weaponPosition.position;
         Vector3 scale = create.transform.localScale;
         scale.x = WeaponSize;
         scale.y = WeaponSize;
         create.transform.localScale = scale;
         Weapon_2 @object = Instantiate(create, weaponPosition.position, Quaternion.identity);
         return(@object);
         //  if (ImpactEffect != null)
         // {
         //    Instantiate(ImpactEffect, GranadePosition, Quaternion.identity);
         // }
     }
     else
     {
         return(null);
     }
 }
    public void Select()
    {
        Weapon_2 send = null;
        int      a    = Random.Range(1, 7);

        if (a == 1 && Lenghts[0] != 0)
        {
            int i = Random.Range(0, Lenghts[0]);
            send = LowChanceWeapons[i];
        }
        else
        {
            if (a > 1 && a < 4 && Lenghts[1] != 0)
            {
                int i = Random.Range(0, Lenghts[1]);
                send = MidChanceWeapons[i];
            }
            else
            {
                if (Lenghts[2] != 0)
                {
                    int i = Random.Range(0, Lenghts[2]);

                    send = HighChanceWeapons[i];
                }
            }
        }
        if (send != null)
        {
            Spawn(send);
        }
    }
    public void EquipWeapon(Weapon_2 weapon)
    {
        Vector3 Scale = weapon.transform.localScale;

        if (control.m_FacingRight)
        {
            if (Mathf.Sign(weapon.transform.localScale.x) < 0)
            {
                Scale.x *= -1;
            }
        }
        else
        {
            if (Mathf.Sign(weapon.transform.localScale.x) > 0)
            {
                Scale.x *= -1;
            }
        }

        weapon.pj      = this;
        weapon.onStand = false;
        weapon.transform.localScale = Scale;
        weapon.control    = control;
        control.weapon    = weapon;
        Grabbing          = true;
        weapon.IsGrabbed  = true;
        weapon.weaponslot = PosSlot;
        weapon.objectTag  = gameObject.tag;
        last_weapon       = weapon;
    }
    public void Spawn(Weapon_2 spawn)
    {
        spawn.onStand  = true;
        spawn.standPos = pos;
        lastWeapon     = Instantiate(spawn, pos, Quaternion.identity);
        Vector3 scale = lastWeapon.transform.localScale;

        scale.x = WeaponSize;
        scale.y = WeaponSize;
        lastWeapon.transform.localScale = scale;
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        @object = other.GetComponent <Movement>();
        weapon  = other.GetComponent <Weapon_2>();

        if (@object)
        {
            @object.TakeDamage();
        }
        else if (weapon)
        {
            Destroy(other.gameObject);
        }
    }
Ejemplo n.º 6
0
    public void Throw(float ForceUp, float UpTime)
    {
        Weapon_2    WeaponCheck      = @object.GetComponent <Weapon_2>();
        autodestroy AutoDestroyCheck = @object.GetComponent <autodestroy>();

        if (!AutoDestroyCheck)
        {
            if (WeaponCheck != null)
            {
                if (!WeaponCheck.IsGrabbed)
                {
                    @object.GetComponent <Rigidbody2D>().velocity = new Vector2(0, ForceUp * MultiplierForObjects);
                }
            }
            else
            {
                @object.GetComponent <Rigidbody2D>().velocity = new Vector2(0, ForceUp);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        MovimientoHorizontal = Input.GetAxisRaw(StrHorizontal) * VelocidadMovimiento;
        if (Input.GetButtonDown(StrJump))
        {
            salto = true;
            Anim.SetTrigger("Salto");
        }

        if (control.m_FacingRight)
        {
            multiplier = 1;
        }
        else
        {
            multiplier = -1;
        }
        control.Move(MovimientoHorizontal * Time.fixedDeltaTime, false, salto);
        salto = false;


        /*
         * if (rb.velocity.y < 0)
         * {
         *  rb.velocity += Vector2.up * Physics2D.gravity.y * (fallmultiplier - 1) * Time.fixedDeltaTime;
         * }
         * else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
         * {*/
        rb.velocity += Vector2.up * Physics2D.gravity.y * (lowjumpmultiplier - 1) * Time.fixedDeltaTime;
        // }
        if (Input.GetButtonDown(StrHab))
        {
            Debug.Log(multiplier);
            if (poderes != null)
            {
                poderes.multiplier = multiplier;

                switch (MyCharacter)
                {
                case Character.Mark:
                    poderes.UseMark();
                    break;

                case Character.Platina:
                    Weapon_2 pipo = poderes.UsePlatina();
                    if (pipo != null)
                    {
                        DropWeapon(true);
                        EquipWeapon(pipo);
                    }
                    break;
                }
            }
        }


        if (Input.GetButtonDown(StrGrab))
        {
            if (Grabbing == false)
            {
                last_weapon = null;
                Weapon_2 weapon;
                weapon = null;

                Collider2D[] weaponsTop = Physics2D.OverlapCircleAll(TopTransform.position, GrabRange, MaskWeapon);
                Collider2D[] weaponsBot = Physics2D.OverlapCircleAll(BottomTransform.position, GrabRange, MaskWeapon);

                int i;

                if (weaponsBot.Length != 0)
                {
                    i      = Random.Range(0, weaponsBot.Length);
                    weapon = weaponsBot[i].GetComponent <Weapon_2>();
                }
                if (weaponsTop.Length != 0)
                {
                    i      = Random.Range(0, weaponsTop.Length);
                    weapon = weaponsTop[i].GetComponent <Weapon_2>();
                }

                if (weapon != null)
                {
                    EquipWeapon(weapon);
                }
            }
            else
            {
                DropWeapon(true);
            }
        }
    }