Ejemplo n.º 1
0
 private void Start()
 {
     shootingCooldown     = new Cooldown(1);
     bulletData           = new BulletData();
     bulletData.position  = new Position();
     bulletData.direction = new Position();
 }
    private AnimEventShot CreateExplosion()
    {
        //IL_0048: Unknown result type (might be due to invalid IL or missing references)
        //IL_004d: Unknown result type (might be due to invalid IL or missing references)
        //IL_0054: Unknown result type (might be due to invalid IL or missing references)
        //IL_0059: Unknown result type (might be due to invalid IL or missing references)
        //IL_006c: Unknown result type (might be due to invalid IL or missing references)
        //IL_006d: Unknown result type (might be due to invalid IL or missing references)
        BulletData bulletData = m_atkInfo.bulletData;

        if (bulletData == null)
        {
            return(null);
        }
        BulletData.BulletMine dataMine = bulletData.dataMine;
        if (bulletData == null)
        {
            return(null);
        }
        if (m_attacker == null)
        {
            return(null);
        }
        Quaternion    rotation      = m_cachedTransform.get_rotation();
        Vector3       position      = m_cachedTransform.get_position();
        AnimEventShot animEventShot = AnimEventShot.CreateByExternalBulletData(dataMine.explodeBullet, m_attacker, m_atkInfo, position, rotation, null, Player.ATTACK_MODE.NONE, null);

        if (animEventShot == null)
        {
            return(null);
        }
        return(animEventShot);
    }
Ejemplo n.º 3
0
 private void OutOfRange(BulletData bullet)
 {
     if (bullet.TraveledDistance() > despawnRadius)
     {
         bullet.Despawn();
     }
 }
Ejemplo n.º 4
0
        private void SpawnBullet(BulletData bullet)
        {
            var init      = initialPosition.transform.position;
            var direction = (init - pivot.transform.position).normalized;

            bullet.Spawn(init, direction);
        }
Ejemplo n.º 5
0
    void shootBullet()
    {
        timePass += Time.deltaTime;
        if (shotInterval - timePass > 0)
        {
            return;
        }
        Vector2 shotSpeed = controller.GetShot();

        if (shotSpeed.x != 0 || shotSpeed.y != 0)
        {
            timePass = 0;
            Transform currBullet = Instantiate(_bullet, transform.position, Quaternion.identity, GameManager.Instance.transform);

            currBullet.GetComponent <Rigidbody2D>().velocity = calculateBulletSpeed(shotSpeed.x, shotSpeed.y);
            BulletData bdata = currBullet.GetComponent <BulletData>();
            if (bdata == null)
            {
                bdata = currBullet.gameObject.AddComponent <BulletData>();
            }
            currBullet.GetComponent <BulletData>().playerScript = this;
            //GameManager.Instance.bullets.Add(bdata);
            Destroy(currBullet.gameObject, bulletLifeTime);
        }
    }
Ejemplo n.º 6
0
        private void UpdateModelPosition(BulletData bullet)
        {
            var model = bullet.Model;
            var delta = Time.deltaTime * speed * bullet.Direction;

            model.transform.Translate(delta.x, 0, delta.y);
        }
Ejemplo n.º 7
0
    public void Shoot()
    {
        if (targetVisible == null)
        {
            return;
        }

        Vector2 force = spriteForward.x > 0 ? Vector2.right.Rotate(longAttack.shootAngle) : Vector2.left.Rotate(longAttack.shootAngle);

        force *= longAttack.shootForce;

        Vector2 shootPos = longAttack.shootPos.localPosition;

        if ((spriteFacingLeft && spriteForward.x > 0) || (!spriteFacingLeft && spriteForward.x > 0))
        {
            shootPos.x *= -1;
        }
        // Quaternion rot = Quaternion.LookRotation (targetVisible.position);
        Transform  obj  = PoolManager.Instance.myObjectPools ["Bullets"].Spawn(longAttack.bullet.transform, longAttack.shootPos.TransformPoint(shootPos), Quaternion.identity, null);
        BulletData data = obj.gameObject.GetComponent <BulletData>();
        bool       d    = true;

        if (spriteForward.x > 0)
        {
            d = false;
        }
        data.spriteRenderer.flipX = d ^ data.facingLeft;
        obj.gameObject.GetComponent <Rigidbody2D> ().velocity = GetProjectilVelocity(targetShootPosition, longAttack.shootPos.transform.position);
    }
