コード例 #1
0
ファイル: ParticleState.cs プロジェクト: Crysco/Invasion
        public static ParticleState GetRandom(float minVel, float maxVel)
        {
            var state = new ParticleState();
            state.Velocity = rand.NextVector2(minVel, maxVel);
            state.Type = ParticleType.None;
            state.LengthMultiplier = 1;

            return state;
        }
コード例 #2
0
ファイル: Ship.cs プロジェクト: Crysco/Invasion
        //public Team getTeam()
        //{
        //    return Team;
        //}
        public override void Update()
        {
            if (!Colliding)
                getDirection();// getDirection(Position, Destination.Position);

            if (Velocity.LengthSquared() > 0)
            {
                if (LocalOrientation > 0)
                    LocalOrientation -= AngSpeed;
                else if (LocalOrientation < 0)
                    LocalOrientation += AngSpeed;

                if (Math.Abs(LocalOrientation - Direction.ToAngle()) < 0.1f)
                    LocalOrientation = Direction.ToAngle();
            }

            Position += Velocity;

            lastPosition = Position;
            Colliding = false;

            if (Position.WithinRadius(Destination.Position, Destination.Radius))
            {
                if (Destination.team == null || Destination.team.ID != Team.ID)
                {
                    if (Destination.shipCount > 0)
                    {
                        Destination.enemyShipCount += Value;
                        Destination.shipCount -= Value;
                        Destination.invadingTeam = Team;
                    }
                    //create sound
                    Cue cue = GameRoot.soundBank.GetCue("Woodblock-04");
                    cue.Play();
                    //particle creation below
                    for (int i = 0; i < 6; i++)
                    {
                        float speed = 1.8f * (1f - 1 / rand.NextFloat(1, 10));
                        var state = new ParticleState()
                        {
                            Velocity = rand.NextVector2(speed, speed),
                            Type = ParticleType.Ship,
                            LengthMultiplier = 1
                        };

                        //Color colorr = Color.Lerp(color1, color2, rand.NextFloat(0, 1));
                        GameRoot.ParticleManager.CreateParticle(Art.SquareParticle, Position, color, 190f, .5f, state);
                    }
                }
                else if (Destination.team.ID == Team.ID)
                {
                    Destination.shipCount += Value;
                    if(Destination.enemyShipCount > 0)
                        Destination.enemyShipCount -= Value;
                }

                IsExpired = true;
            }

            //delete ships that go off screen
            if (!GameRoot.Viewport.Bounds.Contains(Position.ToPoint()))
                IsExpired = true;
        }
コード例 #3
0
ファイル: Planet.cs プロジェクト: Crysco/Invasion
        public void changeTeams()
        {
            if (team != null)
                TeamManager.removePlanet(team, this);
            if (invadingTeam != null)
            {
                this.team = invadingTeam;
                TeamManager.addPlanet(team, this);
            }
            color = team.getColor();
            Cue cue = GameRoot.soundBank.GetCue("Metal");
            cue.Play();

            float hue1 = rand.NextFloat(0, 6);
            float hue2 = (hue1 + rand.NextFloat(0, 2)) % 6f;
            Color color1 = ColorUtil.HSVToColor(hue1, 0.5f, 1);
            Color color2 = ColorUtil.HSVToColor(hue2, 0.5f, 1);

            for (int i = 0; i < (int)(60*(Math.Pow(ObjectSize,2))); i++)
            {
                float speed = (18f * (1f - 1 / rand.NextFloat(1, 10)))*(float)(Math.Pow(ObjectSize,2));
                var state = new ParticleState()
                {
                    Velocity = rand.NextVector2(speed, speed),
                    Type = ParticleType.Planet,
                    LengthMultiplier = 1
                };

                Color colorr = Color.Lerp(color1, color2, rand.NextFloat(0, 1));
                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190f, 1.5f, state);
            }
        }