Exemplo n.º 1
0
    public BulletObj CreateBullet(int resid)
    {
        BulletObj _obj = null;

        for (int idx = 0; idx < _allBullet.Count; ++idx)
        {
            BulletObj obj = _allBullet[idx];
            if (!obj.IsUsing && obj.ResId == resid)
            {
                _obj = obj;
                _obj.bullet.SetActive(true);
                break;
            }
        }
        if (_obj == null)
        {
            _obj        = new BulletObj();
            _obj.ResId  = resid;
            _obj.bullet = GameObject.Instantiate(ResourceMgr.Instance.LoadResource(resid) as GameObject);
            _obj.bullet.transform.position = FAR_POS;
            _allBullet.Add(_obj);
        }
        _obj.IsUsing = true;
        return(_obj);
    }
Exemplo n.º 2
0
        public void CreateBullet(SkillCom ower, AddBulletModel addBullet)
        {
            if (SkillLocate.Model.GetBulletModel(addBullet.id, out BulletModel model))
            {
                BulletCom bulletCom = LCECS.ECSLocate.ECS.GetWorld().GetCom <BulletCom>();

                BulletObj bulletObj = new BulletObj();

                //配置
                bulletObj.model = model;

                //预制体
                if (model.asset != null && !string.IsNullOrEmpty(model.asset.ObjName))
                {
                    bulletObj.go = ToolkitLocate.GoPool.Take(model.asset.ObjName);
                }

                //拥有者
                bulletObj.ower = ower;

                //配置数据
                bulletObj.firePos            = addBullet.firePos;
                bulletObj.fireDir            = addBullet.fireDir;
                bulletObj.speed              = addBullet.speed;
                bulletObj.duration           = addBullet.duration;
                bulletObj.useFireDirForever  = addBullet.useFireDirForever;
                bulletObj.canHitAfterCreated = addBullet.canHitAfterCreated;

                //保存
                bulletCom.AddBullet(bulletObj);
            }
        }
Exemplo n.º 3
0
 public void Fire()
 {
     for (int i = 0; i < shootPosition.Length; i++)
     {
         GameObject obj       = Instantiate(bullet, shootPosition[i].position, shootPosition[i].rotation);
         BulletObj  bulletObj = obj.GetComponent <BulletObj>();
         bulletObj.SetFather(fatherObj);
     }
 }
Exemplo n.º 4
0
 public override void Fire()
 {
     for (int i = 0; i < shootPos.Length; i++)
     {
         GameObject obj    = Instantiate(bulletObj, shootPos[i].position, shootPos[i].rotation);
         BulletObj  bullet = obj.GetComponent <BulletObj>();
         bullet.SetFather(this);
     }
 }
Exemplo n.º 5
0
    public void EnemyManagerUpdate()
    {
        foreach (GameObject Enemy in EnemyList)
        {
            if (!Enemy || !Enemy.activeSelf)
            {
                EnemyList.Remove(Enemy);
                continue;
            }

            Enemy.GetComponent <EnemyBase>().EnemyUpdate();
        }

        //Update bullets shot by enemy
        foreach (GameObject BulletObj in BulletList)
        {
            if (!BulletObj)
            {
                BulletList.Remove(BulletObj);
                continue;
            }

            if (BulletObj.activeSelf)
            {
                BulletObj.GetComponent <BulletObject>().BulletObjectUpdate();
            }

            //if (BulletObj.transform.localPosition.x > theCanvas.transform.localPosition.x + Screen.width || BulletObj.transform.localPosition.x < theCanvas.transform.localPosition.x - Screen.width ||
            //    BulletObj.transform.localPosition.y > theCanvas.transform.localPosition.y + Screen.height || BulletObj.transform.localPosition.y < theCanvas.transform.localPosition.y - Screen.height)
            //{
            //    Destroy(BulletObj);
            //}

            if ((BulletObj.transform.position - theCharacter.transform.position).magnitude > 500)
            {
                Destroy(BulletObj);
            }
        }
    }
