Ejemplo n.º 1
0
    public void spawnBullet()
    {
        // TODO bullet sound
        OTAnimatingSprite bullet;

        bullet = (OTAnimatingSprite)GameObject.Instantiate(bulletPrefab);
        bullet.transform.parent = bullets.transform;
        bulletsInGame.Add(bullet);
        bullet.name = "bullet-" + ++bulletCounter;

        if (currentBullet == bulletType.Supernova)
        {
            bullet.image = bulletSupernova;
            bullet.size.Set(16, 16);
            bullet.tag = "bulletSupernova";
            audio.PlayOneShot(fireSupernovaSound);
        }
        else if (currentBullet == bulletType.Freeze)
        {
            bullet.image = bulletFreeze;
            bullet.size.Set(16, 16);
            bullet.tag = "bulletFreeze";
            audio.PlayOneShot(fireFreezeSound);
        }
        else
        {
            audio.PlayOneShot(fireSound);
        }

        currentBullet = bulletType.Standard;
        cannon.GetComponent <Cannon>().setSpecialBullet(0);
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        enemiesInGame = new List <OTSprite>();
        bulletsInGame = new List <OTAnimatingSprite>();
        starLst       = new List <OTSprite>();

        enemies = new GameObject("Enemies");
        bullets = new GameObject("Bullets");

        enemyCounter  = 0;
        bulletCounter = 0;

        currentBullet = bulletType.Standard;

        bombCount = 3;

        scoreText  = GameObject.Find("scoreGUI").GetComponent <GUIText>();
        shieldText = GameObject.Find("shieldGUI").GetComponent <GUIText>();
        fuelText   = GameObject.Find("fuelGUI").GetComponent <GUIText>();
        bombsText  = GameObject.Find("bombsGUI").GetComponent <GUIText>();

        InitializeObjects();

        score = 0;
        //playing = true;
        unsetPause();
        bombLaunched = false;
    }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     currentAmmo   = maxAmmo;
     body          = gameObject.GetComponent <Rigidbody>();
     shootingTimer = maxShootingTimer;
     currentBullet = bulletType.normal;
 }
Ejemplo n.º 4
0
        public Bullet fire(int x, int y, PlayerDir dir, bulletOwner owner, bulletType type)
        {
            Bullet bullet = new Bullet();

            bullet.x = x;
            bullet.y = y;

            int vel    = 0;
            int width  = 0;
            int height = 0;

            switch (type)
            {
            case bulletType.SMALL:     //adjust properties here
                vel    = 8;
                width  = 9;
                height = 9;
                break;

            case bulletType.SWORD:     // no bullets if a sword is the weapon
                vel    = 0;
                width  = 36;
                height = 36;
                break;
            }

            switch (dir) // determine direction the character is looking, so we know what trail to fire the bullets in
            {
            case PlayerDir.UP:
                bullet.vel_x = 0;
                bullet.vel_y = -vel;
                break;

            case PlayerDir.DOWN:
                bullet.vel_y = vel;
                bullet.vel_x = 0;
                break;

            case PlayerDir.LEFT:
                bullet.vel_x = -vel;
                bullet.vel_y = 0;
                break;

            case PlayerDir.RIGHT:
                bullet.vel_x = vel;
                bullet.vel_y = 0;
                break;
            }

            bullet.owner   = owner;
            bullet.type    = type;
            bullet.width   = width;
            bullet.height  = height;
            bullet.col_tok = game_state.coll_engine.register_object(bullet, ColType.BULLET);
            //set some final bullet properties

            bullets.Add(bullet); // add the bullet to the list to be displayed later

            return(bullet);
        }
