Exemple #1
0
 protected void Update()
 {
     NowVector          = NextVector;
     transform.position = NowVector;
     RailR += RSpeed;
     Angle += W;
     if (IsRotatToFace)
     {
         transform.Rotate(-transform.rotation.eulerAngles);
         transform.Rotate(new Vector3(0, 0, Mathf.Rad2Deg * FaceAngle - 90));
     }
     if (transform.position.x > 10 || transform.position.x < -10 || transform.position.y > 10 || transform.position.y < -10)
     {
         Destroy(gameObject);
     }
     if (player != null)
     {
         if (Box.Miss(this, player))
         {
             Miss?.Invoke(this, new MissEventArgs());
             Destroy(gameObject);
         }
     }
     if (onDestroy)
     {
         Destroy(gameObject);
     }
 }
Exemple #2
0
        protected override bool OnReceivePulseSpaceBlock(PulseSpaceDurationList buffer)
        {
            if (buffer.Count < (LeadInPatternDurations.Count + 5))
            {
                return(true);
            }

            for (int i = 0; i < LeadInPatternDurations.Count; i++)
            {
                const int errorMagin = 100;
                if (buffer[i] < (LeadInPatternDurations[i] - errorMagin) || buffer[i] > (LeadInPatternDurations[i] + errorMagin))
                {
                    Miss?.Invoke(this, EventArgs.Empty);
                    return(true); // Wrong pattern, discard this IR message.
                }
            }

            _lastReceived = buffer.Copy();
            return(false);
        }
Exemple #3
0
 // Update is called once per frame
 void Update()
 {
     transform.position = NextVector;
     if (IsRotatToFace)
     {
         transform.Rotate(-transform.rotation.eulerAngles);
         transform.Rotate(new Vector3(0, 0, Mathf.Rad2Deg * FaceAngle - 90));
     }
     if (player != null)
     {
         if (Box.Miss(this, player))
         {
             Miss?.Invoke(this, new MissEventArgs());
             Destroy(gameObject);
         }
     }
     if (onClear)
     {
         Destroy(gameObject);
     }
 }
Exemple #4
0
        public void TakeShot(int targetPlayer, Cell targetCell)
        {
            if (targetPlayer < 0 || targetPlayer > 1)
            {
                throw new ArgumentOutOfRangeException("Only two players allowed!");
            }

            var shotResult = PlayerBoards[targetPlayer].RegisterShot(targetCell);

            if (shotResult.IsHit)
            {
                Hit?.Invoke(this, EventArgs.Empty);
                if (shotResult.IsSunk)
                {
                    ShipDestroyed?.Invoke(this, new ShipDestroyedEventArgs {
                        DestroyedShip = shotResult.Ship
                    });
                }
            }
            else
            {
                Miss?.Invoke(this, EventArgs.Empty);
            }
        }
Exemple #5
0
 public void InvokeEvent()
 {
     NoteTap.Invoke();
     Miss.Invoke();
 }
Exemple #6
0
 protected void OnMiss(Vector2 coordinates, Block block)
 {
     Miss?.Invoke(new CollisionEventArgs(coordinates, block));
 }