Ejemplo n.º 1
0
        public void DestroyObject(GameObject destroyObj, uint damage)
        {
            if (!_bricks.ContainsKey(destroyObj))
            {
                return;
            }

            IDestroyable brick = _bricks[destroyObj];

            brick.Damage(damage);

            if (brick.IsDestroy)
            {
                _currentCount--;
                if (_currentCount == 0)
                {
                    FullDestroy();
                }
                else if (_GenerateBonus)
                {
                    _bonusManager.GenerateBonus(brick.MyPosition);
                }
            }
            else
            {
                VisualUpdateObj(brick);
            }
        }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Ground")
        {
            spriteRenderer.sprite = onGround;

            direction = Vector2.right;
            speed     = 5;
        }

        if (other.tag == "Enemy")
        {
            IDestroyable iD = other.GetComponent <IDestroyable>();
            iD.Destroy();

            direction = tempDirection;

            Destroy();
        }

        if (other.tag == "Terrain")
        {
            Destroy();
        }
    }
Ejemplo n.º 3
0
 public static void Destroy(IDestroyable obj)
 {
     if (obj != null)
     {
         obj.Destroy();
     }
 }
 public void DoDamage(int damage, IDestroyable target)
 {
     if (target != null)
     {
         target.ReceiveDamage(damage);
     }
 }
 public override void HitAsteroid(IDestroyable asteroid)
 {
     base.HitAsteroid(asteroid);
     if (me.SceneMgr.GetCurrentPlayer().IsActivePlayer())
     {
         EmitBulletDueToCollision(asteroid);
     }
 }
Ejemplo n.º 6
0
 public PlayerBullet(MovingDirection direction, int damage, IDestroyable originEntity)
 {
     Damage       = damage;
     Color        = ConsoleColor.Green;
     OriginEntity = originEntity;
     Direction    = direction;
     Health       = 1;
 }
Ejemplo n.º 7
0
 public bool WasHit(IDestroyable dest)
 {
     if (hits == null)
     {
         return(false);
     }
     return(hits.Contains(dest));
 }
Ejemplo n.º 8
0
    public IAction RemoveFieldObject(Vector2Int targetFieldObjectCell)
    {
        IDestroyable fieldObjectToRemove = fieldMatrix.GetObjectFromStorage(targetFieldObjectCell);
        fieldMatrix.SetObjectToDefault(targetFieldObjectCell);

        if (fieldObjectToRemove != null) return new ActionSingle((callback) => { fieldObjectToRemove.Destroy(callback); });
        else return null;
    }
Ejemplo n.º 9
0
        public void DestroyComponent(int x, int y, GameTime gameTime)
        {
            IDestroyable toDestroy = (components[x, y] as IDestroyable);

            if (toDestroy != null)
            {
                toDestroy.Destroy(gameTime);
            }
        }