Ejemplo n.º 5
0
        public Bullet fire(int x, int y, PlayerDir dir, bulletOwner owner, bulletType type)
        {
            Bullet bullet = new Bullet();

            bullet.x = x;
            bullet.y = y;

            int vel    = 0;
            int width  = 0;
            int height = 0;

            switch (type)
            {
            case bulletType.SMALL:
                vel    = 8;
                width  = 9;
                height = 9;
                break;

            case bulletType.SWORD:
                vel    = 0;
                width  = 36;
                height = 36;
                break;
            }

            switch (dir)
            {
            case PlayerDir.UP:
                bullet.vel_x = 0;
                bullet.vel_y = -vel;
                break;

            case PlayerDir.DOWN:
                bullet.vel_y = vel;
                bullet.vel_x = 0;
                break;

            case PlayerDir.LEFT:
                bullet.vel_x = -vel;
                bullet.vel_y = 0;
                break;

            case PlayerDir.RIGHT:
                bullet.vel_x = vel;
                bullet.vel_y = 0;
                break;
            }

            bullet.owner   = owner;
            bullet.type    = type;
            bullet.width   = width;
            bullet.height  = height;
            bullet.col_tok = game_state.coll_engine.register_object(bullet, ColType.BULLET);

            bullets.Add(bullet);

            return(bullet);
        }
Ejemplo n.º 6
0
    public void SetBulletType(Player p, int i)
    {
        player            = p;
        currentBulletType = i;
        bulletType cbt = Bullets.bullets[currentBulletType];

        this.bulletName = cbt.bulletName;
        this.speed      = cbt.speed;
    }
Ejemplo n.º 7
0
    private void SetBulletType(int newBulletIdx)
    {
        bulletType type = bulletTypes[newBulletIdx];

        bulletDamage     = type.bulletDamage;
        shootingInterval = type.shootingInterval;
        bulletSpeed      = type.bulletSpeed;
        bulletPrefab     = type.bulletPrefab;
    }
Ejemplo n.º 8
0
 public Bullet(Vector2 dir, Vector2 pos, bulletType Type)
 {
     this.direction = dir;
     this.position  = pos;
     this.speed     = 10;
     boundingBox    = new Rectangle((int)position.X, (int)position.Y, (int)(16), (int)(16));
     texture        = Game1.content.Load <Texture2D>(@"Bullet");
     type           = Type;
 }
Ejemplo n.º 9
0
 void Start()
 {
     Destroy(gameObject, 10f);
     rb = GetComponent <Rigidbody2D> ();
     if (type == null)
     {
         type = bulletType.RED;
     }
 }
Ejemplo n.º 10
0
        public Bullet fire(int x, int y, PlayerDir dir, bulletOwner owner, bulletType type)
        {
            Bullet bullet = new Bullet();
            bullet.x = x;
            bullet.y = y;

            int vel = 0;
            int width = 0;
            int height = 0;
            switch (type)
            {
                case bulletType.SMALL: //adjust properties here
                    vel = 8;
                    width = 9;
                    height = 9;
                    break;
                case bulletType.SWORD: // no bullets if a sword is the weapon
                    vel = 0;
                    width = 36;
                    height = 36;
                    break;
            }

            switch (dir) // determine direction the character is looking, so we know what trail to fire the bullets in
            {
                case PlayerDir.UP:
                    bullet.vel_x = 0;
                    bullet.vel_y = -vel;
                    break;
                case PlayerDir.DOWN:
                    bullet.vel_y = vel;
                    bullet.vel_x = 0;
                    break;
                case PlayerDir.LEFT:
                    bullet.vel_x = -vel;
                    bullet.vel_y = 0;
                    break;
                case PlayerDir.RIGHT:
                    bullet.vel_x = vel;
                    bullet.vel_y = 0;
                    break;
            }

            bullet.owner = owner;
            bullet.type = type;
            bullet.width = width;
            bullet.height = height;
            bullet.col_tok = game_state.coll_engine.register_object(bullet, ColType.BULLET);
            //set some final bullet properties

            bullets.Add(bullet); // add the bullet to the list to be displayed later

            return bullet;
        }
