コード例 #1
0
ファイル: Projectile.cs プロジェクト: paulgeorges/dodgeball
    private void OnRedirectedCollision(ProjectileHit projectileHit)
    {
        if ((hitMask.value & 1 << projectileHit.hitObject.layer) != 0 && projectileHit.hitObject != owner && !_collisionComplete)
        {
            _collisionComplete = true;

            ProcessCollision(projectileHit);
        }
    }
コード例 #2
0
ファイル: Entity.cs プロジェクト: cloera/ZombieGame
    public virtual void OnHit(ProjectileHit proj)
    {
        health         -= proj.damage;
        healthBar.value = health;

        if (health <= 0)
        {
            Dead();
        }
    }
コード例 #3
0
    private void SpawnProjectile()
    {
        GameObject projectile = GameObject.Instantiate(arrowPrefab);

        projectile.transform.position = projectilePosition.transform.position;
        projectile.transform.rotation = projectilePosition.transform.rotation;

        ProjectileHit hit = projectile.GetComponent <ProjectileHit>();

        hit.Host = host;
        hit.SetBounces(host.Stats.ProjectileBounces);
    }
コード例 #4
0
    private void OnBulletHit(ProjectileHit projectileHitInfo)
    {
        if (projectileHitInfo.hitObject)
        {
            DamageInfo damageInfo = new DamageInfo();
            damageInfo.originPoint = projectileHitInfo.originPoint;
            damageInfo.impactPoint = projectileHitInfo.hitPoint;
            damageInfo.normal      = projectileHitInfo.normal;
            damageInfo.damageDone  = pointBlankDamage;

            projectileHitInfo.hitObject.SendMessage(GameMessages.TAKE_DAMAGE, damageInfo, SendMessageOptions.DontRequireReceiver);
        }
    }
コード例 #5
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (tempIFrames == 0)
        {
            if (collision.gameObject.tag == "Projectile")
            {
                ProjectileHit tempProjectile = collision.gameObject.GetComponent <ProjectileHit>();

                ChangeHealth(-tempProjectile.damage);

                tempIFrames = tempProjectile.iFrames;
            }
        }
    }
コード例 #6
0
ファイル: Projectile.cs プロジェクト: paulgeorges/dodgeball
    private void OnTriggerEnter(Collider other)
    {
        if ((hitMask.value & 1 << other.gameObject.layer) != 0 && other.gameObject != owner && !_collisionComplete)
        {
            _collisionComplete = true;

            ProjectileHit projectileHit = new ProjectileHit();
            projectileHit.originObject   = owner;
            projectileHit.originPoint    = originPoint;
            projectileHit.hitObject      = other.gameObject;
            projectileHit.hitObjectLayer = other.gameObject.layer;

            ProcessTriggerHit(ref projectileHit);
            ProcessCollision(projectileHit);
        }
    }
コード例 #7
0
ファイル: Projectile.cs プロジェクト: paulgeorges/dodgeball
    private void OnCollisionEnter(Collision other)
    {
        if ((hitMask.value & 1 << other.gameObject.layer) != 0 && other.gameObject != owner && !_collisionComplete)
        {
            _collisionComplete = true;

            ProjectileHit projectileHit = new ProjectileHit();
            projectileHit.originObject   = owner;
            projectileHit.originPoint    = originPoint;
            projectileHit.hitObject      = other.gameObject;
            projectileHit.hitObjectLayer = other.gameObject.layer;
            projectileHit.normal         = other.contacts[0].normal;
            projectileHit.hitPoint       = other.contacts[0].point;

            ProcessCollision(projectileHit);
        }
    }
