public static bool Collide(IShip shipColliding, IProjectile ball)
        {
            Rectangle shipRect = new Rectangle(
               (int)shipColliding.Position.X + COLLISION_OFFSET,
               (int)shipColliding.Position.Y + COLLISION_OFFSET,
               shipColliding.FrameSize.X - (COLLISION_OFFSET * 2),
               shipColliding.FrameSize.Y - (COLLISION_OFFSET * 2));

            Rectangle cannonBall = new Rectangle(
                (int)ball.Position.X + COLLISION_OFFSET,
                (int)ball.Position.Y + COLLISION_OFFSET,
                ball.FrameSize.X - (COLLISION_OFFSET * 2),
                ball.FrameSize.Y - (COLLISION_OFFSET * 2));

            if (shipRect.Intersects(cannonBall))
            {
                ball.Position = new Vector2(9999,9999); // might be buggy
                return true;
            }
            if (ball.Position.Y >= ball.BallFiredPos.Y)
            {
                ball.Position = new Vector2(999,999);
            }

            return false;
        }
示例#2
0
文件: Starship.cs 项目: nok32/SoftUni
        public virtual void RespondToAttack(IProjectile projectile)
        {
            switch (projectile.GetType().Name)
            {
                case "PenetrationShell":
                    this.Health = this.Health - projectile.Damage > 0 ? this.Health - projectile.Damage : 0;
                    break;
                case "ShieldReaver":
                    this.Health = this.Health - projectile.Damage > 0 ? this.Health - projectile.Damage : 0;
                    this.Shields = this.Shields - (projectile.Damage * 2) > 0 ? this.Shields - (projectile.Damage * 2) : 0;
                    break;
                case "Laser":
                    var projectileDamage = projectile.Damage;

                    if (projectileDamage > this.Shields)
                    {
                        projectileDamage -= this.Shields;
                        this.Shields = 0;
                        this.Health = this.Health - projectileDamage > 0 ? this.Health - projectileDamage : 0;
                    }
                    else
                    {
                        this.Shields -= projectileDamage;
                    }

                    break;
            }
        }
        public override void RespondToAttack(IProjectile attack)
        {
            this.Shields += 50;

            base.RespondToAttack(attack);

            this.Shields -= 50;
        }
示例#4
0
 public override void RespondToAttack(IProjectile attack)
 {
     this.Shields += 50;
     attack.Hit(this);
     if (this.Shields - 50 < 0)
     {
         this.Shields = 0;
         return;
     }
     this.Shields -= 50;
 }
 public ProjectileTileCollisionHandler(CollisionData collision)
 {
     if (collision.GameObjectA is IProjectile)
     {
         projectile = (IProjectile)collision.GameObjectA;
     }
     else
     {
         projectile = (IProjectile)collision.GameObjectB;
     }
 }
 public EnemyFireballCollisionHandler(CollisionData collision)
 {
     if (collision.GameObjectA is IEnemy)
     {
         enemy = (IEnemy)collision.GameObjectA;
         fireball = (IProjectile)collision.GameObjectB;
     }
     else
     {
         enemy = (IEnemy)collision.GameObjectB;
         fireball = (IProjectile)collision.GameObjectA;
     }
 }
        public PipeFireballCollisionHandler(CollisionData collision)
        {
            this.collision = collision;
            this.side = collision.CollisionSide;

            if (collision.GameObjectA is IProjectile)
            {
                fireball = (IProjectile)collision.GameObjectA;
            }
            else
            {
                fireball = (IProjectile)collision.GameObjectB;
                this.side.FlipSide();
            }
        }
示例#8
0
 public SpinnerBullet(IProjectile projectile) : base(projectile, RangedWeaponPowerup.Spinner)
 {
     if (projectile.ProjectileItem == ProjectileItem.BAZOOKA ||
         projectile.ProjectileItem == ProjectileItem.GRENADE_LAUNCHER ||
         projectile.ProjectileItem == ProjectileItem.FLAREGUN ||
         projectile.ProjectileItem == ProjectileItem.BOW ||
         projectile.ProjectileItem == ProjectileItem.SNIPER)
     {
         UpdateDelay = 0;
     }
     else
     {
         UpdateDelay = 4;
     }
 }
