Exemple #1
1
        public override void Update(int t)
        {
            _p = _p0 + t * _v0 + new XY(0, t * t * _a * 0.5f);

            if (t > 0 && !World.Box.ContainsPoint(_p))
            {
                Despawn();
                return;
            }

            if (t % 15 == 0)
            {
                The.World.Spawn(new PetalBullet(_p, (The.Player.Position - _p).WithLength(2), Color.Magenta));
                foreach (var v in Danmaku.Spray(new XY(0, 1.5f), Mathf.PI / 6, 2))
                {
                    The.World.Spawn(new PetalBullet(_p, v, Color.Yellow));
                }
            }
        }
        protected override void Update(int t)
        {
            P = _p0 + t * _v;
            if (t < _delay)
            {
                return;
            }

            _random = _.Random.Angle();

            _.World.Spawn(new Blast(P, 10, 120));

            foreach (var v in Danmaku.Ring(new XY(_random), _.Difficulty.Choose(5, 7, 5, 7)))
            {
                _.World.Spawn(
                    new DelayedLinearPetalBullet(
                        new XY(P.X, P.Y),
                        v * 0.75f,
                        Color.DarkRed,
                        Color.Red,
                        3f,
                        120,
                        21
                        )
                    );
            }
            foreach (var v in Danmaku.Ring(new XY(_random + Mathf.PI / _.Difficulty.Choose(0, 0, 5, 7)), _.Difficulty.Choose(0, 0, 5, 7)))
            {
                _.World.Spawn(
                    new DelayedLinearPetalBullet(
                        new XY(P.X + v.X * 5, P.Y + v.Y * 5),
                        v * 0.75f,
                        Color.Yellow,
                        Color.Red,
                        3f,
                        120
                        )
                    );
            }
            Despawn();
        }
        public override void Update(int t)
        {
            var world    = The.World;
            int interval = The.Difficulty <= Difficulty.Easy ? 12 : 2;
            int rays     = The.Difficulty.Choose(2, 2, 3, 5);

            if (t % interval == 0)
            {
                foreach (var v in Danmaku.Ring(new XY(0.004f * t), rays))
                {
                    world.Spawn(new PetalBullet(_p, v, Color.Lime));
                }
            }
            if (t % 4 == 0)
            {
                foreach (var v in Danmaku.Ring(new XY(-0.1f / rays * t), rays))
                {
                    world.Spawn(new PetalBullet(_p, v, Color.Cyan));
                }
            }
        }
