Esempio n. 1
0
 public void RemoveShield(FXVShield s)
 {
     if (shieldObjects.Contains(s))
     {
         shieldObjects.Remove(s);
     }
 }
Esempio n. 2
0
 public void AddShield(FXVShield s)
 {
     if (!shieldObjects.Contains(s))
     {
         shieldObjects.Add(s);
     }
 }
Esempio n. 3
0
        void Update()
        {
            Vector3 newPos = transform.position + moveDir * speed * Time.deltaTime;

            ray.origin = transform.position;
            RaycastHit rhi;

            Vector3 offset = newPos - transform.position;

            currentTime += Time.deltaTime;

            //transform.position = newPos;
            float dist = Vector3.Distance(moveDir, transform.position);
            float step = speed * Time.deltaTime;

            Debug.Log(dist + "  this: " + transform.position.z + "  MOVE: " + moveDir.z);
            if ((dist > 5) && (transform.position.z <= moveDir.z))
            {
                transform.position = Vector3.MoveTowards(this.transform.position,
                                                         moveDir, step);
            }
            else
            {
                transform.position = Vector3.MoveTowards(this.transform.position,
                                                         postMoveDir, step);
            }

            bool needDestroy = false;

            if (currentTime > lifetime)
            {
                needDestroy = true;
            }

            if (Physics.Raycast(ray, out rhi, offset.magnitude))
            {
                needDestroy = true;

                FXVShield shield = rhi.collider.gameObject.GetComponentInParent <FXVShield>();

                if (shield && !shield.GetIsDuringActivationAnim())
                {
                    shield.OnHit(rhi.point, bulletHitSize);

                    if (hitParticles)
                    {
                        GameObject ps = Instantiate(hitParticles, transform.position, Quaternion.identity);
                        ps.transform.position = transform.position;
                        ps.GetComponent <ParticleSystem>().Emit(25);
                        Destroy(ps, 3.0f);
                    }
                }
            }
            if (needDestroy)
            {
                DestroyObject(gameObject);
            }
        }
Esempio n. 4
0
        void OnCollisionEnter(Collision collision)
        {
            ContactPoint contact = collision.contacts[0];

            if (collision.gameObject.name == "Shield")
            {
                shield = collision.gameObject.GetComponentInParent <FXVShield>();
                if (shield && !shield.GetIsDuringActivationAnim())
                {
                    shield.OnHit(contact.point, bulletHitSize);
                }
                Kill();

                Debug.Log(collision.gameObject.name);
            }
        }