Ejemplo n.º 8
0
    // Changed Item when they get moved around in the inventory
    public void ChangeInventoryItem(ItemSlot slot)
    {
        CraftingType ct     = Utils.ConvertCollectableType(slot.Item.Type);
        BulletData   bullet = mInventory.GetActiveBulletItem();
        WeaponData   weapon = mInventory.GetActiveWeaponItem();
        CoreData     core   = mInventory.GetActiveCoreItem();

        ScriptableObject slotItem = slot.Item;

        if (!slot.IsInventorySlot)
        {
            slotItem = null;
        }

        switch (ct)
        {
        case CraftingType.BULLET: bullet = (BulletData)slotItem; break;

        case CraftingType.WEAPON: weapon = (WeaponData)slotItem; break;

        case CraftingType.CORE: core = (CoreData)slotItem; break;
        }

        mInventory.SetActiveItems(bullet, weapon, core);
        updateCraftingItems();
    }
 public void Spawn(EntityManager _entityManager, List <Entity> list, float3 _parentPos, int _damage, int _bulletType, ObjectMoveData moveData)
 {
     Debug.Assert(list != null);
     if (list == null)
     {
         return;
     }
     for (int i = 0; i < list.Count; i++)
     {
         BulletData bulletInfo = _entityManager.GetComponentData <BulletData>(list[i]);
         if (!bulletInfo.IsInitialized)
         {
             bulletInfo.IsInitialized = true;
             bulletInfo.IsCollide     = false;
             bulletInfo.Damage        = _damage;
             bulletInfo.BulletType    = _bulletType;
             _entityManager.SetComponentData <Translation>(list[i], new Translation {
                 Value = _parentPos
             });
             _entityManager.SetComponentData <ObjectMoveData>(list[i], moveData);
             _entityManager.SetComponentData <BulletData>(list[i], bulletInfo);
             break;
         }
     }
 }
Ejemplo n.º 10
0
    void BulletSwap(int a, int b)
    {
        BulletData temp = bullets[a];

        bullets[a] = bullets[b];
        bullets[b] = temp;
    }
Ejemplo n.º 11
0
    public void SetUp(BulletData info) // information sent from gun to bullet to change bullet properties
    {
        ResetBullet();
        damage             = info.Damage;      // bullet damage
        impactForce        = info.ImpactForce; // force applied to rigid bodies
        maxInaccuracy      = info.MaxSpread;   // max inaccuracy of the bullet
        variableInaccuracy = info.Spread;      // current inaccuracy... mostly for machine guns that lose accuracy over time
        speed         = info.Speed;            // bullet speed
        DirectionFrom = info.Position;
        GunName       = info.WeaponName;
        OwnGunID      = info.WeaponID;
        isNetwork     = info.isNetwork;
        // lifetime = info.LifeTime;
        AIViewID = bl_GameManager.m_view;
        // direction bullet is traveling
        direction = transform.TransformDirection(Random.Range(-maxInaccuracy, maxInaccuracy) * variableInaccuracy, Random.Range(-maxInaccuracy, maxInaccuracy) * variableInaccuracy, 1);

        newPos   = transform.position;        // bullet's new position
        oldPos   = newPos;                    // bullet's old position
        velocity = speed * transform.forward; // bullet's velocity determined by direction and bullet speed
        if (Trail != null)
        {
            if (!bl_GameData.Instance.BulletTracer)
            {
                Destroy(Trail);
            }
        }
        // schedule for destruction if bullet never hits anything
        Invoke("Disable", 5);
    }