Exemple #4
1
 protected override void Update(int t)
 {
     if (t % 120 == 0)
     {
         foreach (var v in Danmaku.Ring(new XY(_.Random.Angle()), 60))
         {
             _.World.Spawn(new LinearPetalBullet(P, v * 1f, Color.Magenta, Color.DarkMagenta, 3));
         }
     }
     if (t % 20 == 0 && _.Player != null && !_.Player.Despawned)
     {
         _.World.Spawn(
             new LinearRoundBullet(
                 P,
                 (_.Player.P - P).WithLength(2).Rotated(_.Random.SignedFloat() * 0.2f),
                 Color.Blue,
                 Color.Blue,
                 10
                 )
             );
     }
 }
        protected override void Update(int t)
        {
            var   o  = World.Box.Center;
            float av = Mathf.PI / _.Difficulty.Choose(900, 900, 900, 900);
            int   dt = _.Difficulty.Choose(90, 80, 70, 60);

            if (t == 0)
            {
                _.World.Spawn(new HugeStar(new XY(o.X, World.Box.Top + 20), XY.Zero, 0, av));
                _.World.Spawn(new HugeStar(new XY(o.X, World.Box.Bottom - 20), XY.Zero, 0, av));
            }
            if (t % dt == 0)
            {
                // ReSharper disable once PossibleLossOfFraction - так и было задумано!
                float angle = t / dt * Mathf.phiAngle / 30;
                foreach (var v in Danmaku.Ring(new XY(angle), 30))
                {
                    _.World.Spawn(new LinearRoundBullet(new XY(World.Box.Left, o.Y), v, Color.Red, Color.Red));
                    _.World.Spawn(new LinearRoundBullet(new XY(World.Box.Right, o.Y), v, Color.Red, Color.Red));
                }
            }
        }
        public override void Update(int t)
        {
            Color color;

            switch (t % 1800)
            {
            case 0:
                color = Color.Lime;
                break;

            case 300:
                color = Color.Yellow;
                break;

            case 600:
                color = Color.Red;
                break;

            case 900:
                color = Color.Magenta;
                break;

            case 1200:
                color = Color.Blue;
                break;

            case 1500:
                color = Color.Cyan;
                break;

            default: return;
            }
            XY v;

            switch (t % 1200)
            {
            case 0:
                v = XY.Down;
                break;

            case 300:
                v = XY.Left;
                break;

            case 600:
                v = XY.Up;
                break;

            case 900:
                v = XY.Right;
                break;

            default: return;
            }
            int bullets = The.Difficulty.Choose(5, 7, 9, 11);

            foreach (var w in Danmaku.Ring(1.5f * v, bullets))
            {
                The.World.Spawn(new RecursiveBullet(_p, w, color, 5));
            }
        }
        /// <summary>
        /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
        /// </summary>
        /// <param name="danmaku">the danmaku that hit the collider.</param>
        /// <param name="info">additional information about the collision</param>
        protected override void DanmakuCollision(Danmaku danmaku,
                                                 RaycastHit2D info) {
            if (affected.Contains(danmaku))
                return;
            if (rotationMode == RotationType.Reflection)
            {
                Vector2 normal = info.normal;
                Vector2 direction = danmaku.direction;
                danmaku.Direction = direction -
                                    2 * Vector2.Dot(normal, direction) * normal;
                affected.Add(danmaku);
                return;
            }

            float baseAngle = angle;
            switch (rotationMode) {
                case RotationType.Relative:
                    baseAngle += danmaku.Rotation;
                    break;
                case RotationType.Object:
                    if (Target != null) {
                        baseAngle += DanmakuUtil.AngleBetween2D(
                                                                danmaku.Position,
                                                                Target.position);
                    } else {
                        Debug.LogWarning(
                                         "Trying to direct at an object but no Target object assinged");
                    }
                    break;
                case RotationType.Absolute:
                    break;
            }
            danmaku.Rotation = baseAngle;
            affected.Add(danmaku);
        }
        /// <summary>
        /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
        /// </summary>
        /// <param name="danmaku">the danmaku that hit the collider.</param>
        /// <param name="info">additional information about the collision</param>
        protected override void DanmakuCollision(Danmaku danmaku,
                                                 RaycastHit2D info) {
            if (affected.Contains(danmaku))
                return;

            danmaku.ClearControllers();

            affected.Add(danmaku);
        }
        /// <summary>
        /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
        /// </summary>
        /// <param name="danmaku">the danmaku that hit the collider.</param>
        /// <param name="info">additional information about the collision</param>
        protected override void DanmakuCollision(Danmaku danmaku,
                                                 RaycastHit2D info) {
            if (affected.Contains(danmaku))
                return;

            danmaku.Controller += controllerAggregate;

            affected.Add(danmaku);
        }
        /// <summary>
        /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
        /// </summary>
        /// <param name="danmaku">the danmaku that hit the collider.</param>
        /// <param name="info">additional information about the collision</param>
        protected override void DanmakuCollision(Danmaku danmaku,
                                                 RaycastHit2D info) {
            if (affected.Contains(danmaku))
                return;

            if (prefab != null)
                prefab.Match(danmaku);

            affected.Add(danmaku);
        }