示例#9
0
    protected override void OnTriggerEnter2D(Collider2D collider)
    {
        base.OnTriggerEnter2D(collider);

        Vector2 contactPoint = (collider.bounds.center - transform.position) / 2f + transform.position;

        if (collider.gameObject.layer == LayerProjectile && HasShield)
        {
            IProjectile projectile = collider.GetComponent <IProjectile>();
            if (projectile.GetShooter() != this)
            {
                projectile.Hit(this, contactPoint);
            }
        }
    }
示例#10
0
        public void Update()
        {
            foreach (IEnemy enemy in EnemyList)
            {
                enemy.Update();
            }
            foreach (IBlock block in BlockList)
            {
                block.Update();
            }
            foreach (IItem item in ItemList)
            {
                item.Update();
            }
            foreach (IFire fire in FireList)
            {
                fire.Update();
            }
            count++;
            Queue <IProjectile> tempQueue = new Queue <IProjectile>();

            while (ProjectileQueue.Count > 0)
            {
                IProjectile temp = ProjectileQueue.Dequeue();
                if (temp.mySprite is MarioFireBallBoomSprite && count == 50)
                {
                }
                else
                {
                    temp.Update();
                    tempQueue.Enqueue(temp);
                }
            }
            if (count == 50)
            {
                count = 0;
            }
            ProjectileQueue = tempQueue;

            foreach (IBackground background in BackgroundList)
            {
                background.Update();
            }
            CollisionDetector.Update(this);
            ECollisionDetector.Update(this);
            FBCollisionDetector.Update(this);
            ICollisionDetector.Update(this);
        }
示例#11
0
    public override void Initialize(IProjectile projectile, HeroSide side)
    {
        var pos = (Vector2)transform.position;

        if (side == HeroSide.Top)
        {
            goal = new Vector2(pos.x, Game.Levels.CurrentLevel.BottomGoal.Position.y);
        }
        else
        {
            goal = new Vector2(pos.x, Game.Levels.CurrentLevel.TopGoal.Position.y);
        }

        this.projectile = projectile;
        this.side       = side;
    }
示例#12
0
        private void OnTriggerEnter2D(Collider2D otherObject)
        {
            IProjectile onCollision = otherObject.GetComponent <IProjectile>();

            if (onCollision != null)
            {
                if (!onCollision.CanPenetrate && otherObject.tag == this.objectsToDestroyTags)
                {
                    Destroy(otherObject.gameObject);
                }
            }
            else if (otherObject.tag == this.objectsToDestroyTags)
            {
                Destroy(otherObject.gameObject);
            }
        }
 public BuckeyeProjectileCollisionHandler(CollisionData collision)
 {
     this.collision = collision;
     collisionSide = (ICollisionSide)collision.CollisionSide;
     if (collision.GameObjectA is IBuckeyePlayer)
     {
         player = (IBuckeyePlayer)collision.GameObjectA;
         projectile = (IProjectile)collision.GameObjectB;
     }
     else
     {
         player = (IBuckeyePlayer)collision.GameObjectB;
         projectile = (IProjectile)collision.GameObjectA;
         collisionSide = collisionSide.FlipSide();
     }
 }
示例#14
0
    public void OnCollisionEnter(Collision collision)
    {
        //If hit by a projectile
        IProjectile projectile = collision.gameObject.GetComponent <IProjectile>();

        if (projectile != null)
        {
            curHP -= projectile.GetDamage();
            if (curHP <= 0)
            {
                AddScore();
                Die();
            }
            projectile.Die();
        }
    }