Ejemplo n.º 11
0
        public Bullet fire(int x, int y, PlayerDir dir, bulletOwner owner, bulletType type)
        {
            Bullet bullet = new Bullet();
            bullet.x = x;
            bullet.y = y;

            int vel = 0;
            int width = 0;
            int height = 0;
            switch (type)
            {
                case bulletType.SMALL:
                    vel = 8;
                    width = 9;
                    height = 9;
                    break;
                case bulletType.SWORD:
                    vel = 0;
                    width = 36;
                    height = 36;
                    break;
            }

            switch (dir)
            {
                case PlayerDir.UP:
                    bullet.vel_x = 0;
                    bullet.vel_y = -vel;
                    break;
                case PlayerDir.DOWN:
                    bullet.vel_y = vel;
                    bullet.vel_x = 0;
                    break;
                case PlayerDir.LEFT:
                    bullet.vel_x = -vel;
                    bullet.vel_y = 0;
                    break;
                case PlayerDir.RIGHT:
                    bullet.vel_x = vel;
                    bullet.vel_y = 0;
                    break;
            }

            bullet.owner = owner;
            bullet.type = type;
            bullet.width = width;
            bullet.height = height;
            bullet.col_tok = game_state.coll_engine.register_object(bullet, ColType.BULLET);

            bullets.Add(bullet);

            return bullet;
        }
Ejemplo n.º 12
0
 public void initialize(Vector2 dir, Vector2 pos, bulletType Type, float dmg)
 {
     textureRectangle = new Rectangle(0, 0, 65, 32);
     this.direction   = dir;
     this.position    = pos;
     this.speed       = 10;
     this.dmg         = dmg;
     boundingBox      = new Rectangle((int)position.X, (int)position.Y, (int)(16), (int)(16));
     texture          = Game1.content.Load <Texture2D>(@"Bullet");
     type             = Type;
     currentFrame     = 0;
 }
Ejemplo n.º 13
0
    void Start()
    {
        currentAmmo    = maxAmmo;
        body           = gameObject.GetComponent <Rigidbody>();
        shootingTimer  = maxShootingTimer;
        currentBullet  = bulletType.normal;
        reloadTimer    = reloadSpeed;
        shootDirection = startLook;
        shootDirection.Normalize();

        audio = GetComponent <AudioSource>();
    }
Ejemplo n.º 14
0
 public DesperadoShot checkShot(bulletType part)
 {
     for (int i = 0; i < 6; i++)
     {
         if (EquippedShots[i].bPart == part)
         {
             return(EquippedShots[i]);
         }
     }
     //SaveShot();
     return(new DesperadoShot());
 }
Ejemplo n.º 15
0
    void changeBulletType()
    {
        int scrollAmount = (int)Input.mouseScrollDelta.y;

        if (scrollAmount != 0)
        {
            curBulletType = (bulletType)(((int)curBulletType + (int)(Input.mouseScrollDelta.y)) % typesLength);
            if ((int)curBulletType == -1)
            {
                curBulletType = (bulletType)(typesLength - 1);
            }
            //Debug.Log("switched to " + curBulletType.ToString() + "Bullet");
        }
    }
Ejemplo n.º 16
0
    void BulletSwitching()
    {
        //R1 button:
        if (Input.GetAxis("R1 Button") > 0f && timeSinceBulletSwitch > bulletSwitchTime)
        {
            bulletSwitchTime = 1f;
            switch (bullettype)
            {
            case bulletType.fire:
                bullettype = bulletType.water;
                break;

            case bulletType.water:
                bullettype = bulletType.earth;
                break;

            case bulletType.earth:
                bullettype = bulletType.fire;
                break;
            }
            timeSinceBulletSwitch = 0f;
        }
        //L1 Button:
        else if (Input.GetAxis("L1 Button") > 0f && timeSinceBulletSwitch > bulletSwitchTime)
        {
            bulletSwitchTime = 1f;
            switch (bullettype)
            {
            case bulletType.fire:
                bullettype = bulletType.earth;
                break;

            case bulletType.water:
                bullettype = bulletType.fire;
                break;

            case bulletType.earth:
                bullettype = bulletType.water;
                break;
            }
            timeSinceBulletSwitch = 0f;
        }
        //else
        //{
        //    bulletSwitchTime = 0f;
        //}

        timeSinceBulletSwitch += Time.deltaTime;
    }