Exemple #11
0
 static void OnSceneGUI(SceneView sceneView)
 {
     if(!EditorApplication.isPlaying || !showSelectors)
         return;
     Vector3 forward = Vector3.forward;
     using (HandleUtil.With(Color.green)) {                
         foreach (Danmaku danmaku in Danmaku.All) {
             if(danmaku == null)
                 continue;
             selectedDanmaku = danmaku;
             Handles.matrix = Matrix4x4.TRS(danmaku.Position, Quaternion.Euler(0f, 0f, danmaku.Rotation), danmaku.Size * Vector3.one);
             float colliderSize = danmaku.Prefab.ColliderSize.Max();
             Handles.DrawWireDisc(danmaku.Prefab.ColliderOffset, forward, colliderSize);
             Handles.DrawLine(Vector3.zero, colliderSize * Vector3.right);
         }
     }
 }
 protected BulletBase(Danmaku danmaku,
                      Vector2f startPosition,
                      Vector2f size,
                      float hitboxRadius,
                      GameObject targetObject,
                      GameObject ownerObject,
                      EventHandler <EventArgs> onCollision,
                      int lifeTime,
                      Texture texture,
                      StatChanger statChanger)
     : this(danmaku, startPosition, size, hitboxRadius, new[] { targetObject }.ToList(), ownerObject, onCollision, lifeTime,
            new NoneRotator(),
            new NoneDeterminantOfDirectionOfMovement(),
            texture,
            new NoneWayOfDying(danmaku),
            statChanger)
 {
 }
        private void SpawnSmile(XY p, XY v, Color color)
        {
            var w     = v.Normalized;
            var line  = Danmaku.Line(w, 0, 40, 5);
            var spray = Danmaku.Spray(90 * w, Mathf.PI / 3, 9);

            var world = The.World;

            foreach (var offset in line)
            {
                world.Spawn(new VerticalBounceBullet(p + 20 * w.Rotated90CW() + offset, v, color));
                world.Spawn(new VerticalBounceBullet(p - 20 * w.Rotated90CW() + offset, v, color));
            }
            foreach (var offset in spray)
            {
                world.Spawn(new VerticalBounceBullet(p + offset, v, color));
            }
        }
        /// <summary>
        /// 请求弹幕服务器回调
        /// </summary>
        /// <param name="responses"></param>
        private void danmakuListener(List <string> responses)
        {
            foreach (string response in responses)
            {
                //log("Receive Response:" + response);
                if (!response.Contains("chatmsg"))
                {
                    continue;
                }

                //解析弹幕
                Danmaku danmaku = ResponseParser.parseDanmaku(response);
                if (danmaku == null)
                {
                    continue;
                }
                OnDanmakuEvent(danmaku);
            }
        }
Exemple #15
0
        /// <summary>
        /// 请求弹幕服务器回调
        /// </summary>
        /// <param name="responses"></param>
        private void danmakuListener(List <string> responses)
        {
            foreach (string response in responses)
            {
                //type@=uenter/rid@=783827/uid@=20887267/nn@=mt德芙要吃吗/level@=9/ic@=avatar@Sdefault@S12/rni@=0/el@=/sahf@=0/wgei@=0/
                log.InfoFormat("Receive Response:" + response);
                if (!response.Contains("chatmsg"))
                {
                    continue;
                }

                //解析弹幕
                Danmaku danmaku = ResponseParser.parseDanmaku(response);
                if (danmaku == null)
                {
                    continue;
                }
                OnDanmakuEvent(danmaku);
            }
        }
        /// <summary>
        /// 解析弹幕信息
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        public static Danmaku parseDanmaku(string response)
        {
            if (response == null)
            {
                return(null);
            }

            MatchCollection matcher = GetMatcher(response, REGEX_CHAT_DANMAKU);
            Danmaku         danmaku = null;

            if (matcher.Count > 0)
            {
                danmaku = new Danmaku(Convert.ToInt32(matcher[0].Groups[2].Value),
                                      matcher[0].Groups[3].Value,
                                      matcher[0].Groups[4].Value,
                                      Convert.ToInt32(matcher[0].Groups[1].Value));
            }

            return(danmaku);
        }
        /// <summary>
        /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
        /// </summary>
        /// <param name="danmaku">the danmaku that hit the collider.</param>
        /// <param name="info">additional information about the collision</param>
        protected override void DanmakuCollision(Danmaku danmaku,
                                                 RaycastHit2D info) {
            if (affected.Contains(danmaku))
                return;

            switch (type) {
                case ColorType.Constant:
                    if (colors.Length > 0)
                        danmaku.Color = colors[0];
                    break;
                case ColorType.Random:
                    if (colors.Length > 0)
                        danmaku.Color = colors.Random();
                    break;
                case ColorType.Gradient:
                    if (gradient != null)
                        danmaku.Color = gradient.Evaluate(Random.value);
                    break;
            }

            affected.Add(danmaku);
        }