示例#15
0
        protected virtual void DamageToNPC(Map map, IProjectile projectile)
        {
            foreach (Inpc npc in map.MapNpcs)
            {
                if (npc.Friendly == false)
                {
                    List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line));

                    if ((intersections?.Count > 0 || CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) && (_from is Player))
                    {
                        Damage(npc, projectile);
                        break;
                    }
                }
            }
        }
示例#16
0
    //Projectile Creation

    public void CreateProjectile(IProjectile projectileDetails)
    {
        switch (projectileDetails.projectileType)
        {
        case eProjectileType.FIREBALL:
            CreateSimpleProjectile(projectileDetails);
            break;

        case eProjectileType.LIGHTNING:
            CreateSimpleProjectile(projectileDetails);
            break;

        default:
            break;
        }
    }
示例#17
0
        private static void OnProjectileHit(IProjectile projectile, ProjectileHitArgs args)
        {
            if (args.IsPlayer)
            {
                var player = Game.GetPlayer(args.HitObjectID);
                var bot    = GetBot(player);
                if (bot == Bot.None)
                {
                    return;
                }

                // I use this instead of PlayerDamage callback because this one include additional
                // info like normal vector
                bot.OnProjectileHit(projectile, args);
            }
        }
 public WolverineProjectileCollisionHandler(CollisionData collision)
 {
     this.collision = collision;
     collisionSide = (ICollisionSide)collision.CollisionSide;
     if (collision.GameObjectA is IWolverine)
     {
         enemy = (IWolverine)collision.GameObjectA;
         projectile = (IProjectile)collision.GameObjectB;
     }
     else
     {
         enemy = (IWolverine)collision.GameObjectB;
         projectile = (IProjectile)collision.GameObjectA;
         collisionSide = collisionSide.FlipSide();
     }
 }
示例#19
0
        private void LookForTarget(IProjectile projectile)
        {
            Collider [] colliders = Physics.OverlapSphere(projectile.Transform.position, _awareRange);

            foreach (Collider collider in colliders)
            {
                IDamagable damagable = collider.GetComponent <IDamagable>();

                if (damagable != null && collider.GetComponent <Destroyable>() == null &&
                    !(damagable.GetType().IsAssignableFrom(projectile.TargetToAvoid.GetType())))
                {
                    projectile.Target = collider.transform;
                    break;
                }
            }
        }
示例#20
0
/*
 * // Make sure to keep this script enabled after destruction for this to work
 * private void FixedUpdate()
 * {
 *  List<string> s = new List<string>();
 *  foreach (Rigidbody rb in GetComponentsInChildren<Rigidbody>())
 *  {
 *    s.Add(rb.name + "=" + rb.velocity.ToString("F2"));
 *  }
 *  Debug.Log("Velocities: " + string.Join(", ", s.ToArray()));
 * }
 */

    private void OnCollisionEnter(Collision collision)
    {
        if (m_destroyed)
        {
            return;
        }

        GameObject collided      = collision.collider.gameObject;
        int        collidedLayer = 1 << collided.layer;

        if ((collidedLayer & projectileLayer) == 0)
        {
            return;
        }

        IProjectile projectile = collided.GetComponent <IProjectile>();

        if (projectile == null)
        {
            return;
        }

        healthPoints -= projectile.HitPoints;
        if (healthPoints <= 0)
        {
            m_destroyed  = true;
            healthPoints = 0;
            int random = Random.Range(0, explosionPrefabs.Length - 1);
            if (explosionPrefabs.Length > 0)
            {
                m_explosions[random].transform.position = transform.position;
                m_explosions[random].transform.rotation = transform.rotation;
                m_explosions[random].SetActive(true);
            }
            random = Random.Range(0, explosionClips.Length - 1);
            m_audio.Stop();
            m_audio.PlayOneShot(explosionClips[random]);
            SelfDestruct(explosionClips[random].length);
        }
        else if (bulletImpactPrefab != null)
        {
            Instantiate(bulletImpactPrefab, collision.contacts[0].point, Quaternion.identity);
            int random = Random.Range(0, bulletImpactClips.Length - 1);
            m_audio.Stop();
            m_audio.PlayOneShot(bulletImpactClips[random]);
        }
    }
