Example #1
0
 public static void Shoot(Transform firePoint, GameObject bulletPrefab, PC_Class Player)
 {
     if (Input.GetButtonDown("Fire1"))
     {
         GameObject  bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
         Rigidbody2D rb     = bullet.GetComponent <Rigidbody2D>();
         rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
         Bullet_Coll bullet_specs = bullet.GetComponent <Bullet_Coll>();
         bullet_specs.Origin = Player;
     }
 }
Example #2
0
            public static void Move(PC_Class PC)
            {
                float moveSpeed = Input.GetKey(KeyCode.LeftShift) ? PC.Speed * 2 : PC.Speed;

                Movement.x = Input.GetAxisRaw("Horizontal");
                Movement.y = Input.GetAxisRaw("Vertical");
                Vector2 MousePos = PC.Cam.ScreenToWorldPoint(Input.mousePosition);

                PC.RB.MovePosition(PC.RB.position + Movement * moveSpeed * Time.fixedDeltaTime);

                Vector2 lookDir = MousePos - PC.RB.position;
                float   angle   = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f;

                PC.RB.rotation = angle;
            }
Example #3
0
            public static void ThrowAllPotions(PC_Class PC)
            {
                Random rand = new Random();

                foreach (Items.Potion potion in PC.HP_Pots)
                {
                    HpPrefab.GetComponent <Items.Potion>().AmountHealed = potion.AmountHealed;
                    GameObject  ThisPotion = Instantiate(HpPrefab, PC.firePoint.position, PC.firePoint.rotation);
                    Rigidbody2D rb         = ThisPotion.GetComponent <Rigidbody2D>();
                    rb.AddForce(new Vector2(Random.Range(0, 360), Random.Range(0, 360)), ForceMode2D.Force);
                }
                PC.HP_Pots.Clear();
                foreach (Items.Potion potion in PC.MP_Pots)
                {
                    MpPrefab.GetComponent <Items.Potion>().AmountHealed = potion.AmountHealed;
                    GameObject  ThisPotion = Instantiate(MpPrefab, PC.firePoint.position, PC.firePoint.rotation);
                    Rigidbody2D rb         = ThisPotion.GetComponent <Rigidbody2D>();
                    rb.AddForce(new Vector2(Random.Range(0, 360), Random.Range(0, 360)), ForceMode2D.Force);
                }
                PC.MP_Pots.Clear();
            }
Example #4
0
 public static void Die(PC_Class PC)
 {
     Debug.Log("DEAD");
     ThrowAllPotions(PC);
     Destroy(PC.gameObject);
 }