Ejemplo n.º 1
0
        private void StarAttack()
        {
            var projectileSprite    = ((SpriteRenderer)phaseOneProjectile.GetComponent <SpriteRenderer>()).Sprite;
            var projectileDirection = player.Position + playerCenter - transform.Position;

            for (int i = 0; i < bossOutline.Length; i++)
            {
                var j = (i == bossOutline.Length - 1) ? 0 : i + 1;

                var direction = bossOutline[j] - bossOutline[i];
                if (direction.X != 0 || direction.Y != 0)
                {
                    direction.Normalize();
                }

                var offset       = Vector2.Distance(bossOutline[j], bossOutline[i]) / 8;
                var currentPoint = bossOutline[i];

                while (Vector2.Distance(currentPoint, bossOutline[j]) >= offset)
                {
                    var projectileInstance = GameManager.Instantiate(phaseOneProjectile, currentPoint + transform.Position - projectileSprite.GetCenter());
                    var instanceVelocity   = (Velocity)projectileInstance.GetComponent <Velocity>();
                    instanceVelocity.Direction = projectileDirection;
                    currentPoint += offset * direction;
                }
            }
        }
Ejemplo n.º 2
0
        public override void Initialize(GameObject owner)
        {
            base.Initialize(owner);

            transform          = (Transform)GetComponent <Transform>();
            transform.Position = new Vector2(360, 300);

            renderer = (SpriteRenderer)GetComponent <SpriteRenderer>();

            velocity = (Velocity)GetComponent <Velocity>();

            var playerObj = GameManager.GetObjectByTag("Player");

            player             = (Transform)playerObj.GetComponent <Transform>();
            playerCenter       = ((SpriteRenderer)playerObj.GetComponent <SpriteRenderer>()).Sprite.GetCenter();
            phaseOneProjectile = GameManager.GetPrefab("GreenProjectile");
            phaseTwoProjectile = GameManager.GetPrefab("PinkSquareProjectile");

            phaseOneProjectile.Tag = "Enemy" + phaseOneProjectile.Tag;

            centerPosition = new Vector2(360, 360) - renderer.Sprite.GetCenter();

            bulletFanProjectile         = GameManager.GetPrefab("WhiteDiamondProjectile");
            bulletFanProjectileRenderer = (SpriteRenderer)bulletFanProjectile.GetComponent <SpriteRenderer>();

            phaseOneCoordinates = new Vector2[]
            {
                new Vector2(360, 84) - renderer.Sprite.GetCenter(),
                new Vector2(248, 432) - renderer.Sprite.GetCenter(),
                new Vector2(541, 215) - renderer.Sprite.GetCenter(),
                new Vector2(178, 215) - renderer.Sprite.GetCenter(),
                new Vector2(471, 432) - renderer.Sprite.GetCenter()
            };

            bossOutline = new Vector2[]
            {
                new Vector2(128, 10) * renderer.Sprite.Scale,
                new Vector2(96, 102) * renderer.Sprite.Scale,
                new Vector2(1, 101) * renderer.Sprite.Scale,
                new Vector2(77, 159) * renderer.Sprite.Scale,
                new Vector2(46, 246) * renderer.Sprite.Scale,
                new Vector2(128, 188) * renderer.Sprite.Scale,
                new Vector2(210, 246) * renderer.Sprite.Scale,
                new Vector2(180, 159) * renderer.Sprite.Scale,
                new Vector2(255, 101) * renderer.Sprite.Scale,
                new Vector2(160, 102) * renderer.Sprite.Scale
            };

            starPoints = new Vector2[]
            {
                new Vector2(128, 10) * renderer.Sprite.Scale,
                new Vector2(1, 101) * renderer.Sprite.Scale,
                new Vector2(46, 246) * renderer.Sprite.Scale,
                new Vector2(210, 246) * renderer.Sprite.Scale,
                new Vector2(255, 101) * renderer.Sprite.Scale,
            };

            health       = totalHealth = 2;
            midbossState = MidbossState.TransitionPhase1;
        }
Ejemplo n.º 3
0
        public void TriangleAttack()
        {
            var projectileSprite    = ((SpriteRenderer)phaseOneProjectile.GetComponent <SpriteRenderer>()).Sprite;
            var projectileDirection = -VectorMath.Angle2Vector(transform.Rotation);

            for (int i = 0; i < bossOutline.Length - 1; i++)
            {
                var j = (i == bossOutline.Length - 1) ? 0 : i + 1;

                var direction = bossOutline[j] - bossOutline[i];
                if (direction.X != 0 || direction.Y != 0)
                {
                    direction.Normalize();
                }

                var offset       = Vector2.Distance(bossOutline[j], bossOutline[i]) / 16;
                var currentPoint = bossOutline[i];

                var projectileInstance = GameManager.Instantiate(phaseOneProjectile, currentPoint + transform.Position - projectileSprite.GetCenter());
                projectileInstance.Tag = "Enemy" + projectileInstance.Tag;
                var instanceVelocity = (Velocity)projectileInstance.GetComponent <Velocity>();
                instanceVelocity.Direction = projectileDirection;

                while (Vector2.Distance(currentPoint, bossOutline[j]) >= offset)
                {
                    currentPoint              += offset * direction;
                    projectileInstance         = GameManager.Instantiate(phaseOneProjectile, currentPoint + transform.Position - projectileSprite.GetCenter());
                    projectileInstance.Tag     = "Enemy" + projectileInstance.Tag;
                    instanceVelocity           = (Velocity)projectileInstance.GetComponent <Velocity>();
                    instanceVelocity.Direction = projectileDirection;
                }
            }
        }