示例#21
0
 public static int GetProjectileWidth(IProjectile projectile)
 {
     if (projectile is ArrowProjectile || projectile is SilverArrowProjectile)
     {
         return(arrowWidth * DRAWSCALE);
     }
     else if (projectile is BlueCandleProjectile || projectile is RedCandleProjectile)
     {
         return(flameWidth);
     }
     else if (projectile is BombProjectile)
     {
         return(standardWidth * DRAWSCALE);
     }
     else if (projectile is BombExplosion)
     {
         return(explosionWidth * DRAWSCALE);
     }
     else if (projectile is BoomerangProjectile || projectile is MagicBoomerangProjectile)
     {
         return(standardWidth * DRAWSCALE);
     }
     else if (projectile is FireballProjectile)
     {
         return(fireballWidth * DRAWSCALE);
     }
     else if (projectile is SwordBeamProjectile)
     {
         return(swordBeamWidth * DRAWSCALE);
     }
     else if (projectile is SwordBeamExplosion)
     {
         return(standardWidth * DRAWSCALE);
     }
     else if (projectile is SwordProjectile)
     {
         return(swordWidth);
     }
     else if (projectile is SonicBeamProjectile)
     {
         return(sonicBeamWidth);
     }
     else
     {
         return(0);
     }
 }
示例#22
0
 public static int GetProjectileHeight(IProjectile projectile)
 {
     if (projectile is ArrowProjectile || projectile is SilverArrowProjectile)
     {
         return(standardHeight * DRAWSCALE);
     }
     else if (projectile is BlueCandleProjectile || projectile is RedCandleProjectile)
     {
         return(flameHeight);
     }
     else if (projectile is BombProjectile)
     {
         return(standardHeight * DRAWSCALE);
     }
     else if (projectile is BombExplosion)
     {
         return(explosionHeight * DRAWSCALE);
     }
     else if (projectile is BoomerangProjectile || projectile is MagicBoomerangProjectile)
     {
         return(boomerangHeight * DRAWSCALE);
     }
     else if (projectile is FireballProjectile)
     {
         return(fireballHeight * DRAWSCALE);
     }
     else if (projectile is SwordBeamProjectile)
     {
         return(standardHeight * DRAWSCALE);
     }
     else if (projectile is SwordBeamExplosion)
     {
         return(swordBeamExplosionHeight * DRAWSCALE);
     }
     else if (projectile is SwordProjectile)
     {
         return(swordHeight);
     }
     else if (projectile is SonicBeamProjectile)
     {
         return(sonicBeamHeight);
     }
     else
     {
         return(0);
     }
 }
示例#23
0
 public void Shoot(Vector3 startLocation, Vector3 target, float force)
 {
     if (_projectileQueue.Count == 0)
     {
         CantShootEvent.Raise(this, EventArgs.Empty);
     }
     else
     {
         IProjectile projectile = _projectileQueue.Dequeue();
         projectile.Shoot(startLocation, target, force);
         ShootEvent.Raise(this, EventArgs.Empty);
         if (_projectileQueue.Count == 0)
         {
             QueueEmptiedEvent.Raise(this, EventArgs.Empty);
         }
     }
 }
示例#24
0
        /// <summary>
        /// Called by projectiles when they land / hit, this is where we apply damage/slows etc.
        /// </summary>
        public void ApplyEffects(IAttackableUnit u, IProjectile p = null)
        {
            if (SpellData.HaveHitEffect && !string.IsNullOrEmpty(SpellData.HitEffectName))
            {
                ApiFunctionManager.AddParticleTarget(Owner, SpellData.HitEffectName, u);
            }

            _spellGameScript.ApplyEffects(Owner, u, this, p);
            if (p is null)
            {
                return;
            }
            if (p.IsToRemove())
            {
                Projectiles.Remove(p.NetId);
            }
        }