Ejemplo n.º 17
0
 public void setBulletType(bulletType type)
 {
     if (type == bulletType.Supernova)
     {
         currentBullet = bulletType.Supernova;
         cannon.GetComponent <Cannon>().setSpecialBullet(1);
         audio.PlayOneShot(getSupernovaSound);
     }
     if (type == bulletType.Freeze)
     {
         currentBullet = bulletType.Freeze;
         cannon.GetComponent <Cannon>().setSpecialBullet(2);
         audio.PlayOneShot(getFreezeSound);
     }
 }
Ejemplo n.º 18
0
    void DestroyObject(bulletType type)
    {
        switch (type)
        {
        case bulletType.RED:
            Destroy(gameObject);
            KillCounter++;
            break;

        case bulletType.BLUE:
            Destroy(gameObject);
            KillCounter++;
            break;
        }
    }
Ejemplo n.º 19
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "powerUp")
        {
            powerUp newpower = collision.gameObject.GetComponent <powerUp>();
            currentBullet = (bulletType)newpower.currentPower;
            switch (currentBullet)
            {
            case bulletType.normal:
            {
                currentAmmo = 10;
                break;
            }

            case bulletType.bouncy:
            {
                currentAmmo = 10;
                break;
            }

            case bulletType.explosive:
            {
                currentAmmo = 4;
                break;
            }

            case bulletType.fast:
            {
                currentAmmo = 7;
                break;
            }

            case bulletType.spread:
            {
                currentAmmo = 10;
                break;
            }

            case bulletType.burst:
            {
                currentAmmo = 5;
                break;
            }
            }
            Destroy(collision.gameObject);
        }
    }
Ejemplo n.º 20
0
    // Start is called before the first frame update
    void Start()
    {
        bullettype = bulletType.fire;

        m_rigidbody = GetComponent <Rigidbody>();

        moveSpeed = 10f;

        timeBetweenShots = 0.15f;
        timePassed       = 0f;

        timeSinceBulletSwitch = 0f;
        bulletSwitchTime      = 1f; //To change this also change values in the BulletSwitching() function.


        playerHealth = 100;
    }
Ejemplo n.º 21
0
 public override void Fire(Vector2 position, Vector2 direction, bulletType type, float dmg)
 {
     if (direction.X > 0)
     {
         for (int i = 0; i < 1; i++)
         {
             Bullet temp = Game1.retrieveBullet();
             temp.initialize(direction, new Vector2(position.X + 96, position.Y + 64), bulletType.Friendly, dmg);
             Game1.addBullet(temp);
         }
     }
     else if (direction.X < 0)
     {
         for (int i = 0; i < 1; i++)
         {
             Bullet temp = Game1.retrieveBullet();
             temp.initialize(direction, new Vector2(position.X, position.Y + 64), bulletType.Friendly, dmg);
             Game1.addBullet(temp);
         }
     }
 }
Ejemplo n.º 22
0
    //Rotating Function:
    void RightStick(bulletType bt)
    {
        //Getting input from controller:
        Vector3 playerDirection = new Vector3(Input.GetAxisRaw("RHorizontalJ1"), 0f, -Input.GetAxisRaw("RVerticalJ1"));

        //Checking for any input at all:
        if (playerDirection.sqrMagnitude > 0f)
        {
            //rotating player:
            transform.rotation = Quaternion.LookRotation(playerDirection, Vector3.up);

            //Shooting:
            if (timePassed > timeBetweenShots)
            {
                timePassed = 0;

                switch (bt)
                {
                case bulletType.normal:
                    Instantiate(bulletObject, transform.position + playerDirection, Quaternion.LookRotation(playerDirection, Vector3.up));
                    break;

                case bulletType.fire:
                    Instantiate(fireBulletObject, transform.position + playerDirection, Quaternion.LookRotation(playerDirection, Vector3.up));
                    break;

                case bulletType.water:
                    Instantiate(waterBulletObject, transform.position + playerDirection, Quaternion.LookRotation(playerDirection, Vector3.up));
                    break;

                case bulletType.earth:
                    Instantiate(earthBulletObject, transform.position + playerDirection, Quaternion.LookRotation(playerDirection, Vector3.up));
                    break;
                }
            }
        }

        timePassed += Time.deltaTime;
    }