Ejemplo n.º 4
0
        private void ManagePhase2(GameTime gameTime)
        {
            if (gameTime.TotalGameTime.TotalMilliseconds >= phase2LastAttack + phase2AttackCooldown)
            {
                var projectileRenderer = (SpriteRenderer)phaseTwoProjectile.GetComponent <SpriteRenderer>();
                foreach (var point in starPoints)
                {
                    var rotatedPoint = VectorMath.RotatePoint(point, renderer.Sprite.GetCenter(), transform.Rotation);
                    var direction    = rotatedPoint - renderer.Sprite.GetCenter();

                    var instance = GameManager.Instantiate(phaseTwoProjectile, rotatedPoint + transform.Position - projectileRenderer.Sprite.GetCenter());
                    instance.Tag = "Enemy" + instance.Tag;
                    var instanceVelocity = (Velocity)instance.GetComponent <Velocity>();
                    instanceVelocity.Direction = direction;
                }
                phase2LastAttack = gameTime.TotalGameTime.TotalMilliseconds;
            }

            if (gameTime.TotalGameTime.TotalMilliseconds >= bulletFanCooldown + bulletFanLastAttackTime)
            {
                BulletFan(new Vector2(0, 0));
                BulletFan(new Vector2(730, 0));
                bulletFanLastAttackTime = gameTime.TotalGameTime.TotalMilliseconds;
            }

            transform.Rotation += (float)phase2RotationSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        }
        public override void Initialize(GameObject owner)
        {
            base.Initialize(owner);
            projectile = GameManager.GetPrefab("PurpleDiamondProjectile");

            transform          = (Transform)GetComponent <Transform>();
            renderer           = (SpriteRenderer)GetComponent <Renderer>();
            projectileRenderer = (SpriteRenderer)projectile.GetComponent <SpriteRenderer>();

            health = 4;
        }
Ejemplo n.º 6
0
        public void SetObject(Prefabrication prefab)
        {
            var transform = (Transform)GetComponent <Transform>();
            var renderer  = (SpriteRenderer)GetComponent <SpriteRenderer>();

            var center = transform.Position + renderer.Sprite.GetCenter();

            var prefabRenderer = (SpriteRenderer)prefab.GetComponent <SpriteRenderer>();

            galleryButtonIcon = new Prefabrication();
            galleryButtonIcon.AddComponent(prefabRenderer);
            if (prefab.HasComponent <Animator>())
            {
                galleryButtonIcon.AddComponent(prefab.GetComponent <Animator>());
            }


            var xOffset = (renderer.Sprite.SpriteRectangle.Width - size) / 2;
            var yOffset = (renderer.Sprite.SpriteRectangle.Height - size) / 2;

            var offset = new Vector2(xOffset, yOffset);

            var buttonIcon = GameManager.Instantiate(galleryButtonIcon, State.Gallery);

            buttonIcon.Tag = "GallerySprite";
            var buttonIconRenderer = (SpriteRenderer)buttonIcon.GetComponent <SpriteRenderer>();

            buttonIconRenderer.Sprite.LayerDepth = 0.2f;
            var scale = (buttonIconRenderer.Sprite.SpriteRectangle.Width > buttonIconRenderer.Sprite.SpriteRectangle.Height) ?
                        size / buttonIconRenderer.Sprite.SpriteRectangle.Width :
                        size / buttonIconRenderer.Sprite.SpriteRectangle.Height;

            if (scale < buttonIconRenderer.Sprite.Scale)
            {
                buttonIconRenderer.Sprite.Scale = scale;
            }

            var buttonIconTransform = (Transform)buttonIcon.GetComponent <Transform>();

            buttonIconTransform.Position = center - buttonIconRenderer.Sprite.GetCenter();
        }
        public override void Initialize(GameObject owner)
        {
            base.Initialize(owner);
            projectile = GameManager.GetPrefab("GreySquareProjectile");

            transform          = (Transform)GetComponent <Transform>();
            renderer           = (SpriteRenderer)GetComponent <SpriteRenderer>();
            projectileRenderer = (SpriteRenderer)projectile.GetComponent <SpriteRenderer>();

            range = new Vector2(135, 225);

            health = 2;
        }
Ejemplo n.º 8
0
        private void ManagePhase2(GameTime gameTime)
        {
            if (gameTime.TotalGameTime.TotalMilliseconds >= phase2LastAttack + phase2AttackCooldown)
            {
                var projectileRenderer = (SpriteRenderer)projectile.GetComponent <SpriteRenderer>();
                foreach (var point in starPoints)
                {
                    var rotatedPoint = VectorMath.RotatePoint(point, renderer.Sprite.GetCenter(), transform.Rotation);
                    var direction    = rotatedPoint - renderer.Sprite.GetCenter();
                    if (direction.X != 0 || direction.Y != 0)
                    {
                        direction.Normalize();
                    }
                    var instance = GameManager.Instantiate(projectile, rotatedPoint + transform.Position - projectileRenderer.Sprite.GetCenter());

                    var instanceVelocity = (Velocity)instance.GetComponent <Velocity>();
                    instanceVelocity.Direction = direction;
                }
                phase2LastAttack = gameTime.TotalGameTime.TotalMilliseconds;
            }

            transform.Rotation += (float)phase2RotationSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        }
        private static void ChangePosition(Prefabrication prefab, dynamic args)
        {
            var transform = (Transform)prefab.GetComponent <Transform>();

            transform.Position = new Vector2((float)args.X, (float)args.Y);
        }
Ejemplo n.º 10
0
        private static void SetScale(Prefabrication prefab, dynamic args)
        {
            var transform = (Transform)prefab.GetComponent <Transform>();

            transform.Scale = (float)args.Value;
        }