// Update is called once per frame
    void Update()
    {
        Collider2D[] aliveObjectsInRadius = Physics2D.OverlapCircleAll(transform.position, 5f, LayerMask.GetMask("Objects"));

        foreach (Collider2D limb in aliveObjectsInRadius)
        {
            if (limb.gameObject.GetComponent <LimbBehaviour>())
            {
                isExplosivelyCharged = true;
                GetComponent <DroneModBehaviour>().overwriteHover = true;
                Vector2 targetObjLoc = limb.transform.position - transform.position;
                targetObjLoc.Normalize();
                GetComponent <PhysicalBehaviour>().rigidbody.AddForce(targetObjLoc * movSpeed);

                if (Vector2.Distance(transform.position, limb.transform.position) < 1)
                {
                    ExplosionCreator.CreateFragmentationExplosion(10, transform.position, 5, 5, true, true, 1f);
                    GetComponent <DroneModBehaviour>().selfDestruct = true;
                }
            }
            else
            {
                isExplosivelyCharged = false;
                GetComponent <DroneModBehaviour>().overwriteHover = false;
            }
        }
    }
        protected override void ProcessOneEntity(int entityId, float deltaTime)
        {
            // gather data for selection
            var collisionDetectedTag = GameState.GameData.Tags[entityId].IsBitSet((int)Tag.CollisionDetected);

            // selection
            if (!collisionDetectedTag)
            {
                return;
            }

            // gather data for processing
            var transform = GameState.GameData.Transforms[entityId];
            var enemy     = GameState.GameData.Enemies[entityId];

            // process data
            var t = transform.Value;

            ExplosionCreator.Create("Explosion10", t.Position, _explosionSizeScaleFactor, t.Size * t.Scale, GameState);

            var p = GameState.FindPlayer();

            p.player.Score += enemy.Value.Score;
            GameState.GameData.Players[p.index] = p.player;

            // update data
            GameState.GameData.Tags[entityId] = GameState.GameData.Tags[entityId].UnsetBits((int)Tag.IsAlive, (int)Tag.CollisionDetected);
        }
示例#3
0
    private void Update()
    {
        if (!glitched)
        {
            Vector3 vector3 = this.transform.right + 0.25f * new Vector3((float)((double)Mathf.PerlinNoise(0.0f, 2f * Time.time + this.Seed) * 2.0 - 1.0), (float)((double)Mathf.PerlinNoise(2f * Time.time - this.Seed, 5f) * 2.0 - 1.0), 0.0f);
            vector3.Normalize();
            float        distance     = Mathf.Min(this.MaxSpeed, this.UnitsPerSecond + this.AccelerationPerSecond * this.f) * Time.deltaTime;
            RaycastHit2D raycastHit2D = Physics2D.Raycast((Vector2)this.transform.position, (Vector2)vector3, distance, (int)this.mask);
            if ((bool)raycastHit2D)
            {
                Vector2 vector2 = raycastHit2D.point + raycastHit2D.normal * 0.05f;


                //prevents rpg from firing bfg balls
                UnityEngine.GameObject.Destroy(this.gameObject);


                //haha BOOM
                ExplosionCreator.CreatePulseExplosion((Vector3)vector2, 240f, 900f, true, true);

                raycastHit2D.transform.SendMessage("Shot", (object)new Shot(raycastHit2D.normal, raycastHit2D.point, 35f), SendMessageOptions.DontRequireReceiver);
                raycastHit2D.transform.SendMessage("ExitShot", (object)new Shot(raycastHit2D.normal, raycastHit2D.point, 35f), SendMessageOptions.DontRequireReceiver);
                raycastHit2D.transform.SendMessage("Break", (object)(distance * (Vector2)vector3), SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                this.transform.position += vector3 * distance;
            }
            this.f += Time.deltaTime;
        }
        else
        {
            //don't ask, I don't know either, it just works and I'm too tired to question it
            this.transform.position = new Vector2(10000, 10000);
        }
    }
示例#4
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     ExplosionCreator.CreateFragmentationExplosion(10, transform.position, 5, 5, true, true, 1f);
     Destroy(gameObject);
 }