Esempio n. 1
0
        void Update()
        {
            if (projectile)
            {
                Vector2 position            = projectile.specRigidbody.UnitCenter;
                Vector2 direction           = projectile.LastVelocity.normalized;
                int     thePointOfTheMaskIs = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.EnemyHitBox, CollisionLayer.BulletBreakable);
                PhysicsEngine.Instance.Raycast(position, direction, 100f, out RaycastResult result, true, true, thePointOfTheMaskIs);
                if (result != null && result.Contact != null)
                {
                    tk2dTiledSprite component = SpawnManager.SpawnVFX(linkVFXPrefab, false).GetComponent <tk2dTiledSprite>();
                    PostBeamRender(component);

                    Vector2 unitCenter  = position;
                    Vector2 unitCenter2 = result.Contact;
                    component.transform.position = unitCenter;
                    Vector2 vector = unitCenter2 - unitCenter;
                    float   num    = BraveMathCollege.Atan2Degrees(vector.normalized);
                    int     num2   = Mathf.RoundToInt(vector.magnitude / 0.0625f);
                    component.dimensions         = new Vector2((float)num2, component.dimensions.y);
                    component.transform.rotation = Quaternion.Euler(0f, 0f, num);
                    component.UpdateZDepth();

                    ETGMod.StartGlobalCoroutine(doTimerMagic(component.gameObject, wait));
                    OnBeamHit(result.Contact, projectile);
                }
                projectile.DieInAir();
            }
        }
Esempio n. 2
0
            private void UpdateLink(PlayerController target, tk2dTiledSprite m_extantLink)
            {
                Vector2 unitCenter  = base.specRigidbody.UnitCenter;
                Vector2 unitCenter2 = target.specRigidbody.HitboxPixelCollider.UnitCenter;

                m_extantLink.transform.position = unitCenter;
                Vector2 vector = unitCenter2 - unitCenter;
                float   num    = BraveMathCollege.Atan2Degrees(vector.normalized);
                int     num2   = Mathf.RoundToInt(vector.magnitude / 0.0625f);

                m_extantLink.dimensions         = new Vector2((float)num2, m_extantLink.dimensions.y);
                m_extantLink.transform.rotation = Quaternion.Euler(0f, 0f, num);
                m_extantLink.UpdateZDepth();
                this.ApplyLinearDamage(unitCenter, unitCenter2);
            }
        public void BuildPatch()
        {
            if (m_stripPrefab == null)
            {
                m_stripPrefab = (GameObject)BraveResources.Load("Global Prefabs/TallGrassStrip", ".prefab");
            }
            HashSet <IntVector2> hashSet = new HashSet <IntVector2>();

            for (int j = 0; j < cells.Count; j++)
            {
                IntVector2 intVector = cells[j];
                if (!hashSet.Contains(intVector))
                {
                    hashSet.Add(intVector);
                    int        num = 1;
                    var        targetIndexForPosition = GetTargetIndexForPosition(intVector);
                    IntVector2 intVector2             = intVector;
                    while (true)
                    {
                        intVector2 += IntVector2.Right;
                        if (hashSet.Contains(intVector2))
                        {
                            break;
                        }
                        if (!cells.Contains(intVector2))
                        {
                            break;
                        }
                        if (targetIndexForPosition != GetTargetIndexForPosition(intVector2))
                        {
                            break;
                        }
                        num++;
                        hashSet.Add(intVector2);
                    }
                    GameObject      grassObject = SpawnManager.SpawnVFX(m_stripPrefab, false);
                    tk2dTiledSprite tiledSprite = grassObject.GetComponent <tk2dTiledSprite>();
                    tiledSprite.SetSprite(GameManager.Instance.Dungeon.tileIndices.dungeonCollection, (int)targetIndexForPosition);
                    tiledSprite.dimensions         = new Vector2((16 * num), 16f);
                    grassObject.transform.position = new Vector3(intVector.x, intVector.y, intVector.y);
                    m_tiledSpritePool.Add(intVector, tiledSprite);
                    switch (targetIndexForPosition)
                    {
                    case IndexPosition.BOTTOM:
                        tiledSprite.HeightOffGround     = -2f;
                        tiledSprite.IsPerpendicular     = true;
                        tiledSprite.transform.position += new Vector3(0f, 0.6875f, 0f);
                        break;

                    case IndexPosition.TOP:
                        tiledSprite.IsPerpendicular = true;
                        break;

                    default:
                        tiledSprite.IsPerpendicular = false;
                        break;
                    }
                    tiledSprite.UpdateZDepth();
                }
            }
            if (!ExpandStaticReferenceManager.AllGrasses.Contains(this))
            {
                ExpandStaticReferenceManager.AllGrasses.Add(this);
            }
            InitializeParticleSystem();
        }