Ejemplo n.º 10
0
 public bool SetDamage(int damage, IDestroyable victim)
 {
     victim.TakeDamage(damage);
     if (victim.GetHealth() <= 0)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 11
0
    private void OnTriggerEnter(Collider other)
    {
        IDestroyable destroyable = other.transform.root.GetComponentInChildren <IDestroyable>();

        if (destroyable != null)
        {
            destroyable.Destroy();
        }
    }
Ejemplo n.º 12
0
        public void Destroy(IDestroyable d)
        {
            toDestroy.Add(d);

            if (!d.IsDestroyed)
            {
                d.Destroy();
            }
        }
Ejemplo n.º 13
0
    /// <summary>
    /// On collision, apply damage to an IDestroyable
    /// </summary>
    /// <param name="collision"></param>
    public void OnTriggerEnter2D(Collider2D collision)
    {
        IDestroyable des = collision.GetComponent <IDestroyable>();

        if (des != null)
        {
            des.DestroyMe(damagePower);
        }
    }
Ejemplo n.º 14
0
        protected override void Update(GameTime gameTime)
        {
            Time.UpdateTime(gameTime);
            InputManager.Update();

            if (InputManager.Exit)
            {
                Exit();
            }

            Time.IsInFixedUpdate  = true;
            timeSinceFixedUpdate += Time.UpdateDeltaTime;
            while (timeSinceFixedUpdate > Time.FixedDeltaTime)
            {
                timeSinceFixedUpdate -= Time.FixedDeltaTime;
                for (int i = 0; i < actors.Count; i++)
                {
                    Actor actor = actors[i];
                    if (!actor.IsDestroyed)
                    {
                        actor.EngineFixedUpdate();
                    }
                }

                CollisionHelper.CheckCollision(colliders);
            }
            Time.IsInFixedUpdate = false;

            for (int i = 0; i < actors.Count; i++)
            {
                Actor actor = actors[i];
                if (!actor.IsDestroyed)
                {
                    actor.EngineUpdate();
                }
            }

            while (toDestroy.Count > 0)
            {
                IDestroyable d = toDestroy[0];

                d.FinalDestroy();

                toDestroy.RemoveAt(0);
                if (d is Actor a)
                {
                    actors.Remove(a);
                }
                else if (d is RectangleCollider rc)
                {
                    colliders.Remove(rc);
                }
            }

            base.Update(gameTime);
        }
        /// <summary> Perform damage on the killable object </summary>
        /// <param name="destroyable"> The killable to act on. </param>
        /// <param name="damageAmount">The amount of damage to perform. </param>
        private void Damage(IDestroyable destroyable, int damageAmount)
        {
            destroyable.Health -= (int)(damageAmount / destroyable.Resistance.BulletResistance);
            Log.InfoFormat("Damaged {0}. Health remaining: {1}", destroyable, destroyable.Health);

            if (destroyable.Health <= 0)
            {
                destroyable.Destroy();
            }
        }
Ejemplo n.º 16
0
        public void SetTarget(IDestroyable target)
        {
            Target = target;

            foreach (var t in Turrets)
            {
                t.EnemyWatched = Target;
                t.Watcher = Target == null;
            }
        }
Ejemplo n.º 17
0
        public void DamageDestroyable(IDestroyable destroyable)
        {
            if (OriginEntity != null && destroyable == OriginEntity)
            {
                return;
            }

            destroyable.DealDamage(Damage);
            Health = 0;
        }
Ejemplo n.º 18
0
 public static async Task <TModel> Destroy <TModel>(
     this IDestroyable <TModel> resource,
     string modelId
     ) where TModel : ModelBase
 {
     return(await resource.Requester.Request <TModel>(
                resource.Endpoint,
                "DELETE",
                $"{resource.BasePath}/{modelId}"
                ));
 }
Ejemplo n.º 19
0
 void Awake()
 {
     if (holdPoint == null)
     {
         Debug.Log("hold point is null on " + gameObject.name);
     }
     destroyable = GetComponent <IDestroyable>();
     colliders   = GetComponentsInChildren <Collider>();
     SetInterpolation();
     SetIsHeld();
 }
        public virtual void HitAsteroid(IDestroyable asteroid)
        {
            if (hit)
            {
                return;
            }
            else
            {
                hit = true;
            }

            if (bullet.Owner.IsCurrentPlayerOrBot())
            {
                bullet.Owner.AddScoreAndShow(ScoreDefines.CANNON_HIT);
                if (bullet.Owner.IsCurrentPlayer())
                {
                    bullet.SceneMgr.FloatingTextMgr.AddFloatingText(ScoreDefines.CANNON_HIT, bullet.Center, FloatingTextManager.TIME_LENGTH_1,
                                                                    FloatingTextType.SCORE);
                }

                if (asteroid is UnstableAsteroid)
                {
                    Rect   opponentLoc = PlayerBaseLocation.GetBaseLocation(bullet.Owner.GetPosition() == PlayerPosition.RIGHT ? PlayerPosition.LEFT : PlayerPosition.RIGHT);
                    double xMin        = opponentLoc.X;
                    double xMax        = opponentLoc.X + opponentLoc.Width;

                    if (asteroid.Position.Y > SharedDef.VIEW_PORT_SIZE.Height * 0.4 &&
                        asteroid.Position.X >= xMin && asteroid.Position.X <= xMax)
                    {
                        if (bullet.Owner.IsCurrentPlayer())
                        {
                            bullet.SceneMgr.FloatingTextMgr.AddFloatingText(Strings.ft_score_cannon_unstable_above_enemy, bullet.Center,
                                                                            FloatingTextManager.TIME_LENGTH_4, FloatingTextType.BONUS_SCORE, FloatingTextManager.SIZE_BIG, false, true);
                        }
                        bullet.Owner.AddScoreAndShow(ScoreDefines.CANNON_DESTROYED_UNSTABLE_ASTEROID_ABOVE_ENEMY);
                    }
                }
            }

            asteroid.TakeDamage(bullet.Damage, bullet);

            NetOutgoingMessage msg = bullet.SceneMgr.CreateNetMessage();

            msg.Write((int)PacketType.BULLET_HIT);
            msg.Write(bullet.Id);
            msg.Write(asteroid.Id);
            msg.Write(bullet.Damage);
            bullet.SceneMgr.SendMessage(msg);

            EmmitorGroup g = ParticleEmmitorFactory.CreateBulletImplosionEmmitor(bullet.SceneMgr, bullet.Center, bullet.Color);

            g.Attach(bullet.SceneMgr, false);
        }
Ejemplo n.º 21
0
 public int RegisterHit(IDestroyable dest)
 {
     if (hits == null)
     {
         hits = new List <IDestroyable>();
     }
     if (!hits.Contains(dest))
     {
         hits.Add(dest);
     }
     return(hits.Count);
 }
Ejemplo n.º 22
0
 public void Trigger(GameObject collider)
 {
     if (collider.tag != "Bullet")
     {
         Destroy(gameObject);
         IDestroyable destroyable = collider.GetComponent <IDestroyable>();
         if (destroyable != null)
         {
             destroyable.Destroy();
         }
     }
 }
Ejemplo n.º 23
0
    public void Challenge()
    {
        bonus = 0;
        foreach (HexTile tile in curr.nears)
        {
            if (tile.edifice == null)
            {
                continue;
            }

            if (tile.edifice.team == team)
            {
                bonus++;
            }
        }

        int  dice        = Mathf.FloorToInt(Random.Range(1.01f, 6.99f));
        int  totalAttack = manager.red[team] + bonus + dice;
        bool nearEnemy   = false;

        foreach (HexTile tile in curr.nears)
        {
            IDestroyable destroyable = (IDestroyable)tile.edifice;


            if (destroyable != null)
            {
                if (destroyable.team == team)
                {
                    continue;
                }

                nearEnemy = true;
                bool survived = destroyable.Hit(totalAttack);

                if (!survived)
                {
                    alive = false;
                }
            }
        }

        if (!nearEnemy)
        {
            return;
        }

        damageText.color = Color.yellow;
        damageText.text  = totalAttack.ToString();
        StartCoroutine("HitMotion");
        nearEnemy = false;
    }
Ejemplo n.º 24
0
        void Awake()
        {
            destroyable = GetComponent <IDestroyable>();
            colliders   = GetComponentsInChildren <Collider>();
            rigidbodyToHold.interpolation = RigidbodyInterpolation.Interpolate;

            if (rigidbodyToHold == null)
            {
                rigidbodyToHold = GetComponent <Rigidbody>();
            }

            SetIsHeld();
        }
Ejemplo n.º 25
0
    public void OnHit(int damage, GameObject victim)
    {
        IDestroyable destroyModel = victim.GetComponent <IDestroyable>();

        if (destroyModel != null)
        {
            bool killed = _healthModel.SetDamage(damage, destroyModel);
            if (killed)
            {
                GameManager.Instanse.GameEventSystem.DestroyObjectEventLaunch(damage, victim);
            }
        }
    }
Ejemplo n.º 26
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log("Destroyer Triggered!");
        IDestroyable other = collision.GetComponent <IDestroyable>();

        if (other != null && collision.tag != "Player")
        {
            other.IDestroy();
            if (monster != null && !monster.GetComponent <Monster>().isDead)
            {
                HighScore.AddScore();
            }
        }
    }