Ejemplo n.º 12
0
    public override ResultType DoAction()
    {
        if (null == _owner.Enemy)
        {
            return(ResultType.Fail);
        }

        _owner.SubEnergy(0.01f);

        if (Time.realtimeSinceStartup - _lastAttackTime <= _attackInterval)
        {
            return(ResultType.Running);
        }
        _lastAttackTime = Time.realtimeSinceStartup;

        BulletData bulletData = new BulletData();

        bulletData.startPos = _owner.Position;
        bulletData.target   = _owner.Enemy.transform;
        bulletData.speed    = 5f;
        bulletData.damage   = 5;
        BulletManager.GetInstance().AddBullet(bulletData);

        return(ResultType.Success);
    }
Ejemplo n.º 13
0
    public static void CreateScriptableObject()
    {
        BulletData bulletData = ScriptableObject.CreateInstance <BulletData>();

        AssetDatabase.CreateAsset(bulletData, "Assets/Resources/ScriptableObjects/BulletData.asset");
        AssetDatabase.SaveAssets();
    }
Ejemplo n.º 14
0
    public BulletData GetBulletData(int bulletId)
    {
        BulletData data = null;

        m_bulletDataDictionary.TryGetValue(bulletId, out data);
        return(data);
    }
Ejemplo n.º 15
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "PlayerBullet")
        {
            BulletData bulletdata = other.GetComponent <BulletData>();
            if (!bulletdata.getEnemyName().Equals(gameObject.name))
            {
                return;
            }
        }

        if (other.tag == "EnemyBullet" || other.tag == "Enemy" || other.tag == "Boundary")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 16