示例#25
0
    protected override void Update()
    {
        gun.Rotate(Vector3.Dot(comparisor, Vector3.left));

        if (slugGun.FireRate(Time.deltaTime))
        {

            bullet = slugGun.Fire();
            bullet.CharacterType = CharacterTypes.PLAYER;
            bulletInstance = PooledBulletGameObjects.GetPooledBullet(Character);
            bulletInstance.Projectile = bullet;
            telegram.Receiver = bulletInstance;
            telegram.Message = gunModel;
            messageDispatcher.DispatchMessage(telegram);
        }
        base.Update();
    }
        public BlockFireballCollisionHandler(CollisionData collision)
        {
            this.collision = collision;
            this.side      = collision.CollisionSide;

            if (collision.GameObjectA is IProjectile)
            {
                fireball = (IProjectile)collision.GameObjectA;
                block    = (IBlock)collision.GameObjectB;
            }
            else
            {
                fireball = (IProjectile)collision.GameObjectB;
                block    = (IBlock)collision.GameObjectA;
                this.side.FlipSide();
            }
        }
示例#27
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.layer == LayerMask.NameToLayer("Ground"))
        {
            anim.SetBool("Jumping", false);
        }

        if (col.gameObject.tag == "EnemyBullet")
        {
            IProjectile projectile = (IProjectile)col.gameObject.GetComponent(typeof(IProjectile));
            if (projectile != null)
            {
                playerHealthChange(-projectile.getDamageValue());
                projectile.OnActorHit();
            }
        }
    }
示例#28
0
 public ProjectileProjectileCollisionResponse(IProjectile p1, IProjectile p2, CollisionSide type)
 {
     if (p1 is FireballProjectile && p2 is ShellProjectile)
     {
         if (type != CollisionSide.None)
         {
             p2.Die();
         }
     }
     if (p2 is FireballProjectile && p1 is ShellProjectile)
     {
         if (type != CollisionSide.None)
         {
             p1.Die();
         }
     }
 }
示例#29
0
    public void FireProjectile()
    {
        float distance = (direction == Utils.Direction.LEFT) ? shootDistance * -1 : shootDistance;

        Vector2 destination = new Vector2(shootStart.position.x + distance, shootStart.position.y);

        GameObject  go = Instantiate(ProjectilePrefab);
        IProjectile fb = go.GetComponent <IProjectile>();

        fb.maxDistance = Mathf.Abs(distance);
        fb.start       = shootStart.position;
        fb.end         = destination;
        fb.source      = type;
        fb.ReleaseProjectile();

        cooldownTimer = Time.time;
    }
示例#30
0
    // Token: 0x06001A86 RID: 6790 RVA: 0x0008A580 File Offset: 0x00088780
    public void EmitRemoteProjectile(int cmid, Vector3 origin, Vector3 direction, byte slot, int projectileID, bool explode)
    {
        CharacterConfig characterConfig;

        if (this.TryGetPlayerAvatar(cmid, out characterConfig))
        {
            if (characterConfig.Avatar.Decorator.AnimationController)
            {
                characterConfig.Avatar.Decorator.AnimationController.Shoot();
            }
            IProjectile projectile = characterConfig.WeaponSimulator.EmitProjectile(cmid, characterConfig.State.Player.PlayerId, origin, direction, (global::LoadoutSlotType)slot, projectileID, explode);
            if (projectile != null)
            {
                Singleton <ProjectileManager> .Instance.AddProjectile(projectile, projectileID);
            }
        }
    }
        protected void addProjectile(IProjectile proj)
        {
            if (!materialDict.ContainsKey(proj.Color))
            {
                materialDict.Add(proj.Color, new DiffuseMaterial(new SolidColorBrush(proj.Color)));
            }
            GeometryModel3D geo = new GeometryModel3D(sphereMesh, materialDict[proj.Color]);

            collection.Add(geo);

            TranslateTransform3D trans = new TranslateTransform3D(proj.Position);

            geo.Transform = trans;
            projectiles.Add(new InternalProjectile {
                GeoObject = geo, Transform = trans, UnderlyingProjectile = proj
            });
        }
