void DoSkill1028(MapGrid pos, SoldierSkill skill) { if (pos == null) { return; } GameObject posgo = m_LifePrent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.FirePos); Transform fireplace = posgo.transform; if (fireplace != null) { string bulletname = "1003051"; GameObject go = GameObjectLoader.LoadPath("effect/prefab/", bulletname, BattleEnvironmentM.GetLifeMBornNode(true)); go.transform.position = fireplace.position; if (m_LifePrent.WalkDir == WalkDir.WALKRIGHT) { go.transform.localScale = new Vector3(-go.transform.localScale.x, go.transform.localScale.y, go.transform.localScale.z); } Bullet bullet = go.AddComponent <Bullet>(); if (bullet != null) { Bullet.BulletType t = Bullet.BulletType.bomb1028; Vector3 vpos = pos.pos; vpos.y = go.transform.localPosition.y; bullet.SetInfo(vpos, m_DoAttack, 10f, m_LifePrent.WalkDir, t, skill); } } }
//Fin singleton public Bullet GetBullet(Bullet.BulletType bulletType) { Bullet shot; if (bulletType == Bullet.BulletType.Player) { if (stackPlayerBullets.Count <= 0) { shot = (Instantiate(playerBullet, Vector3.zero, new Quaternion())).GetComponent <Bullet> (); } else { shot = stackPlayerBullets.Pop(); } } else { if (stackEnnemyBullets.Count <= 0) { shot = (Instantiate(ennemyBullet, Vector3.zero, new Quaternion())).GetComponent <Bullet> (); } else { shot = stackEnnemyBullets.Pop(); } } shot.ResetPosition(); shot.gameObject.SetActive(true); return(shot); }
// This function makes sure the oldest bullet is used for recycling void CycleIndex(Bullet.BulletType type) { int i = (int)type; bulletIndicies[i]++; if (bulletIndicies[i] >= bulletLists[i].Count) { bulletIndicies[i] = 0; } }
void AddRandomDesire() { Bullet.BulletType desire = GetRandomDesire(); desires.Add(desire); if (desire == Bullet.BulletType.Drink) { desiresGameObjects.Add(Instantiate(GameController.instance.thirstIcon, desiresCanvas.transform).gameObject); } else { desiresGameObjects.Add(Instantiate(GameController.instance.hungerIcon, desiresCanvas.transform).gameObject); } }
public void ChangeBullet() { if (Input.GetKey(KeyCode.A)) { BulletType = Bullet.BulletType.Even; } if (Input.GetKey(KeyCode.S)) { BulletType = Bullet.BulletType.Odd; } if (Input.GetKey(KeyCode.D)) { BulletType = Bullet.BulletType.Prime; } }
// 弾を発射(単発・デフォルトから変えたいパラメータあり) public void ShotBullet( Vector2 genPos, Vector2 genRot, BulletType type, float angle, float?moveSpeed = null, float?rotateSpeed = null, float?accel = null, float?attack = null, float?size = null, Color?color = null) // default引数はNullable<T>を使ってnull扱いとする { // Prefab取得して生成 GameObject bullet = Object.Instantiate <GameObject>(GetBulletPrefab(type), genPos, Quaternion.Euler(genRot)); // パラメータ上書きがあれば行う bullet.GetComponent <Bullet>().SetParam(moveSpeed, rotateSpeed, accel, attack, size, color); // 角度指定して発射 bullet.GetComponent <Bullet>().Shot(angle); }
public void FireBullet(Bullet.BulletTarget bTarget, Bullet.BulletType bType, Vector3 position, Vector3 direction) { if (bulletReady.Count == 0) { return; } var bullet = bulletReady[0]; bulletReady.RemoveAt(0); bulletNotReady.Add(bullet); bullet.enabled = true; bullet.transform.position = position; bullet.transform.rotation = Quaternion.Euler(0, 0, -90 + Mathf.Atan2(direction.y, direction.x) * 180.0f / Mathf.PI); bullet.Reset(bTarget, bType); }
void RecycleBullets(Bullet.BulletType type, Vector3 fireDirection) { GameObject current; // The current bullet int i = (int)type; // Bullet Recycling if (bulletLists[i].Count < maxBullets) { // If there are less than the max bullets, make more current = Instantiate(bulletPrefabs[i], firePoint.position, firePoint.rotation); if (bulletType == Bullet.BulletType.Fire) { current.GetComponent <Rigidbody>().velocity = Vector3.zero; } else { current.GetComponent <Rigidbody>().velocity = playerRB.velocity; } bulletLists[i].Add(current); } else { // If max bullets is exceted, reuse the oldest bullet current = bulletLists[i][bulletIndicies[i]]; if (bulletType == Bullet.BulletType.Fire) { current.GetComponent <Bullet>().ResetBullet(firePoint, Vector3.zero); } else { current.GetComponent <Bullet>().ResetBullet(firePoint, playerRB.velocity); } CycleIndex(type); } // Add force to bullet based on fire direction current.GetComponent <Rigidbody>().AddForce(fireDirection * bulletForces[i], ForceMode.VelocityChange); Vector3 spin = new Vector3(Random.Range(-100, 100), Random.Range(-100, 100), Random.Range(-100, 100)); current.GetComponent <Rigidbody>().angularVelocity = spin; }
void SwitchWeapon() { // Switch Bullet Type if (Input.GetButtonDown("PulseBeam")) { bulletType = Bullet.BulletType.Pulse; } else if (Input.GetButtonDown("FlameThrower")) { bulletType = Bullet.BulletType.Fire; } else if (Input.GetButtonDown("IceBreaker")) { bulletType = Bullet.BulletType.Ice; } else if (Input.GetButtonDown("GelCaster")) { bulletType = Bullet.BulletType.Gel; } float input = Input.GetAxisRaw("Mouse ScrollWheel"); if (input > 0) { bulletType++; if ((int)bulletType > 3) { bulletType = Bullet.BulletType.Pulse; } } else if (input < 0) { bulletType--; if ((int)bulletType < 0) { bulletType = Bullet.BulletType.Gel; } } typeScreen.sprite = typeIcons[(int)bulletType]; }
public override void DoAttack(int count) { Life target = m_skillinfo.m_LifeTarget; //m_ConditionSkillTarget[PropSkillInfo.m_type]; MapGrid pos = m_skillinfo.m_TargetPos; //m_ConditionSkillTargetPos[PropSkillInfo.m_type]; if (m_skillinfo.m_target != 2 && target != null) { pos = target.GetMapGrid(); } //if (PropSkillInfo.m_type == 1009 || PropSkillInfo.m_type == 1028) // NGUIUtil.DebugLog( "doskill " + PropSkillInfo.m_type + "," + m_ConditionSkillTarget[PropSkillInfo.m_type] + "," + PropSkillInfo.m_name,"red"); //播放攻击动画 //受击掉血 m_LifePrent.m_Attr.Attacked = true; if (m_skillinfo.m_skilleffectinfo != null) //RoleModelsM.GetSkillResourcesData(PropSkillInfo.m_type,"HasBullet") == 1) { GameObject posgo = m_LifePrent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.FirePos); if (m_skillinfo.m_type == 1041) { posgo = m_LifePrent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.LeftHandPos); } else if (m_skillinfo.m_type == 1044) { posgo = m_LifePrent.GetSkin().ProPerty.HelpPoint.GetVauleByKey(HelpPointName.bagPos); } Transform fireplace = posgo.transform; if (fireplace != null) { string bulletname = m_skillinfo.m_skilleffectinfo.m_targeteffect; string bulletLeft = "1202071"; string bulletRight = "1202071"; if (BattleEnvironmentM.GetLifeMBornNode(true) == null) { return; } GameObject go = null; if (m_LifePrent.WalkDir == WalkDir.WALKLEFT) { go = GameObjectLoader.LoadPath("effect/prefab/", bulletLeft, fireplace.position, BattleEnvironmentM.GetLifeMBornNode(true)); } else { go = GameObjectLoader.LoadPath("effect/prefab/", bulletRight, fireplace.position, BattleEnvironmentM.GetLifeMBornNode(true)); } if (m_LifePrent.WalkDir == WalkDir.WALKLEFT) { go.transform.localScale = new Vector3(-go.transform.localScale.x, go.transform.localScale.y, go.transform.localScale.z); } Bullet bullet = go.AddComponent <Bullet>(); if (bullet != null) { Bullet.BulletType t = Bullet.BulletType.Bullet; Vector3 vpos = pos.pos; if (m_skillinfo.m_skilleffectinfo.m_postion == 0) { vpos.y = go.transform.localPosition.y; } else { vpos.y += 0.2f; } bullet.SetInfo(vpos, m_DoAttack, 10f, m_LifePrent.WalkDir, t, (m_skillinfo as SoldierSkill), true); //vpos,m_DoAttack,10f,m_LifePrent.WalkDir,t,m_skillinfo as SoldierSkill); } } } else { m_DoAttack(m_skillinfo as SoldierSkill, count); } }
public void Shoot(Bullet.BulletType Type, GameObject Shooter, int ID, bool IsVamp, bool IsReinfoce, int index) { SetPos(Shooter, ID); int rarity = 0; if ((int)Type < 100) { rarity = GameManager.Inst().UpgManager.BData[(int)Type].GetRarity(); } int colorIndex = ColorSelection[ID]; if (Shooter.tag == "SubWeapon" && ID > 1) { colorIndex = ColorSelection[ID + 1]; } switch (Type) { case Bullet.BulletType.NORMAL: Normal(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.SPREAD: Spread(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.MISSILE: Missile(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.LASER: Laser(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.CHARGE: Charge(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.BOOMERANG: Boomerang(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.CHAIN: Chain(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.GATLING: Gatling(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.EXPLOSION: Explosion(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.DOT: Dot(Shooter, rarity, colorIndex, IsVamp, IsReinfoce); break; case Bullet.BulletType.EQUIP_MISSILE: Equip_Missile(index); break; case Bullet.BulletType.EQUIP_KNOCKBACK: Equip_Knockback(index); break; case Bullet.BulletType.EQUIP_SLOW: Equip_Slow(); break; } }