0
    //Calculate the bullet's drag acceleration
    public static Vector3 CalculateBulletDragAcc(Vector3 bulletVel, BulletData bulletData)
    {
        //If you have a wind speed in your game, you can take that into account here:
        //https://www.youtube.com/watch?v=lGg7wNf1w-k
        Vector3 bulletVelRelativeToWindVel = bulletVel - bulletData.windSpeedVector;

        //Step 1. Calculate the bullet's drag force [N]
        //https://en.wikipedia.org/wiki/Drag_equation
        //F_drag = 0.5 * rho * v^2 * C_d * A

        //The velocity of the bullet [m/s]
        float v = bulletVelRelativeToWindVel.magnitude;
        //The bullet's cross section area [m^2]
        float A = Mathf.PI * bulletData.r * bulletData.r;

        float dragForce = 0.5f * bulletData.rho * v * v * bulletData.C_d * A;


        //Step 2. We need to add an acceleration, not a force, in the integration method [m/s^2]
        //Drag acceleration F = m * a -> a = F / m
        float dragAcc = dragForce / bulletData.m;

        //SHould be in a direction opposite of the bullet's velocity vector
        Vector3 dragVec = dragAcc * bulletVelRelativeToWindVel.normalized * -1f;


        return(dragVec);
    }
 private void OnDisappear()
 {
     //IL_0065: Unknown result type (might be due to invalid IL or missing references)
     //IL_007b: Unknown result type (might be due to invalid IL or missing references)
     //IL_0082: Expected O, but got Unknown
     //IL_008f: Unknown result type (might be due to invalid IL or missing references)
     //IL_0095: Expected O, but got Unknown
     //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
     ownerPlayer           = null;
     usePlayer             = null;
     bulletData            = null;
     skillParam            = null;
     cachedPlayerTransform = null;
     cachedTransform       = null;
     if (!object.ReferenceEquals(cachedCollider, null))
     {
         cachedCollider.set_enabled(false);
     }
     cachedCollider = null;
     if (cachedEffectTransform != null && cachedEffectTransform.get_gameObject() != null)
     {
         EffectManager.ReleaseEffect(cachedEffectTransform.get_gameObject(), true, false);
     }
     cachedEffectTransform = null;
     if (!object.ReferenceEquals((object)this.get_gameObject(), null))
     {
         Object.Destroy(this.get_gameObject());
     }
     isInitialized = false;
 }
    public int ChargedShot(int charge, int maxCharge, BulletData bulletData, Transform self, Vector2 barrelOffSet)
    {
        charge = charge <= maxCharge ?
                 charge :
                 maxCharge;

        int splits = charge;

        if (splits == 0)
        {
            Quaternion rotation = Quaternion.identity;
            if (chargedRandomSpreadLimit != 0)
            {
                rotation = Quaternion.Euler(0, 0, Random.Range(-chargedRandomSpreadLimit, chargedRandomSpreadLimit));
            }
            ShootBullet(bulletData, self, barrelOffSet, rotation);
        }
        else
        {
            for (int i = 0; i < splits; i++)
            {
                Quaternion rotation = Quaternion.identity;
                if (chargedRandomSpreadLimit != 0)
                {
                    rotation = Quaternion.Euler(0, 0, Random.Range(-chargedRandomSpreadLimit, chargedRandomSpreadLimit));
                }

                rotation *= Quaternion.Euler(0, 0, i * chargredAngle / splits - chargredAngle * 0.5f);
                ShootBullet(bulletData, self, barrelOffSet, rotation);
            }
        }

        return(charge);
    }
    public override void Shoot(BulletData bulletData, Transform self, Vector2 barrelOffSet)
    {
        float timeBetweenShots = Time.time - previousShot;

        randomSpreadIndex -= timeBetweenShots - weaponFireRate - recoilDuration;

        float randomAngle;

        if (bulletCount - 1 == 0)
        {
            randomAngle = Random.Range(-0.5f * randomAngles[RandomSpreadIndex], 0.5f * randomAngles[RandomSpreadIndex]);
            Quaternion rotation = Quaternion.Euler(0, 0, randomAngle);
            ShootBullet(bulletData, self, barrelOffSet, rotation);
        }
        else
        {
            for (int i = 0; i < bulletCount; i++)
            {
                randomAngle = Random.Range(-0.5f * randomAngles[RandomSpreadIndex], 0.5f * randomAngles[RandomSpreadIndex]);
                Quaternion rotation = Quaternion.Euler(0, 0, randomAngle);

                rotation *= Quaternion.Euler(0, 0, spreadAngle / bulletCount * 0.5f + i * spreadAngle / bulletCount - spreadAngle * 0.5f);
                ShootBullet(bulletData, self, barrelOffSet, rotation);
            }
        }

        previousShot = Time.time;
    }
Ejemplo n.º 20
0
    //Calculate the bullet's lift acceleration
    public static Vector3 CalculateBulletLiftAcc(Vector3 bulletVel, BulletData bulletData, Vector3 bulletUpDir)
    {
        //If you have a wind speed in your game, you can take that into account here:
        //https://www.youtube.com/watch?v=lGg7wNf1w-k
        Vector3 bulletVelRelativeToWindVel = bulletVel - bulletData.windSpeedVector;

        //Step 1. Calculate the bullet's lift force [N]
        //https://en.wikipedia.org/wiki/Lift_(force)
        //F_lift = 0.5 * rho * v^2 * S * C_l

        //The velocity of the bullet [m/s]
        float v = bulletVelRelativeToWindVel.magnitude;
        //Planform (projected) wing area, which is assumed to be the same as the cross section area [m^2]
        float S = Mathf.PI * bulletData.r * bulletData.r;

        float liftForce = 0.5f * bulletData.rho * v * v * S * bulletData.C_l;

        //Step 2. We need to add an acceleration, not a force, in the integration method [m/s^2]
        //Drag acceleration F = m * a -> a = F / m
        float liftAcc = liftForce / bulletData.m;

        //The lift force acts in the up-direction = perpendicular to the velocity direction it travels in
        Vector3 liftVec = liftAcc * bulletUpDir;


        return(liftVec);
    }