示例#32
0
    public static void DealDamage(IProjectile projectile, IBlock block)
    {
        var collisionPosition = ((MonoBehaviour)projectile).transform.position;

        if (projectile.damageTypes.isEnergetic)
        {
            DealEnergeticDamage(projectile.damageTypes.energeticType);
        }
        if (projectile.damageTypes.isKinetic)
        {
            DealKineticDamage(projectile.damageTypes.kineticType);
        }
        if (projectile.damageTypes.isExplosive)
        {
            DealExplosiveDamage(projectile.damageTypes.explosiveType, collisionPosition, projectile);
        }
    }
示例#33
0
    public override BattleHero CollectTarget(SkillBase skill)
    {
        base.CollectTarget(skill);
        if (!owner.battleGroup)
        {
            return(null);
        }

        if (owner is IProjectile)
        {
            IProjectile p = owner as IProjectile;
            lastTarget = p.GetTarget() as BattleHero;
            return(lastTarget);
        }

        return(null);
    }
示例#34
0
 public void OnCollisionResponse(IProjectile projectile, CollisionDetection.CollisionSide collisionSide)
 {
     /*
      * if (projectile is MagicBoomerangProjectile || projectile is BoomerangProjectile)
      * {
      *  if (this.item is IDrop) { }
      *  if (!this.item.IsGrabbed)
      *  {
      *      this.boomerang = projectile;
      *      //this.GrabbedOffset = new Vector2((this.item.Bounds.Width - this.boomerang.Bounds.Width) / 2, (this.item.Bounds.Height - this.boomerang.Bounds.Height) / 2);
      *      this.grabbed = true;
      *  }
      *  this.item.Physics.Location = new Vector2(this.boomerang.Physics.Location.X - GrabbedOffset.X, this.boomerang.Physics.Location.Y - this.GrabbedOffset.Y);
      *  this.item.Bounds = new Rectangle((int)this.item.Physics.Location.X, (int)this.item.Physics.Location.Y, this.item.Bounds.Width, this.item.Bounds.Height);
      * }
      */
 }
示例#35
0
        private void TickProjectiles()
        {
            List <IProjectile> toDelete = new List <IProjectile>();

            for (var i = 0; i < m_Projectiles.Count; i++)
            {
                IProjectile projectile = m_Projectiles[i];
                projectile.TickApproaching();
                if (projectile.DidHit())
                {
                    projectile.DestroyProjectile();
                    m_Projectiles[i] = null;
                }
            }

            m_Projectiles.RemoveAll(projectile => projectile == null);
        }
示例#36
0
        private void TickProjectiles()
        {
            for (int i = 0; i < m_Projectiles.Count; i++)
            {
                IProjectile projectile = m_Projectiles[i];
                projectile.TickApproaching();
                if (projectile.DidHit())
                {
                    projectile.DestroyProjectile();
                    m_Projectiles[i] = null;
                    //Не можем remove в foreach - нельзя модифицировать коллекцию, по которой enumerate
                    //В случае for можно было бы удалить, но тогда нужно думать, что с индексом, проще так
                }
            }

            m_Projectiles.RemoveAll(projectile => projectile == null);
        }
