public static void CreateGun() { GunUpgrade asset = ScriptableObject.CreateInstance <GunUpgrade>(); AssetDatabase.CreateAsset(asset, "Assets/Resources/UpGrades/Guns/newGun.asset"); AssetDatabase.SaveAssets(); }
void SelectWeapon(GameObject go) { if (allienGun == null || weaponTypeGameObject == null) { InitComponents(); } GunUpgrade bullet = go.GetComponent <GunUpgrade>(); allienGun.changeBulletType(go); //print(bullet.GetGunColor()); allienGun.SwapColor(bullet.GetGunColor()); GameObject.FindGameObjectWithTag("WeaponTypeUI").GetComponent <SpriteRenderer>().sprite = bullet.GetWeaponIcon(); }
public static void applyGunUpgrade(GunUpgrade gunUpgrade) { switch (gunUpgrade) { case GunUpgrade.Multishot: CharacterController.Instance.hasMutishot = true; break; case GunUpgrade.Autoguide: CharacterController.Instance.hasAutoGuidShot = true; break; case GunUpgrade.Charging: CharacterController.Instance.hasChargingShot = true; break; case GunUpgrade.Ice: CharacterController.Instance.hasIceShot = true; break; case GunUpgrade.Fire: CharacterController.Instance.hasFireShot = true; break; case GunUpgrade.Thunder: CharacterController.Instance.hasThunderShot = true; break; case GunUpgrade.Damage: CharacterController.Instance.activeGunBonusDamage(); break; case GunUpgrade.Piercing: CharacterController.Instance.hasPiercingShot = true; break; case GunUpgrade.Bouncing: CharacterController.Instance.hasBouncingShot = true; break; default: throw new ArgumentOutOfRangeException(nameof(gunUpgrade), gunUpgrade, null); } }
public void AddToGunUpgrade(GunUpgrade upgrade) { gunUpgrade.Add(upgrade.type); }
void Update() { if (Time.timeScale == 0) { return; } transform.rotation.Set(0.0f, 0.0f, 0.0f, transform.rotation.w); if (Input.GetButtonDown("Fire") && !mWeeb.IsStunned() && mBulletPrefab.GetComponent <GunUpgrade>().canInstatiateNewBullet()) { // Shoot bullet GameObject bulletObject = Instantiate(mBulletPrefab, transform.position, Quaternion.identity) as GameObject; GunUpgrade bullet = bulletObject.GetComponent <GunUpgrade>(); Vector2 facingDirection = mWeeb.GetFacingDirection(); Vector2 cursorPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); bDirection = cursorPos - (Vector2)transform.position; bDirection.Normalize(); if (bDirection.x < 0 && facingDirection == Vector2.right || (bDirection.x > 0 && facingDirection == Vector2.left)) { if (bDirection.y > 0) { bDirection = Vector2.up; } else { bDirection = Vector2.down; } } /*else if (bDirection.x > 0 && facingDirection == Vector2.left) * { * if (bDirection.y > 0.0f) bDirection = Rotate(Vector2.up, 30); * else bDirection = Rotate(Vector2.down, -30); * }*/ // Set direction of bullet bullet.SetDirection(bDirection); /*Debug.Log(Vector2.Angle(cursorPos, (Vector2)transform.position)); * if(bDirection.y > 0) * { * transform.Rotate(Vector3.forward, Vector2.Angle((Vector2)transform.position, cursorPos) * 2 * 3.14f); * } * else * { * transform.Rotate(Vector3.forward, -Vector2.Angle((Vector2)transform.position, cursorPos)*2*3.14f); * }*/ // Set animation paramsd mShooting = true; mTime = 0.0f; // Play sound mBusterSound.Play(); } if (mShooting) { mTime += Time.deltaTime; if (mTime > kShootDuration) { mShooting = false; } } UpdateAnimator(); }