Ejemplo n.º 21
0
    public bool CreateFan(BulletData bulletData, Vector3 pos, float eulerY)
    {
        //\如果不是扇形
        if (bulletData.m_shapeParam1 != 3)
        {
            return(false);
        }

        if (isShowFanBullet)
        {
            GameObject fanGO = (GameObject)UnityEngine.Object.Instantiate(FanGO);
            float      rad   = bulletData.m_shapeParam2 / 10f;
            fanGO.transform.localScale = new Vector3(rad, rad, rad);
            fanGO.transform.position   = pos + Vector3.up;
            fanGO.transform.rotation   = Quaternion.Euler(0, eulerY, 0);
            var funBehaviour = fanGO.GetComponent <FanController>();
            if (funBehaviour != null)
            {
                funBehaviour.m_Angel = bulletData.m_shapeParam3;
            }
            fanGO.AddComponent <DestroySelf>();
        }

        return(true);
    }
Ejemplo n.º 22
0
 public void UpdateDisplayUI(BulletData bulletData)
 {
     bulletName.text              = bulletData.BulletName;
     icon.sprite                  = bulletData.Icon;
     attackDamage.text            = bulletData.AttackDamage.ToString();
     bulletController.attackForce = bulletData.AttackDamage;
 }
Ejemplo n.º 23
0
    void DrawSettings(BulletData b_Data)
    {
        b_Data.b_Name       = EditorGUILayout.TextField("Projectile name: ", b_Data.b_Name);
        b_Data.b_Mass       = EditorGUILayout.FloatField("Projectile mass: ", b_Data.b_Mass);
        b_Data.b_Velocity   = EditorGUILayout.FloatField("Projectile max velocity: ", b_Data.b_Velocity);
        b_Data.b_Damage     = EditorGUILayout.FloatField("Projectile basic damage: ", b_Data.b_Damage);
        b_Data.hasAnimation = EditorGUILayout.Toggle("Has animation? ", b_Data.hasAnimation);

        if (b_Data.hasAnimation != false)
        {
            EditorGUILayout.HelpBox("Reminder: Please uncheck 'has animation' box if animation is not yet available.", MessageType.Warning);
            b_Data.animation = (Animation)EditorGUILayout.ObjectField("Projectile animation: ", b_Data.animation, typeof(Animation));
        }

        b_Data.b_Prefab = (GameObject)EditorGUILayout.ObjectField("Projectile prefab: ", b_Data.b_Prefab, typeof(GameObject));

        if (b_Data.b_Name == null || b_Data.b_Name.Length < 2)
        {
            EditorGUILayout.HelpBox("Reminder: Please input a name for the new projectile. [Should be longer than two characters]", MessageType.Warning);
        }

        if (GUILayout.Button("Finish and save new projectile...", GUILayout.Height(40)))
        {
            SaveBulletSettings();
            window.Close();
        }
    }