示例#37
0
    protected override void Attack()
    {
        if (!isAttacking && (Utils.GetUnixTime() - cooldownTimer) > cooldown)
        {
            Collider2D collider = Physics2D.OverlapCircle(transform.position, 7f, 1 << LayerMask.NameToLayer("Player"));
            if (collider)
            {
                float distance = shootStart.position.x - collider.transform.position.x;

                if (direction == Utils.Direction.RIGHT && distance > 0)
                {
                    direction = Utils.Direction.LEFT;
                }
                if (direction == Utils.Direction.LEFT && distance <= 0)
                {
                    direction = Utils.Direction.RIGHT;
                }

                Flip(direction);

                isAttacking   = true;
                cooldownTimer = Utils.GetUnixTime();
                Transform destination = collider.transform;
                foreach (float offset in projectileDirectionsOffset)
                {
                    Vector3 vector = destination.position;
                    vector.y += offset;

                    GameObject  go = UnityEngine.Object.Instantiate(ProjectilePrefab);
                    IProjectile fb = go.GetComponent <IProjectile>();
                    fb.start  = new Vector3(shootStart.position.x, shootStart.position.y, shootStart.position.z);
                    fb.end    = vector;
                    fb.source = type;
                    projectiles.Add(fb);
                }
                anim.Play("GolemAttack");


                timer          = new System.Timers.Timer();
                timer.Interval = 1000;
                timer.Elapsed += StopAttacking;
                timer.Enabled  = true;
            }
        }
    }
示例#38
0
        public void AddDebuff(IProjectile projectile)
        {
            if (projectile.AssignedDebuff == null)
            {
                return;
            }

            IDebuff debuff = projectile.AssignedDebuff;

            if (!activeDebuffs.ContainsKey(debuff.Type)) //Debuffs do not stack.
            {
                activeDebuffs.Add(debuff.Type, debuff);
            }
            else
            {
                TrySetReadyForPayload(debuff.Type);
            }
        }
示例#39
0
 public void SetUp(IProjectile parent)
 {
     this.parent      = parent;
     Returning        = false;
     IsExpired        = false;
     StunDuration     = 0;
     Speed            = 0;
     Acceleration     = 0;
     Damage           = 0;
     Width            = 0;
     Height           = 0;
     Offset           = 0;
     Source           = new Physics(Vector2.Zero);
     Physics          = new Physics(Vector2.Zero);
     Data             = new EntityData();
     Sprite           = ProjectileSpriteFactory.Instance.Bomb();
     CollisionHandler = new ProjectileCollisionHandler(this.parent);
 }
示例#40
0
        private void Bounce(IProjectile projectile, float speed)
        {
            Ray        ray = new Ray(projectile.Transform.position, projectile.Transform.forward);
            RaycastHit hit;

            bool isHit = Physics.Raycast(ray, out hit, Time.deltaTime * speed + .45f, ~(projectile as MonoBehaviour).gameObject.layer);

            if (isHit && hit.collider.gameObject.GetComponent <IDamagable>() == null)
            {
                Vector3 direction = Vector3.Reflect(projectile.Rigidbody.velocity, hit.normal);

                float rotation = 90 - Mathf.Atan2(direction.z, direction.x) * Mathf.Rad2Deg;

                projectile.Transform.eulerAngles = new Vector3(0, rotation, 0);

                projectile.Rigidbody.velocity = projectile.Transform.forward * speed;
            }
        }
示例#41
0
 public void DeactivatePooledProjectile(ICharacter character, IProjectile projectile)
 {
     projectilesBoundToCharacterType[character.CharacterType].Find(p => p.Projectile == projectile).Active = false;
 }
示例#42
0
 public void DeactivatePooledBullet(GameObject bullet, ICharacter character, IProjectile projectile)
 {
     bulletPool.DeactivatePooledProjectile(character, projectile);
     pooledBullets.Find(b => b == bullet).SetActive(false);
 }
 /// <summary>
 /// The respond to attack.
 /// </summary>
 /// <param name="projectile">
 /// The projectile.
 /// </param>
 public virtual void RespondToAttack(IProjectile projectile)
 {
     projectile.Hit(this);
 }
 /// <summary>
 /// Removes a projectile from the list
 /// </summary>
 /// <param name="projectileToRemove">The projectile to remove</param>
 public void RemoveProjectile(IProjectile projectileToRemove)
 {
     projectileList.RemoveAll(x => x.Equals(projectileToRemove));
 }
 public static void ProjectileEnemyCollision(IProjectile proj, IEnemy enemy) {
     if (!proj.CanHarmEnemies()) return;
     enemy.Kill();
     proj.Delete();
     if (proj is Bullet) SoundManager.PlayHitSound();
     else SoundManager.PlayKickSound();
 }