Exemple #18
0
        private void InicialiseArena()
        {
            for (int i = 0; i < 5; i++)
            {
                var w    = XY.Down.WithLength(World.Box.Bottom / _delay);
                var line = Danmaku.Line(w, 0.083f, 1, 12);
                foreach (var v in line)
                {
                    _.World.Spawn(
                        new StoppingLinearRoundBullet(
                            new XY(0 + World.Box.Right / 5 * i, 0),
                            v,
                            Color.Blue,
                            Color.Blue,
                            _bulletsize,
                            _delay
                            ));
                }
            }

            for (int i = 0; i < 6; i++)
            {
                var w    = XY.Right.WithLength(World.Box.Right / _delay);
                var line = Danmaku.Line(w, 0.1f, 1, 10);
                foreach (var v in line)
                {
                    _.World.Spawn(
                        new StoppingLinearRoundBullet(
                            new XY(0, World.Box.Bottom / 12 + World.Box.Bottom / 6 * i),
                            v,
                            Color.Blue,
                            Color.Blue,
                            _bulletsize,
                            _delay
                            ));
                }
            }
        }
        static void OnSceneGUI(SceneView sceneView)
        {
            if (!EditorApplication.isPlaying || !showSelectors)
            {
                return;
            }
            Vector3 forward = Vector3.forward;

            using (HandleUtil.With(Color.green)) {
                foreach (Danmaku danmaku in Danmaku.All)
                {
                    if (danmaku == null)
                    {
                        continue;
                    }
                    selectedDanmaku = danmaku;
                    Handles.matrix  = Matrix4x4.TRS(danmaku.Position, Quaternion.Euler(0f, 0f, danmaku.Rotation), danmaku.Size * Vector3.one);
                    float colliderSize = danmaku.Prefab.ColliderSize.Max();
                    Handles.DrawWireDisc(danmaku.Prefab.ColliderOffset, forward, colliderSize);
                    Handles.DrawLine(Vector3.zero, colliderSize * Vector3.right);
                }
            }
        }
        /// <summary>
        /// Updates the Danmaku controlled by the controller instance.
        /// </summary>
        /// <param name="danmaku">the bullet to update.</param>
        /// <param name="dt">the change in time since the last update</param>
        public void Update(Danmaku danmaku, float dt)
        {
            float time = danmaku.Time;

            if (time >= Delay && time - dt <= Delay)
            {
                float baseAngle = Angle.Value;
                switch (RotationMode)
                {
                case RotationMode.Relative:
                    baseAngle += danmaku.Rotation;
                    break;

                case RotationMode.Object:
                    baseAngle += DanmakuUtil.AngleBetween2D(danmaku.Position, Target.position);
                    break;

                case RotationMode.Absolute:
                    break;
                }
                danmaku.Rotation = baseAngle;
            }
        }
Exemple #21
0
    void Start() {
		bullet_transform = gameObject.GetComponent<Transform>();
		bullet = GetComponent<Danmaku>();
    }
 protected GameObject(Danmaku danmaku, Vector2f startPosition, Vector2f size, float hitboxRadius, Texture texture)
     : this(danmaku, startPosition, size, hitboxRadius, int.MaxValue / danmaku.FrameRateLimit, texture)
 {
 }
Exemple #23
0
 public PowerSphereAttack(Danmaku danmaku, GameObject ownerObject, Vector2f startPoint,
                          int countOfBulletsForEasyMode, int timeBetweenAttacks)
     : base(danmaku, ownerObject, startPoint, countOfBulletsForEasyMode, timeBetweenAttacks,
            new PowerSphereAttackPool(ownerObject))
 {
 }
Exemple #24
0
 public MainAttackRight(Danmaku danmaku, GameObject ownerObject, Vector2f startPoint,
                        int countOfBulletsForEasyMode, int timeBetweenAttacks)
     : base(danmaku, ownerObject, startPoint, countOfBulletsForEasyMode, timeBetweenAttacks,
            new MainAttackRightPool(ownerObject))
 {
 }
Exemple #25
0
 public PowerBonus(Danmaku danmaku, Vector2f startPosition)
     : base(danmaku, startPosition, danmaku.Textures["PowerBonus"], new StatChanger(0, 0.1f, 0))
 {
 }
 /// <summary>
 /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
 /// </summary>
 /// <param name="danmaku">the danmaku that hit the collider.</param>
 /// <param name="info">additional information about the collision</param>
 protected override void DanmakuCollision(Danmaku danmaku,
                                          RaycastHit2D info) {
     danmaku.Speed += _acceleration * dt;
 }
Exemple #27
0
 public TurnIntoBonusWayOfDying(Danmaku danmaku) : base(danmaku)
 {
 }
Exemple #28
0
 protected WayOfDyingBase(Danmaku danmaku)
 {
     Danmaku = danmaku;
 }
Exemple #29
0
 public Flower2(Danmaku danmaku, GameObject ownerObject, Vector2f startPoint)
     : base(danmaku, ownerObject, startPoint, 40, 1000, 1000, 1000000)
 {
 }
Exemple #30
0
 void DAALL()
 {
     Danmaku.DestroyAll();
 }