Ejemplo n.º 24
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
            currentColorIndex = PlayerPrefs.GetInt(currentColorKey, 0);
            isRight           = PlayerPrefs.GetInt(isRightKey, 1);

            for (int i = 0; i < keys.Length; i++)
            {
                if (i == 0)
                {
                    isLockArray[i] = PlayerPrefs.GetInt(keys[i], 1);
                }
                else
                {
                    isLockArray[i] = PlayerPrefs.GetInt(keys[i], 0);
                }
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 25
0
        private Bullet CreateBullet(AmmoType type, BulletData data, Transform spawn)
        {
            Bullet bullet = factory.GetAmmo(type) as Bullet;

            bullet.Shoot(data, spawn.position);
            return(bullet);
        }
Ejemplo n.º 26
0
 // Update is called once per frame
 void Update()
 {
     if (Input.anyKeyDown)
     {
         string inputMessage = Input.inputString;
         if (Input.inputString != "" && !showmessage.getIsShow())
         {
             //Debug.Log(Input.inputString);
             //Debug.Log(Input.inputString.Substring(0,1));
             for (int i = 0; i < datacontrol.GetEnemyListLength(); i++)
             {
                 if (datacontrol.EnemyList[i] != null && datacontrol.EnemyList[i].transform.position.z >= -4.8f)
                 {
                     Data data = datacontrol.EnemyList[i].GetComponent <Data>();
                     if (Input.inputString.Substring(0, 1).ToUpper().Equals(data.CharName.ToString()) && !data.getChanged())
                     {
                         GameObject bullet = Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
                         bulletdata = bullet.GetComponent <BulletData>();
                         bulletdata.setEnemy(i);
                         GetComponent <AudioSource>().Play();
                         data.setChanged();
                         istrue = true;
                         return;
                     }
                 }
             }
         }
         if (istrue == false && !inputMessage.Equals("") && !showmessage.getIsShow())
         {
             gameControllerScript.Reduce(10);
             gameControllerScript.UpdateScore();
         }
         istrue = false;
     }
 }
Ejemplo n.º 27
0
 public Bullet(BulletData _bulletData, Vector3 target, GameObject bulletObj)
 {
     _speed     = _bulletData.BulletSpeed;
     _damage    = _bulletData.BulletDamage;
     _target    = target;
     _bulletObj = bulletObj;
 }
    public virtual void Initialize(BulletData bullet, SkillInfo.SkillParam skillParam, Vector3 pos, Quaternion rot)
    {
        //IL_0029: Unknown result type (might be due to invalid IL or missing references)
        //IL_002e: Unknown result type (might be due to invalid IL or missing references)
        //IL_002f: Unknown result type (might be due to invalid IL or missing references)
        //IL_0031: Unknown result type (might be due to invalid IL or missing references)
        //IL_0032: Unknown result type (might be due to invalid IL or missing references)
        //IL_0037: Unknown result type (might be due to invalid IL or missing references)
        //IL_0038: Unknown result type (might be due to invalid IL or missing references)
        //IL_003f: Unknown result type (might be due to invalid IL or missing references)
        //IL_0044: Unknown result type (might be due to invalid IL or missing references)
        //IL_004b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0057: Unknown result type (might be due to invalid IL or missing references)
        //IL_0058: Unknown result type (might be due to invalid IL or missing references)
        //IL_0059: Unknown result type (might be due to invalid IL or missing references)
        //IL_0069: Unknown result type (might be due to invalid IL or missing references)
        speed                = bullet.data.speed;
        initialVelocity      = bullet.data.speed;
        bulletSkillInfoParam = skillParam;
        Vector3 forward = Vector3.get_forward();

        forward  = rot * forward;
        forward *= speed;
        _transform.set_position(pos);
        _transform.LookAt(pos + forward);
        _rigidbody.set_velocity(forward);
    }
Ejemplo n.º 29
0
    // Shoot
    private void HandleShot(BulletData data, float power)
    {
        switch (Mathf.FloorToInt(power))
        {
        case 0:
        case 1:
            BulletHandler.ShootSplit(data, 3f, 2);
            break;

        case 2:
        case 3:
            BulletHandler.ShootSplit(data, 3f, 3);
            break;

        case 4:
            BulletHandler.ShootSplit(data, 4f, 3);
            break;

        default:
            BulletHandler.ShootSplit(data, 4f, 4);
            break;
        }

        foreach (Transform orb in transform.Find("Orbs"))
        {
            if (orb.gameObject.activeSelf)
            {
                orb.GetComponent <Orb>().Shoot();
            }
        }
    }
    // Shoot bullet burst
    public static IEnumerator ShootBurst(BulletData data, float spread, int count, float time, GameObject requiredObj = null)
    {
        bool  hasRequiredObj = requiredObj != null;
        float delay          = time / count;

        for (int i = 0; i < count; i++)
        {
            // Stop if requiredObj was destroyed
            if (hasRequiredObj && requiredObj == null)
            {
                yield break;
            }

            BulletData newData = data;
            if (hasRequiredObj)
            {
                newData.pos = requiredObj.transform.position;
            }
            newData.rot = data.rot + Random.Range(-spread, spread);
            ShootBullet(newData);

            yield return(new WaitForSeconds(delay));
        }

        yield return(null);
    }
Ejemplo n.º 31
0
 public static BulletData getInstance()
 {
     if(_instance == null)
     {
         _instance = new BulletData();
     }
     return _instance;
 }
Ejemplo n.º 32
0
 // Use this for initialization
 // Update is called once per frame
 public static Bullet GetBullet(BulletData bulletData)
 {
     GameObject bulletObj = Resources.Load<GameObject>("Bullet/Bullet");
     bulletObj = GameObject.Instantiate (bulletObj);
     Bullet bullet = bulletObj.GetComponent<Bullet>();
     bullet.MyBulletData = bulletData;
     return bullet;
 }
Ejemplo n.º 33
0
 // Use this for initialization
 public override void StartFire(  eUnitType findType)
 {
     m_findType = findType;
     m_GunData = new GunData ();
     m_bulletData = new BulletData ();
     m_fireCount = m_GunData.m_repeatCount;
     //newBullet.Fire ();
     m_isFire = true;
 }
Ejemplo n.º 34
0
 public void AssignBulletType(BulletData data)
 {
     int index = GetIndex(data.beltSlotInstance_m);
     Debug.Log("!! Assigning belt : " + index);
     if(index >= 0)
     {
         SetBulletType(index, BulletType.Regular);
     }
 }
Ejemplo n.º 35
0
    // Update is called once per frame
    public void Fire(BulletData bulletData, Vector3 startPos, Vector3 velocityDir, eUnitType findUnitType)
    {
        if(m_BulletModel) m_BulletModel.SetActive(true);
        if(m_crasheffect) m_crasheffect.SetActive(false);
        m_destoryed 					= false;
        m_findUnitType 					= findUnitType;
        float speed 					= m_baseSpeed * bulletData.m_bulletSpeed;
        m_rigidbody.transform.forward 	= velocityDir;
        m_rigidbody.position 			= startPos;
        m_rigidbody.velocity 			= velocityDir*speed;

        CancelInvoke ();
        float endTime = m_maxRange/speed;
        Invoke ("EndRange", endTime);
    }
Ejemplo n.º 36
0
    public static Dictionary<int, BulletData> Load(string fileName)
    {
        Dictionary<int, BulletData> table = new Dictionary<int, BulletData>();

        // 텍스트 테이블 읽어 들임
        XmlDocument xmlFile = new XmlDocument();
        xmlFile.PreserveWhitespace = false;
        try
        {
            TextAsset textAsset = (TextAsset)Resources.Load("XML/" + fileName, typeof(TextAsset));
            xmlFile.LoadXml(textAsset.text);
        }
        catch (Exception e)
        {
            return null;
        }

        XmlNodeList allData = xmlFile.ChildNodes;
        foreach (XmlNode mainNode in allData)
        {
            if (mainNode.Name.Equals("Data") == true)
            {
                XmlNodeList childNodeList = mainNode.ChildNodes;
                foreach (XmlNode node in childNodeList)
                {
                    BulletData tableData = new BulletData();

                    tableData.Index = Int32.Parse(node.Attributes.GetNamedItem("Index").Value);
                    tableData.MoveType = Int32.Parse(node.Attributes.GetNamedItem("MoveType").Value);
                    tableData.HitType = Int32.Parse(node.Attributes.GetNamedItem("HitType").Value);
                    tableData.Speed= Int32.Parse(node.Attributes.GetNamedItem("Speed").Value);
                    tableData.MuzzleCount= Int32.Parse(node.Attributes.GetNamedItem("MuzzleCount").Value);
                    tableData.MuzzleAngle= float.Parse(node.Attributes.GetNamedItem("MuzzleAngle").Value);
                    tableData.Amount= Int32.Parse(node.Attributes.GetNamedItem("Amount").Value);
                    tableData.Repeat= Int32.Parse(node.Attributes.GetNamedItem("Repeat").Value);
                    tableData.Delay= float.Parse(node.Attributes.GetNamedItem("Delay").Value);
                    tableData.Period= float.Parse(node.Attributes.GetNamedItem("Period").Value);
                    tableData.Size = float.Parse(node.Attributes.GetNamedItem("Size").Value);
                    
                    table.Add(tableData.Index, tableData);
                }
            }
        }
        return table;
    }
Ejemplo n.º 37
0
            //----------------死亡处理过程----------------//
            public Bullet1(TextureManager _t, Vector2D direction, Vector2D position, int color = 5,float _speed = 100)
            {
                texturemanager = _t;
                Direction.X = direction.X; Position.X = position.X;
                Direction.Y = direction.Y; Position.Y = position.Y;
                bulletbody = new BulletBodys.BigButterfly(_t, 3);                        //敌机子弹皮肤(miniRice)
                speed = _speed;
                BulletData bulletdata = new BulletData(Position, Direction, Scale, speed);
                contorler = new Entities.Controlors.DirectControler(bulletdata);      //选择直线控制器
                renderlevel = 0;

                //需要提前约定好
                MissTick = 61;
                MissRefresh = 60;
            }
Ejemplo n.º 38
0
 /// <summary>
 /// Shoots the bullet.
 /// </summary>
 /// <param name="data">Data.</param>
 public void ShootBullet(BulletData data)
 {
     if (!bulletsResMapping.ContainsKey(data.BulletResName)) {
         bulletsResMapping.Add(data.BulletResName, Statics.GetPrefab("Prefabs/Bullets/" + data.BulletResName));
     }
     GameObject bulletObj = MonoBehaviour.Instantiate(bulletsResMapping[data.BulletResName]) as GameObject;
     Bullet bullet = bulletObj.GetComponent<Bullet>();
     if (bullet != null) {
         bullet.bulletData = data;
         bullet.Shoot(data.FromPosition, data.ToPosition);
         bullets.Add(bullet);
     }
 }
Ejemplo n.º 39
0
        public FrameData(string text)
        {
            string[] data = text.Split('|');

            string[] robotText = data[0].Split('*');
            string[] bulletText = data[1].Split ('*');
            string[] hitText = data[2].Split('*');
            string[] arsenalText = data[3].Split('*');

            robotData = new RobotData[robotText.Length];
            for(int i = 0; i<robotText.Length; i++)
            {
                robotData[i] = new RobotData(robotText[i]);
            }

            if(bulletText[0] != "")
            {
                bulletData = new BulletData[bulletText.Length];
                for(int i = 0; i<bulletText.Length; i++)
                {
                    bulletData[i] = new BulletData(bulletText[i]);
                }
            }
            else
            {
                bulletData = null;
            }

            if(hitText[0] != "")
            {
                hitData = new HitData[hitText.Length];
                for(int i = 0; i<hitText.Length; i++)
                {
                    hitData[i] = new HitData(hitText[i]);
                }
            }
            else
            {
                hitData = null;
            }

            if(arsenalText[0] != "")
            {
                arsenalRespawnTime = new int[arsenalText.Length];
                for(int i = 0; i<arsenalText.Length; i++)
                {
                    arsenalRespawnTime[i] = Convert.ToInt32(arsenalText[i]);
                }
            }
            else
            {
                arsenalRespawnTime = null;
            }
        }
Ejemplo n.º 40
0
        public BulletData bulletdata; //子弹的记录数据

        #endregion Fields

        #region Constructors

        public DirectControler(BulletData b)
        {
            this.bulletdata = b;
            Direction = bulletdata.Direction;
            Position = bulletdata.Position;
        }