Esempio n. 1
0
    public static ABullet create()
    {
        ABullet bullet = Res.createFromPool(MainRes.bulletPool) as ABullet;

        bullet.addToScene();
        return(bullet);
    }
Esempio n. 2
0
        public static void Update(GameTime time, Map map, List <Character> character)
        {
            for (uint i = 0; i < numberofBullets; ++i)
            {
                ABullet c = bullets[i];

                if (Math.Abs(c.Position.X) > 10000)
                {
                    swap(i, --numberofBullets);
                }

                c.Update(time);
                c.Collide(map);

                foreach (Character a in character)
                {
                    c.Collide(a);
                }



                if (c.dead)
                {
                    swap(i, --numberofBullets);
                }
            }
        }
Esempio n. 3
0
        static void swap(uint a, uint b)
        {
            ABullet tmp = bullets[a];

            bullets[a] = bullets[b];
            bullets[b] = tmp;
        }
Esempio n. 4
0
        public static void Draw(SpriteBatch batch)
        {
            for (uint i = 0; i < numberofBullets; ++i)
            {
                ABullet c = bullets[i];

                c.Draw(batch);
            }
        }
Esempio n. 5
0
 public virtual void Shoot()
 {
     if (CurrentEnemy)
     {
         ABullet clone = Instantiate(BulletPrefab, transform.position, transform.rotation);
         clone.Target    = CurrentEnemy.gameObject;
         clone.damage    = Damage;
         clone.targetPos = CurrentEnemy.transform.position;
         _dpsTimer       = 0;
     }
 }
Esempio n. 6
0
    void shootBullet(Vector3 direct)
    {
        ABullet bullet = ABullet.create();

        if (bullet == null)
        {
            return;
        }
        bullet.addToGroup(Groups.bulletAll);
        bullet.transform.position = gunRoot.position;
        bullet.speedVec           = direct;
        Sound.createAndPlay("cannonShootShort", bullet.transform.position, 0.1f);
    }
Esempio n. 7
0
    public void collideTest(List <SCENE_OBJ> bulletGroup)
    {
        if (bulletGroup == null)
        {
            return;
        }
        for (int i = 0; i < bulletGroup.Count; i++)
        {
            ABullet otherObj = bulletGroup[i] as ABullet;

            calculateGlobalspeedAndRelateVec(this, otherObj);

            if (!isObjsMatchCondition(otherObj))
            {
                return;
            }

            collideTest(collideBoxs, otherObj);
        }
    }
Esempio n. 8
0
    void FixedUpdate()
    {
        if (Input.GetButton("Fire1") && CanShot && automatic)
        {
            CanShot = false;

            CameraController.ShakeCamera(ScreenShake, 0.1f);

            player.Knockback = KnockBack;

            SetDispersion();

            if (Gun == Guns.MINE)
            {
                Instantiate(BulletPrefabs[(int)Bullet], transform.position, Quaternion.identity);
            }
            else if (Gun == Guns.SHOTGUN)
            {
                for (int i = 0; i < 6; i++)
                {
                    Object           = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint() + i * transform.parent.localScale.x / 2, transform.position.y + Random.Range(-0.5f, 0.5f)), Quaternion.identity);
                    aBullet          = Object.gameObject.GetComponent <ABullet>();
                    aBullet.LifeTime = Random.Range(LifeTime, LifeTime * 2);
                    aBullet.Velocity = new Vector2(Random.Range(Velocity.x, Velocity.x * 2), Velocity.y);
                    aBullet.Damage   = Damage;
                    aBullet.Flip(transform.parent.localScale);
                }
            }
            else if (Gun == Guns.GRENADELAUNCHER)
            {
                Object           = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity);
                aBullet          = Object.gameObject.GetComponentInChildren <ABullet>();
                aBullet.Velocity = Velocity;
                aBullet.Flip(transform.parent.localScale);
            }
            else
            {
                Object           = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity);
                aBullet          = Object.gameObject.GetComponent <ABullet>();
                aBullet.LifeTime = LifeTime;
                aBullet.Velocity = Velocity;
                aBullet.Damage   = Damage;
                aBullet.Flip(transform.parent.localScale);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Space) && !automatic)
        {
            CameraController.ShakeCamera(ScreenShake, 0.1f);

            player.Knockback = KnockBack;

            if (Gun == Guns.DOUBLEPISTOL)
            {
                Object           = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x - GetSpawnPoint(), transform.position.y), Quaternion.identity);
                aBullet          = Object.gameObject.GetComponent <ABullet>();
                aBullet.LifeTime = LifeTime;
                aBullet.Velocity = Velocity * -1;
                aBullet.Damage   = Damage;
                aBullet.Flip(transform.parent.localScale);

                Object           = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity);
                aBullet          = Object.gameObject.GetComponent <ABullet>();
                aBullet.LifeTime = LifeTime;
                aBullet.Velocity = Velocity;
                aBullet.Damage   = Damage;
                aBullet.Flip(transform.parent.localScale);
            }
            else
            {
                Object           = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity);
                aBullet          = Object.gameObject.GetComponent <ABullet>();
                aBullet.LifeTime = LifeTime;
                aBullet.Velocity = Velocity;
                aBullet.Damage   = Damage;
                aBullet.Flip(transform.parent.localScale);
            }
        }
        else
        {
            player.Knockback = 0;
        }
    }