Beispiel #1
0
    public virtual void Shoot()
    {
        if (shootTimer <= 0)
        {
            shootTimer = ShotDelay;

            if (magazine?.Ammo <= 0 || (magazine?.Reloading == true))
            {
                Debug.Log("click");
                return;
            }

            Debug.Log("SHOOTING ANIMATION HERE");

            Vector3?target = hitPoint();
            CBullet b      = Instantiate(Bullet, transform.position, transform.rotation);
            if (target != null)
            {
                b.Initialize(((Vector3)target - transform.position).normalized);
            }
            else
            {
                b.Initialize(transform.forward.normalized);
            }

            if (magazine != null)
            {
                magazine.Ammo--;
            }
        }
    }
Beispiel #2
0
    private void OnTouchOther(GameObject other)
    {
        CBullet shot = other.GetComponent <CBullet>();

        if ((shot != null) && 0 != ((1u << gameObject.layer) & shot.hitmask))
        {
            Vector3 speed;
            // hit by a bullet.
#if with3D
            Rigidbody r3 = other.GetComponent <Rigidbody>();
            if (r3 != null)
            {
                Debug.Log(r3.ToString());
                speed = r3.velocity;
            }
            else
#endif
            {
#if with2D
                Rigidbody2D r2 = other.GetComponent <Rigidbody2D>();
                if (r2 != null)
                {
                    speed = r2.velocity;
                }
                else
#endif
                speed = new Vector3();
            }
            takeDamage(other, speed, shot.def_damage);
            Destroy(other);              // ..... add boom.
        }
    }
    //public void DoFire(float tDirX)
    //{
    //    Vector3 tBulletPos = mpAlberto.transform.position;
    //    tBulletPos.y += 0.3f;
    //    CBullet bullet = Instantiate<CBullet>(PFBullet, tBulletPos, Quaternion.identity);
    //    bullet.DirX = tDirX;
    //}
    public void DoAttack(float tXSpeed)
    {
        Vector3 tVector = mpAlberto.transform.position;

        tVector.y = tVector.y + 0.5f;
        CBullet tBullet = Instantiate <CBullet>(PFBullet, Vector3.zero, Quaternion.identity);

        tBullet.SetScene(this);
        tBullet.SetXSpeed(tXSpeed);
    }
    public void DoFireBullet()
    {
        Vector3 tVector = this.mpAlberto.transform.position;

        tVector.y += 0.5f;

        CBullet tBullet = Instantiate <CBullet>(CMyGameDataMgr.GetInst().PFBullet, tVector, mpAlberto.transform.localRotation);

        tBullet.GetComponent <Rigidbody>().AddForce(mpAlberto.transform.forward * 10.0f, ForceMode.Impulse);
    }
    public void Spawn(Vector3 pos, Vector3 vel)
    {
        GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(this._bulletAsset, pos, Quaternion.identity);
        CBullet    component  = gameObject.GetComponent <CBullet>();

        component.AddVel(vel);
        UnityEngine.Object.Destroy(gameObject, 8f);
        this._bulletList.Add(component);
        component.SubscribeOnInst(new CBullet.BulletSpawn(this.OnUpdateBulletIndex));
    }
Beispiel #6
0
    private void OnTouchOther(GameObject other)
    {
        CBullet shot = other.GetComponent <CBullet>();

        if ((!System.Object.ReferenceEquals(shot, null)) && 0 != (hitmask & shot.hitmask))
        {
            // hit by a bullet.
            takeDamage(other, other.GetComponent <Rigidbody>().velocity, shot.def_damage);
            Destroy(other);  // ..... add boom.
        }
    }
Beispiel #7
0
    void OnTriggerEnter2D(Collider2D other)
    {
        GameObject other_go = other.gameObject;
        CBullet    shot     = other_go.GetComponent <CBullet>();

        if (!System.Object.ReferenceEquals(shot, null))
        {
            // hit by a bullet.
            Destroy(other_go);                  // ..... add boom.
            takeDamage(other_go, other_go.GetComponent <Rigidbody2D>().velocity, shot.def_damage);
        }
    }