コード例 #8
0
ファイル: Projectile.cs プロジェクト: Epicguru/BeatBlaster
    private void Update()
    {
        Vector3 newPos = transform.position + Velocity * Time.deltaTime;

        Velocity += Physics.gravity * Time.deltaTime;

        if (Physics.Linecast(transform.position, newPos, out RaycastHit hit, CollisionMask))
        {
            PoolObject.Despawn(PoolObject);
            if (HitEffect != null)
            {
                var eff = PoolObject.Spawn(HitEffect);
                eff.transform.position = hit.point + hit.normal * 0.01f;
                eff.transform.forward  = -hit.normal;
                eff.transform.parent   = hit.collider.transform;
            }
            if (HitParticles != null)
            {
                var eff = PoolObject.Spawn(HitParticles);
                eff.transform.position = hit.point + hit.normal * 0.01f;
                eff.transform.forward  = -hit.normal;
            }

            var phit = new ProjectileHit()
            {
                WorldPoint       = hit.point,
                WorldNormal      = hit.normal,
                Collider         = hit.collider,
                IncomingVelocity = Velocity,
                HealthChange     = -Damage
            };

            LastHit = hit.point;

            hit.transform.SendMessageUpwards("UponProjectileHit", phit, SendMessageOptions.DontRequireReceiver);

            if (hit.collider.attachedRigidbody != null)
            {
                hit.collider.attachedRigidbody.AddForceAtPosition(Velocity.normalized * HitImpulse, hit.point, ForceMode.Impulse);
            }
        }
コード例 #9
0
    void CheckCollisions(Collider2D collision)
    {
        if (tempIFrames == 0)
        {
            if (collision.gameObject.tag == "Enemy")
            {
                Enemy tempEnemy = collision.GetComponent <Enemy>();

                ChangeHealth(-tempEnemy.damage);

                tempIFrames = iFrames;
            }
            if (collision.gameObject.tag == "EnemyProjectile")
            {
                ProjectileHit tempProjectile = collision.GetComponent <ProjectileHit>();

                ChangeHealth(-tempProjectile.damage);

                tempIFrames = tempProjectile.iFrames;
            }
        }
    }
コード例 #10
0
ファイル: Health.cs プロジェクト: Epicguru/BeatBlaster
    public void UponProjectileHit(ProjectileHit hit)
    {
        if (IsDead && !CanChangeHealthWhenDead)
        {
            return;
        }

        int old = HP;

        HP += hit.HealthChange;
        if (HP > MaxHP)
        {
            HP = MaxHP;
        }
        if (HP < 0)
        {
            HP = 0;
        }

        if (old != HP)
        {
            UponHealthChange?.Invoke(this, HP - old, hit);
        }
    }
コード例 #11
0
    void OnCollisionEnter(Collision collision)
    {
        ContactPoint contact = collision.contacts[0];

        if (GameObjectPoolManager.Instance.ProjectileHitDict.ContainsKey(ProjectileInfo.ProjectileType))
        {
            ProjectileHit hit = GameObjectPoolManager.Instance.ProjectileHitDict[ProjectileInfo.ProjectileType].AllocateGameObject <ProjectileHit>(ProjectileManager.Instance.transform);
            hit.transform.position = contact.point + contact.normal * hitOffset;
            hit.transform.rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
            if (UseFirePointRotation)
            {
                hit.transform.rotation = gameObject.transform.rotation * Quaternion.Euler(0, 180f, 0);
            }
            else if (rotationOffset != Vector3.zero)
            {
                hit.transform.rotation = Quaternion.Euler(rotationOffset);
            }
            else
            {
                hit.transform.LookAt(contact.point + contact.normal);
            }

            hit.ParticleSystem.Play(true);
            hit.PoolRecycle(hit.ParticleSystem.main.duration);
        }

        foreach (GameObject detachedPrefab in Detached)
        {
            if (detachedPrefab != null)
            {
                detachedPrefab.transform.parent = null;
            }
        }

        PoolRecycle();
    }
コード例 #12
0
ファイル: Projectile.cs プロジェクト: CasualDutchman/LD41
 public void Shoot(Vector3 facing, float spe, float dam, ProjectileHit hit)
 {
     hitType  = hit;
     velocity = facing * spe;
     damage   = dam;
 }
コード例 #13
0
ファイル: Projectile.cs プロジェクト: paulgeorges/dodgeball
 private void ProcessCollision(ProjectileHit projectileHit)
 {
     ProcessBulletHit(projectileHit);
 }
コード例 #14
0
ファイル: Projectile.cs プロジェクト: paulgeorges/dodgeball
 private void ProcessBulletHit(ProjectileHit projectileHit)
 {
     SendMessage(GameMessages.BULLET_HIT, projectileHit, SendMessageOptions.DontRequireReceiver);
 }
コード例 #15
0
ファイル: Projectile.cs プロジェクト: paulgeorges/dodgeball
 private void ProcessTriggerHit(ref ProjectileHit projectileHit)
 {
     projectileHit.hitPoint = projectileHit.hitObject.collider.ClosestPointOnBounds(transform.position);
     projectileHit.hitObject.SendMessage(GameMessages.PROJECTILE_TRIGGER_HIT, projectileHit, SendMessageOptions.DontRequireReceiver);
 }
コード例 #16
0
ファイル: Moose.cs プロジェクト: cloera/ZombieGame
 public override void OnHit(ProjectileHit proj)
 {
     base.OnHit(proj);
     CanadianFury();
 }
コード例 #17
0
 public void Add(ProjectileHit hit) => m_ProjectileHit.Add(hit);
コード例 #18
0
 public void SetCallbackObject(ProjectileHit ph)
 {
     callback = ph;
 }
コード例 #19
0
ファイル: ClayPidgeon.cs プロジェクト: Epicguru/BeatBlaster
 private void UponProjectileHit(ProjectileHit hit)
 {
     PoolObject.Despawn(this.PoolObject);
     Debug.Log("Nice shot!");
 }