Ejemplo n.º 23
0
 public void Dead()
 {
     type = bulletType.Dead;
 }
Ejemplo n.º 24
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "powerUp")
        {
            audio.PlayOneShot(powerUpSound);
            powerUp newpower = collision.gameObject.GetComponent <powerUp>();
            currentBullet = (bulletType)newpower.currentPower;
            hasReloaded   = true;
            reloadTimer   = reloadSpeed;
            switch (currentBullet)
            {
            case bulletType.normal:
            {
                maxAmmo                = 10;
                currentAmmo            = 10;
                gunType.sprite         = normalGun;
                ammoTracker.fillAmount = maxAmmo / maxAmmo;
                break;
            }

            case bulletType.bouncy:
            {
                maxAmmo                = 10;
                currentAmmo            = 10;
                gunType.sprite         = bounceGun;
                ammoTracker.fillAmount = maxAmmo / maxAmmo;
                break;
            }

            case bulletType.explosive:
            {
                maxAmmo                = 4;
                currentAmmo            = 4;
                gunType.sprite         = explosiveGun;
                ammoTracker.fillAmount = maxAmmo / maxAmmo;
                break;
            }

            case bulletType.fast:
            {
                maxAmmo                = 7;
                currentAmmo            = 7;
                gunType.sprite         = fastGun;
                ammoTracker.fillAmount = maxAmmo / maxAmmo;
                break;
            }

            case bulletType.spread:
            {
                maxAmmo                = 10;
                currentAmmo            = 10;
                gunType.sprite         = spreadGun;
                ammoTracker.fillAmount = maxAmmo / maxAmmo;
                break;
            }

            case bulletType.burst:
            {
                maxAmmo                = 5;
                currentAmmo            = 5;
                gunType.sprite         = burstGun;
                ammoTracker.fillAmount = maxAmmo / maxAmmo;
                break;
            }
            }
            Destroy(collision.gameObject);
        }
    }
Ejemplo n.º 25
0
 public BulletType(bulletType type)
 {
     this.type = type;
 }
Ejemplo n.º 26
0
 abstract public void Fire(Vector2 playerPos, Vector2 direction, bulletType type, float dmg);
Ejemplo n.º 27
0
 // sets the current bullet type
 public void SetCurrentBulletType(bulletType newType)
 {
     currBulletType = newType;
 }
Ejemplo n.º 28
0
 // sets the current bullet type
 public void SetCurrentBulletType(int newType)
 {
     currBulletType = (bulletType)Mathf.Clamp(newType, 0, BULLET_TYPE_COUNT);
 }
Ejemplo n.º 29
0
    public void Hit(int Damage,string HitName,float nuckBackDistance,Vector3 pos=default(Vector3),bulletType type=bulletType.common) //공격받을때 공격한사람 이름도 받음
    {
        if (passive.padding > 0)
            nuckBackDistance = 0;
        if (!isSuper&&pv.IsMine && !isDead && !SUPERRRRRRR)
        {
            switch (type)
            {
                case bulletType.snow:
                    break;
                case bulletType.mushroom:
                    break;
                case bulletType.electric:
                    pos=Vector3.zero;
                    canMove = false;
                    rb.velocity=Vector2.zero;
                    rb.DOMove(transform.position, nuckBackTime*2).SetEase(nuckBackEase).OnComplete(()=> { if(!isDead) canMove = true; });
                    break;
            }
            
            hitSound();

            if (pos != Vector3.zero&& nuckBackDistance!=0)
            {
                Vector3 dir = (transform.position - pos).normalized;
                canMove = false;
                rb.velocity=Vector2.zero;
                rb.DOMove(transform.position+dir * nuckBackDistance, nuckBackTime).SetEase(nuckBackEase).OnComplete(()=> { if(!isDead) canMove = true; });   
            }

            if (PhotonNetwork.OfflineMode) 
                flashWhiteRPC();
            else
                pv.RPC("flashWhiteRPC",RpcTarget.All); 
            
            isFight();
            if(statMgr.Hit(Damage))
                Die(HitName);
        }
    }
