コード例 #1
0
ファイル: SkillBait.cs プロジェクト: Aquars1989/RunningBox
        /// <summary>
        /// 技能生效
        /// </summary>
        public override void DoBeforeAction()
        {
            switch (Status)
            {
            case SkillStatus.Enabled:
            {
                if (Owner == null || Owner.MoveObject.Target.TargetType == TargetType.None)
                {
                    Break();
                    return;
                }

                // 新增誘餌物件
                double angle = Function.GetAngle(Owner.Layout.CenterX, Owner.Layout.CenterY, Owner.MoveObject.Target.X, Owner.MoveObject.Target.Y);

                MoveStraight move = new MoveStraight(null, Owner.MoveObject.Resistance, BaitSpeed, 1, 0, 1F);
                move.Target.SetOffsetByAngle(angle, 1000);

                DrawBase draw = Owner.DrawObject.Copy();
                draw.Colors.Opacity = 0.6F;

                ObjectActive bait = new ObjectActive(Owner.Layout, BaitLife, Owner.League, draw, move);
                move.Target.SetObject(bait);

                bait.Propertys.Add(new PropertySpeeded(-1, -(BaitSpeed / (float)BaitLife * 800)));
                bait.Propertys.Add(new PropertyCollision(0));         // 強度碰撞

                // 新增雜訊物件
                int        noiseWidth  = Owner.Layout.Width + 2;
                int        noiseHeight = (int)(Owner.Layout.Height * 1.3F + 0.5F) + 5;
                DrawNoise  drawNoise   = new DrawNoise(Owner.DrawObject.MainColor, Color.White, 1);
                ObjectWave noise       = new ObjectWave(0, 0, noiseWidth, noiseHeight, noiseWidth * 3, noiseHeight * 3, -1, 0, drawNoise, MoveNull.Value);
                noise.DiffusionOpacity = 0;
                noise.Layout.Depend.SetObject(bait);
                Owner.Container.Add(bait);
                Owner.Container.Add(noise);

                // 將目標設為誘餌
                for (int i = 0; i < Owner.Container.Count; i++)
                {
                    ObjectBase objectBase = Owner.Container[i];
                    if (objectBase.Status != ObjectStatus.Alive || Function.IsFriendly(objectBase.League, Owner.League))
                    {
                        continue;
                    }
                    if (objectBase.MoveObject.Target.Object == Owner)
                    {
                        objectBase.MoveObject.Target.SetObject(bait);
                    }
                }

                bait.Dead += (s, e, t) =>
                {
                    noise.DiffusionTime.Limit = Scene.Sec(0.2F);
                    noise.DiffusionTime.Value = 0;

                    if (Owner == null)
                    {
                        return;
                    }
                    for (int i = 0; i < Owner.Container.Count; i++)
                    {
                        ObjectBase objectBase = Owner.Container[i];
                        if (objectBase.Status != ObjectStatus.Alive)
                        {
                            continue;
                        }
                        if (objectBase.MoveObject.Target.Object == s)
                        {
                            objectBase.MoveObject.Target.SetObject(Owner);
                        }
                    }

                    SceneGaming scene = Scene as SceneGaming;
                    if (t == ObjectDeadType.LifeEnd && scene != null)
                    {
                        scene.AddScoreToPlayer("誘餌生還", 300);
                    }
                };
                Status = SkillStatus.Cooldown;
            }
            break;
            }

            base.DoBeforeAction();
        }
コード例 #2
0
        public override void DoBeforeActionMove()
        {
            switch (Status)
            {
            case SkillStatus.Enabled:
            {
                if (Owner == null)
                {
                    Break();
                    return;
                }
                Status   = SkillStatus.Channeled;
                _MiniBar = new PropertyUI(-1, new Size(30, 6), new DrawUICounterBar(Color.FromArgb(160, 210, 100), Color.Black, Color.White, 1, true, Channeled));
                Owner.Propertys.Add(_MiniBar);
                PushSycle.Value = Scene.SceneIntervalOfRound;
                break;
            }

            case SkillStatus.Channeled:
                if (PushSycle.IsFull)
                {
                    LayoutSet checkRange = new LayoutSet()
                    {
                        CollisonShape = ShapeType.Ellipse,
                        Anchor        = DirectionType.Center,
                        X             = Owner.Layout.X,
                        Y             = Owner.Layout.Y,
                        Width         = Range,
                        Height        = Range
                    };

                    int hitCount = 0;
                    for (int i = 0; i < Owner.Container.Count; i++)
                    {
                        ObjectBase objectActive = Owner.Container[i];
                        if (objectActive == Owner)
                        {
                            continue;
                        }

                        // 範圍判定
                        if (!Function.IsCollison(objectActive.Layout, checkRange))
                        {
                            continue;
                        }

                        double angle     = Function.GetAngle(checkRange.CenterX, checkRange.CenterY, objectActive.Layout.CenterX, objectActive.Layout.CenterY);
                        double pushPower = PushPower * Function.GetDistance(checkRange.CenterX, checkRange.CenterY, objectActive.Layout.CenterX, objectActive.Layout.CenterY) / Range;
                        objectActive.MoveObject.AddToNextOffset(objectActive.MoveObject.GetOffsetByAngle(angle, PushPower));
                        hitCount++;
                    }

                    if (hitCount > 0)
                    {
                        if (hitCount > 4)
                        {
                            hitCount = 4;
                        }
                        SceneGaming scene = Scene as SceneGaming;
                        if (scene != null)
                        {
                            scene.AddScoreToPlayer("震盪衝擊", hitCount * 15);
                        }
                    }

                    Color      waveColor = Color.FromArgb(150, Owner.DrawObject.MainColor);
                    ObjectWave wave      = new ObjectWave(0, 0, 0, 0, Range, Range, Scene.Sec(0.15F), Scene.Sec(0.1F), new DrawPen(waveColor, ShapeType.Ellipse, 1), MoveNull.Value);
                    wave.Layout.Depend.SetObject(Owner);
                    wave.DiffusionOpacity = 0.1F;
                    wave.FadeOpacity      = 0.5F;
                    Owner.Container.Add(wave);
                    PushSycle.Value = 0;
                }
                else
                {
                    PushSycle.Value += Scene.SceneIntervalOfRound;
                }
                break;
            }

            base.DoBeforeActionMove();
        }