Ejemplo n.º 27
0
    public void OnDestroy(int damage, GameObject victim)
    {
        IDestroyable component = victim.GetComponent <IDestroyable> ();

        if (component is BigAsteroidDestroyModel)
        {
            GameManager.Instanse.AsteroidsSpawnController.OnBigAsteroidDestroy(victim.transform.position);
        }
        if (component is UFODestroyModel)
        {
            GameManager.Instanse.UFOSpawnController.OnUFODestroy();
        }
        component.Destroy();
    }
Ejemplo n.º 28
0
    private IEnumerator killTarget()
    {
        yield return(new WaitForSeconds(secoundToDie));

        target = GetComponent <IDestroyable>();
        if (target != null)
        {
            target.kill();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 29
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            IDestroyable iD = other.GetComponent <IDestroyable>();
            iD.Destroy();

            Destroy();
        }
        else if (other.tag == "Terrain" || other.tag == "Core")
        {
            Destroy();
        }
    }
Ejemplo n.º 30
0
 private void OnTriggerStay(Collider other)
 {
     if (other.tag == "Boi")
     {
         if (Input.GetButtonDown("Fire2"))
         {
             IDestroyable destroyable = gameObject.GetComponent <IDestroyable>();
             if (destroyable != null)
             {
                 destroyable.Destroy();
             }
         }
     }
 }