Beispiel #8
0
    private int AddEnemyBullet(CBullet bullet)
    {
        int index = GetEmptyEnemyBulletSlot();

        if (index < 0)
        {
            return(-1);
        }

        mEnemyBulletList[index] = bullet;

        return(index);
    }
Beispiel #9
0
    private int AddPlayerBullet(CBullet bullet)
    {
        int index = GetEmptyPlayerBulletSlot();

        if (index < 0)
        {
            return(-1);
        }

        mPlayerBulletList[index] = bullet;

        return(index);
    }
Beispiel #10
0
    public void CreateRyu()
    {
        //load prefabs
        PFAlberto      = Resources.Load <CAlberto>("Prefabs/PFAlberto");
        PFSlime        = Resources.Load <CEnemy>("Prefabs/PFSlime");
        PFBobby        = Resources.Load <CEnemy>("Prefabs/PFBobby");
        PFEnemy_1      = Resources.Load <CEnemy_1>("Prefabs/PFEnemy_1");
        PFBulletSphere = Resources.Load <CBullet>("Prefabs/PFBulletSphere");

        CreateWithLanguageType();

        CreateWithStageData();
    }
Beispiel #11
0
    public void CreateEnemyBullet(float x, float y, float tx, float ty)
    {
        if (mEnemyBullet == null)
        {
            return;
        }

        GameObject obj = Instantiate(mEnemyBullet);

        CBullet bullet = obj.GetComponent <CBullet>();
        int     index  = AddEnemyBullet(bullet);

        bullet.Init(mUnitRootTransform, UNIT_TYPE.BULLET_ENEMY, index, x, y, tx, ty);
    }
Beispiel #12
0
    public void DoAttack()
    {
        mpAnimator.SetTrigger("mTrigAttack");
        CBullet tBullet = Instantiate <CBullet>(mpScene.PFBullet, this.transform.position,
                                                Quaternion.identity);

        float tAlbertoDirX = this.transform.localScale.x;

        tBullet.SetBuletDirX(tAlbertoDirX);

        if (STATE.IDLE == mState)
        {
            mState = STATE.DEAD;
            mpAnimator.SetTrigger("mTrigMove");
        }
    }
Beispiel #13
0
    override public void DoFire()
    {
        mBulletCount = mBulletList.Count;
        CBullet tpBullet = null;

        tpBullet = Instantiate <CBullet>(CRyuGameDataMgr.GetInst().PFBulletSphere,
                                         Vector3.zero, Quaternion.identity);

        Vector3 tPosition = new Vector3(this.transform.position.x,
                                        this.transform.position.y + 0.25f, this.transform.position.z);

        tpBullet.transform.position = tPosition;

        tpBullet.transform.Rotate(mDir);

        mBulletList.Add(tpBullet);
        mBulletList[mBulletCount].CreateAni();
    }
    public void Create()
    {
        PFAlberto = Resources.Load<CAlberto>("Prefabs/PFAlberto");
        PFEnemy_0 = Resources.Load<CEnemy_0>("Prefabs/PFEnemy_0");
        PFEnemy_1 = Resources.Load<CEnemy_1>("Prefabs/PFEnemy_1");
        PFEnemy_2 = Resources.Load<CEnemy_2>("Prefabs/PFEnemy_2");
        PFBullet = Resources.Load<CBullet>("Prefabs/PFBullet");

        mCurrentStageIndex = 0;

        mStageList = new List<string>();
        mStageList.Add("CScenePlayGameGrid_0");
        mStageList.Add("CScenePlayGameGrid_1");
        mStageList.Add("CScenePlayGameGrid_2");

        CreateWithLanguageType();

        LoadDialogueData();
    }
    private void OnUpdateBulletIndex(CBullet bullet)
    {
        int index = this._bulletList.IndexOf(bullet);

        this._index = index;
    }