Exemple #31
0
	/// <summary>
	/// Задает параметры движения пули в зависимости от типа движения
	/// </summary>
	/// <param name="_params">Массив значений.</param>
	/// <param name="_type">Тип движения пули.</param>
	void set_move_params(Danmaku _bullet, float [] _params, movement_type _type)
	{
		_bullet.type = _type;
		switch (_type) 
		{
		// Порядок значения в массиве и тип движения определяют за что отвечает каждая цифра в массиве параметров.
		// Неудобно, нет подсказки при вводе.
		case movement_type.simple:

			_bullet.Speed = _params [0];
			_bullet.Acceleration = _params [1]; 
			_bullet._rotation = _params [2];
			_bullet._angular_acceleration = _params [3];
			break; 
		case movement_type.second:
			_bullet.Speed = _params [0];
			_bullet.Acceleration = _params [1]; 
			_bullet._rotation = _params [2];
			_bullet._angular_acceleration = _params [3];
			_bullet._max_rotation = _params [4];
			break;
		default:
			//print ("Неправильно задан тип движения");
			break;
		}
	}
Exemple #32
0
 /// <summary>
 /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
 /// </summary>
 /// <param name="danmaku">the danmaku that hit the collider.</param>
 /// <param name="info">additional information about the collision</param>
 protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info)
 {
     danmaku.Speed += acceleration * TimeUtil.DeltaTime;
 }
 /// <summary>
 /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
 /// </summary>
 /// <param name="danmaku">the danmaku that hit the collider.</param>
 /// <param name="info">additional information about the collision</param>
 protected override void DanmakuCollision(Danmaku danmaku,
                                          RaycastHit2D info) {
     danmaku.Destroy();
 }
Exemple #34
0
 public Attack1(Danmaku danmaku, GameObject ownerObject, Vector2f startPoint, int lifeTime)
     : base(danmaku, ownerObject, startPoint, lifeTime, 50)
 {
 }
 public Shinigami(Danmaku danmaku)
     : base(danmaku, new Vector2f(0, 0), new Vector2f(0, 0), 0, null)
 {
 }
Exemple #36
0
 public DirectedAttack(Danmaku danmaku, GameObject ownerObject, Vector2f startPoint)
     : base(danmaku, ownerObject, startPoint, 500, 10)
 {
 }
 public void Update(Danmaku danmaku, float dt)
 {
     danmaku.AngularSpeed = 0f;
     danmaku.Rotation     = DanmakuUtil.AngleBetween2D(danmaku.position, Target.position);
 }
 public virtual void OnDanmakuEvent(Danmaku danmaku)
 {
     OnDanmaku?.Invoke(this, new DanmakuEventArgs(danmaku));
 }
Exemple #39
0
 // 客户端可以直接向服务端发送json对象,同时服务端也用类来接,不过类中属性或字段名 需与 接收到的 json对象中的一致
 public async Task SendDanmaku(Danmaku danmaku)
 {
     // 可以直接向客户端发送对象,将会被自动转换为json对象,不过首字母会自动转换为小写
     // { mode: 4, text: "测试发送", stime: 0, size: 40, color: 345678}
     await Clients.All.SendAsync("ReceiveDanmaku", danmaku);
 }
Exemple #40
0
	// Задает параметры движения для типа движения "по точкам".
	void set_move_params(Danmaku _bullet, float [] _params, List<Point> _array)
	{
		_bullet.Speed = _params [0];
		_bullet.Acceleration = _params [1];
		// Здесь нужно сделать deep copy листа в класс пули. Не смог, поставил массивы скалярых величин.
		_bullet.Coordx=new float[_array.Count]; _bullet.Coordz=new float[_array.Count];
		for (int i = 0; i < _array.Count; i++) 
		{
			_bullet.Coordx [i] = _array [i].get_x;
			_bullet.Coordz [i] = _array [i].get_z;
		}
		_bullet._rotation = 0;
		_bullet._angular_acceleration = 0;
	}
 /// <summary>
 /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
 /// </summary>
 /// <param name="danmaku">the danmaku that hit the collider.</param>
 /// <param name="info">additional information about the collision</param>
 protected override void DanmakuCollision(Danmaku danmaku,
                                          RaycastHit2D info)
 {
     danmaku.Destroy();
 }
 /// <summary>
 /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
 /// </summary>
 /// <param name="danmaku">the danmaku that hit the collider.</param>
 /// <param name="info">additional information about the collision</param>
 protected override void DanmakuCollision(Danmaku danmaku,
                                          RaycastHit2D info) {
     danmaku.Position += force * dt;
 }