Beispiel #1
0
        private void Fire()
        {
            //// Set the fired flag so only Fire is only called once.
            //m_Fired = true;

            GameObject     shellInstance = ShellPool.Create(m_Shell, m_FireTransform.transform.position, m_FireTransform.transform.rotation) as GameObject;
            ShellExplosion shell         = shellInstance.GetComponent <ShellExplosion>();

            shell.Reset();
            shell.m_PhyWorld     = m_PhyWorld;
            shell.m_PlayerNumber = m_PlayerNumber;

            //// Create an instance of the shell and store a reference to it's rigidbody.
            //Rigidbody shellInstance =
            //    Instantiate (m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;

            //// Set the shell's velocity to the launch force in the fire position's forward direction.
            //shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward;

            //// Change the clip to the firing clip and play it.
            //m_ShootingAudio.clip = m_FireClip;
            //m_ShootingAudio.Play ();

            //// Reset the launch force.  This is a precaution in case of missing button events.
            //m_CurrentLaunchForce = m_MinLaunchForce;
        }
Beispiel #2
0
        public TankController(TankScriptableObject tankProps)
        {
            model = new TankModel();
            view  = GameObject.Instantiate(tankProps.tankPrefab);
            view.SetController(this);
            shellPool = new ShellPool(tankProps.shellPrefab);
            tankType  = tankProps.tankType;

            shellPrefab = tankProps.shellPrefab;
        }
        private void Update()
        {
            var time     = DateTime.Now;
            var dt       = (time - lastT).TotalSeconds;
            var lifeTime = (time - m_spawnTime).TotalSeconds;

            if (lifeTime >= m_MaxLifeTime)
            {
                ShellPool.Destroy(gameObject);
            }
            else
            {
                transform.position = transform.position + this.transform.forward * (float)dt * 20;
                var other = m_PhyWorld.CheckCollideWithPlayer(m_boxCollider, m_PlayerNumber);
                if (other != null)
                {
                    other.GetComponent <TankHealth>().TakeDamage(30);
                    Debug.Log("bullet intersect: " + other.name.ToString());
                }
            }
            lastT = DateTime.Now;
        }
Beispiel #4
0
 void Awake()
 {
     instance = this;
 }
Beispiel #5
0
 private void Start()
 {
     ShellPool = new ShellPool(ShellPrefab, 4);
     Loaded    = true;
 }
Beispiel #6
0
 private void Awake()
 {
     Unequip();
     shellPool_ = GetComponent <ShellPool>();
 }
Beispiel #7
0
 public ShellController(ShellPool shellPool)
 {
     ShellPool = shellPool;
 }