Ejemplo n.º 30
0
 public void setType(bulletType tyyppi)
 {
     type = tyyppi;
 }
Ejemplo n.º 31
0
    void shootProjectile()
    {
        switch (currentBullet)
        {
        case bulletType.normal:
        {
            //default bullet
            BulletController bulletSpawn = Instantiate(projectile, spawner.transform.position, Quaternion.identity).GetComponent <BulletController>();
            bulletSpawn.startDirection = shootDirection;
            Physics.IgnoreCollision(bulletSpawn.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            audio.PlayOneShot(bulletShot);
            break;
        }

        case bulletType.bouncy:
        {
            //default bullet
            BulletController bulletSpawn = Instantiate(projectile, spawner.transform.position, Quaternion.identity).GetComponent <BulletController>();
            bulletSpawn.startDirection = shootDirection;
            bulletSpawn.bouncy         = true;
            Physics.IgnoreCollision(bulletSpawn.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            audio.PlayOneShot(bulletShot);
            break;
        }

        case bulletType.explosive:
        {
            BulletController bulletSpawn = Instantiate(projectile, spawner.transform.position, Quaternion.identity).GetComponent <BulletController>();
            //makes the bullet larger
            bulletSpawn.transform.localScale += new Vector3(1.0f, 1.0f, 1.0f);
            bulletSpawn.explosive             = true;
            bulletSpawn.startDirection        = shootDirection;
            Physics.IgnoreCollision(bulletSpawn.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            audio.PlayOneShot(bulletShot);
            break;
        }

        case bulletType.fast:
        {
            BulletController bulletSpawn = Instantiate(projectile, spawner.transform.position, Quaternion.identity).GetComponent <BulletController>();
            //makes the bullet faster
            bulletSpawn.fast           = true;
            bulletSpawn.startDirection = shootDirection;
            Physics.IgnoreCollision(bulletSpawn.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            audio.PlayOneShot(bulletShot);
            break;
        }

        case bulletType.spread:
        {
            //first
            BulletController bulletSpawn = Instantiate(projectile, (spawner.transform.position), Quaternion.identity).GetComponent <BulletController>();
            bulletSpawn.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            bulletSpawn.startDirection       = shootDirection;
            Physics.IgnoreCollision(bulletSpawn.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            //second
            BulletController bulletSpawn2 = Instantiate(projectile, (spawner.transform.position), (Quaternion.identity)).GetComponent <BulletController>();
            bulletSpawn2.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            shootDirection = Quaternion.AngleAxis(20, Vector3.up) * shootDirection;
            bulletSpawn2.startDirection = shootDirection;
            Physics.IgnoreCollision(bulletSpawn2.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            //third
            BulletController bulletSpawn3 = Instantiate(projectile, (spawner.transform.position), Quaternion.identity).GetComponent <BulletController>();
            bulletSpawn3.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            shootDirection = Quaternion.AngleAxis(-40, Vector3.up) * shootDirection;
            bulletSpawn3.startDirection = shootDirection;
            Physics.IgnoreCollision(bulletSpawn3.GetComponent <Collider>(), gameObject.GetComponent <Collider>());
            shootDirection = Quaternion.AngleAxis(20, Vector3.up) * shootDirection;
            audio.PlayOneShot(bulletShot);
            break;
        }

        case bulletType.burst:
        {
            StartCoroutine(ShootThree());
            break;
        }
        }

        shootingTimer = 0;
        Debug.Log(currentAmmo);
        currentAmmo--;
        ammoTracker.fillAmount = currentAmmo / maxAmmo;

        if (currentAmmo == 0)
        {
            currentBullet  = bulletType.normal;
            gunType.sprite = normalGun;
            reloadTimer    = 0;
            hasReloaded    = false;
        }
    }