示例#46
0
 void spawnNewProjectile()
 {
     projectile = (GameObject)Instantiate(ProjectilePrefab, transform.position, Quaternion.identity);
     projScript = projectile.GetComponent<IProjectile>();
     projScript.SetDamage(Damage, CritDamage);
     projScript.SetRange(Range, CritRange);
     projectile.transform.SetParent(transform);
     projectile.transform.localRotation = new Quaternion(0, 0, 0, 0);
 }
        public static void ProjectileBlockCollision(IProjectile proj, Block block) {

            Vector2 direction = GetCollisionDirection(proj.Bounds, block.Bounds);
            int penetration = GetPenetration(proj.Bounds, block.Bounds, direction);
            proj.Position += direction * penetration;

            proj.Bounce(direction);
        }
        public static void ProjectilePlayerCollision(IProjectile proj, IMario player) {
            if (player.CurrentState is DeadMarioState)
                return;

            if (!proj.CanHarmPlayers()) return;
            player.TakeDamage();
            proj.Delete();
        }
示例#49
0
 public IProjectile Create(IProjectile projectile)
 {
     // TODO figure out how to replace, this is slow, but only gets hit at startup.
     return (IProjectile)Activator.CreateInstance(projectile.GetType());
 }
 public void HitBy(IProjectile projectile)
 {
     if (pstate == PlayerState.Normal)
     {
         this.Health -= projectile.GetDamage();
         if(this.Health > 0)
             this.DebugFlash();
         else
         {
             this.Destroy();
             timer = maxDeathTime;
         }
     }
 }
示例#51
0
	public void ReleaseBullet(IProjectile bullet) {
		bullet.getGameObject().SetActive (false);
		bullet.getGameObject().transform.position = temp;
		pool.Push (bullet);
	}
 /// <summary>
 /// Adds a new projectile to the game
 /// </summary>
 /// <param name="newProjectile">The new projectile to add</param>
 public void AddProjectile(IProjectile newProjectile)
 {
     if (projectileList.Exists(x => x.IsActive == false))
     {
         int index = projectileList.FindIndex(x => x.IsActive == false);
         projectileList[index] = newProjectile;
     }
     else
         projectileList.Add(newProjectile);
 }
示例#53
0
        public TestRangeWeapon(IReceiver receiver, IMessageDispatcher messageDispatcher,
			IProjectile projectile, IBulletPool bulletPool = null)
            : base(receiver, messageDispatcher, projectile, bulletPool)
        {
        }
示例#54
0
    void projFire(bool crit)
    {
        readyToFire = false;
            projectileOffset = ProjectilePositions[0];
            projScript.Fire(DamageTypes.Ranged, crit);
            StartCoroutine(Cooldown(true));
            PlaySound(ShootSounds[Random.Range(0, ShootSounds.Length - 1)]);

            projScript = null;
            projectile = null;
    }
 public virtual void RespondToAttack(IProjectile attack)
 {
     attack.Hit(this);
 }
示例#56
0
 public override void RespondToAttack(IProjectile projectile)
 {
     this.Shields += ShieldBonus;
     base.RespondToAttack(projectile);
     this.Shields = this.Shields - ShieldBonus > 0 ? this.Shields - ShieldBonus : 0;
 }
示例#57
0
 public static void AddProjectile(IProjectile proj)
 {
     projectiles.Add(proj);
     objects.Add(proj);
 }
        /// <summary>
        /// The respond to attack.
        /// </summary>
        /// <param name="projectile">
        /// The projectile.
        /// </param>
        public override void RespondToAttack(IProjectile projectile)
        {
            this.Shields += ResponseToAttackShieldsIncrease;

            base.RespondToAttack(projectile);

            this.Shields -= ResponseToAttackShieldsIncrease;
        }
示例#59
0
 public TestRangeWeapon(IProjectile projectile)
     : base(0, projectile)
 {
 }