Exemplo n.º 6
0
 public override List <ActorObj> GetHitActors(BulletObj bulletObj)
 {
     throw new global::System.NotImplementedException();
 }
Exemplo n.º 7
0
    // Update is called once per frame
    public void MainCharacterUpdate()
    {
        animator.SetInteger("states", 1);
        //charhealth.text = "Health : " + characterHealth.ToString() + "/" + "100";
        moneytext.text = "Score : " + money.ToString();
        //Debug.Log("THIS IS THE THINGY " + PlayerPrefs.GetFloat("respawntocheckpoint"));
        //Debug.Log("WHERE THE PLAYER IS GOING TO SPAWN " + respawnpoint);
        //Debug.Log("THE CHARACTER POSITION" + transform.position);

        //-------PROBLEMATIC CODE------//

        //----------------------------//

        //Crosshair snap to mouse position
        Vector3 screenPoint = Input.mousePosition;

        screenPoint.z = 10.0f; //distance of the plane from the camera
        Vector3 mousePos = Camera.main.ScreenToWorldPoint(screenPoint);

        gameObject.transform.GetChild(0).transform.position = mousePos;
        //Character faces direction of crosshair
        if (mousePos.x < gameObject.transform.position.x && !facingLeft)
        {
            gameObject.transform.right = -gameObject.transform.right;
            facingLeft = true;
        }
        else if (mousePos.x > gameObject.transform.position.x && facingLeft)
        {
            gameObject.transform.right = -gameObject.transform.right;
            facingLeft = false;
        }

        //Weapon Rot
        Vector3 normalizedDir = (mousePos - gameObject.transform.position).normalized;

        normalizedDir.z = 0;
        playerWeapon.up = normalizedDir;

        KeyInputs();

        //Update bullets shot by player
        foreach (GameObject BulletObj in BulletList)
        {
            if (!BulletObj || !BulletObj.activeSelf)
            {
                BulletList.Remove(BulletObj);
                continue;
            }

            if (BulletObj.activeSelf)
            {
                if (BulletObj.tag == "GenericBullet")
                {
                    BulletObj.GetComponent <BulletObject>().BulletObjectUpdate();
                }
                else if (BulletObj.tag == "GenericRocket")
                {
                    BulletObj.GetComponent <RocketObject>().RocketObjectUpdate();
                }
            }

            //Check if out of screen
            if (BulletObj.transform.position.x > theCanvas.transform.localPosition.x + Screen.width || BulletObj.transform.position.x < theCanvas.transform.localPosition.x - Screen.width ||
                BulletObj.transform.position.y > theCanvas.transform.localPosition.y + Screen.height || BulletObj.transform.position.y < theCanvas.transform.localPosition.y - Screen.height)
            {
                Destroy(BulletObj);
            }
        }

        //Update Character States
        if (characterState == CHARACTER_STATE.CHARACTERSTATE_INVINCIBLE)
        {
            InvincibilityTimer += Time.deltaTime;

            if (InvincibilityTimer >= InvincibilityTimeLimit)
            {
                InvincibilityTimer = 0;
                characterState     = CHARACTER_STATE.CHARACTERSTATE_NORMAL;
                Destroy(gameObject.transform.Find("shield(Clone)").gameObject);
            }
        }
        if (isBerserk)
        {
            BerserkTimer += Time.deltaTime;

            if (BerserkTimer >= BerserkTimeLimit)
            {
                BerserkTimer         = 0;
                isBerserk            = false;
                spriteRenderer.color = defaultColour;

                //Modifiers
                BerserkDamageModifier = BerserkMovementModifer = BerserkShootSpeedModifier = 1;
            }
        }
    }
Exemplo n.º 8
0
 public override bool CheckBulletInRange(AoeObj aoeObj, BulletObj bullet)
 {
     return(false);
 }
Exemplo n.º 9
0
 public void DestroyBullet(BulletObj obj)
 {
     obj.IsUsing = false;
     obj.bullet.transform.position = FAR_POS;
     obj.bullet.SetActive(false);
 }