Ejemplo n.º 31
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            other.gameObject.GetComponent <PlayerHealth> ().SetHealth(100);
        }

        IDestroyable destroyableObject = (IDestroyable)other.gameObject.GetComponent(typeof(IDestroyable));

        if (destroyableObject != null)
        {
            destroyableObject.Destroy();
            FirePoof.Play();
        }
    }
Ejemplo n.º 32
0
            public Missile(Scene scene, IDestroyable followedObject, double visualPriority, Vector3 position, double delay, DestroyableHandler targetReachedCallback)
            {
                FollowedObject = followedObject;
                TargetReachedCallback = targetReachedCallback;

                Image = new Image("PixelBlanc")
                {
                    Position = position,
                    VisualPriority = 1,
                    Alpha = 0,
                    SizeX = 50
                };

                Effect = scene.Particles.Get(@"mothershipMissile");
                Effect.VisualPriority = visualPriority;

                FollowEffect follow = new FollowEffect()
                {
                    Delay = delay,
                    Length = 15000,
                    FollowedObject = FollowedObject,
                    Speed = 1.5f,
                    Progress = Core.Utilities.Effect<IPhysical>.ProgressType.Linear
                };

                scene.PhysicalEffects.Add(this.Image, follow);
            }
        public void Attack(IDestroyable destroyBlob)
        {
            if (this.AttackType == AttackType.PutridFart)
            {
                destroyBlob.Health -= this.Damage;
            }
            else if (this.AttackType == AttackType.Blobplode)
            {
                int halfHealth = this.Health / 2;
                int currentDamage = this.Damage * 2;

                this.Health -= halfHealth;
                destroyBlob.Health -= currentDamage;
            }
        }
Ejemplo n.º 34
0
        private void DoTargetReached(IDestroyable obj)
        {
            var cb = obj as CelestialBody;

            if (cb != null)
            {
                cb.LifePoints = 0;
                return;
            }

            var bs = obj as HumanBattleship;

            if (bs != null)
            {
                bs.DoDie();
                bs.Alpha = 0;
                return;
            }
        }