예제 #1
0
 public AddObject(ArenaObject obj)
 {
     layer       = obj.Layer;
     objCode     = obj.Code;
     graphicCode = obj.GraphicCode;
     coord       = obj.Position;
 }
예제 #2
0
 public ReboundTemplate(float paddleSpeed, BallType bType, ArenaObject arObject, ArenaObjectType arObjectType)
 {
     PaddleSpeed  = paddleSpeed;
     BType        = bType;
     ArObject     = arObject;
     ArObjectType = arObjectType;
 }
예제 #3
0
        public Vector2 ReboundPosition(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj)
        {
            var ballPos       = b.Position;
            var ballDirection = b.Direction;

            return(ballPos);
        }
예제 #4
0
    IEnumerator Respawn()
    {
        if (!m_MainCamera)
        {
            yield break;
        }

        m_MainCamera.FadeIn();
        //m_GUIManager.HideHUD();

        yield return(new WaitForSeconds(m_MainCamera.fadeDuration));

        if (m_CurrentArena != null)
        {
            m_CurrentArena.Cancel();
            m_CurrentArena = null;
        }

        m_PlayerManager.RespawnPlayer(m_CurrentCheckpoint);

        yield return(new WaitForSeconds(1f));

        m_EnemyManager.RemoveAllEnemies();

        yield return(new WaitForSeconds(1f));

        m_MainCamera.SetPos(m_CurrentCheckpoint.playerOne.position.x);

        yield return(new WaitForSeconds(m_MainCamera.fadeBlackScreenTime));

        m_MainCamera.FadeOut();
        //m_GUIManager.ShowHUD();
    }
예제 #5
0
파일: Ball.cs 프로젝트: zamixn/PongRoyale
        public virtual void CheckCollisionWithArenaObjects(Dictionary <byte, ArenaObject> objects)
        {
            if (objects.Count > 0)
            {
                ArenaObjectArray arenaObjectArray = new ArenaObjectArray();
                arenaObjectArray.AddAObjects(objects.Values.ToArray());
                ArenaObjectIterator aObjectIterator = new ArenaObjectIterator(arenaObjectArray);
                //foreach (var obj in objects.Values)
                //{
                //    if (obj.Intersects(GetBounds()))
                //        OnCollision(null, obj);

                //    if (ArenaFacade.Instance.IsPaused)
                //        break;
                //}
                for (ArenaObject i = (ArenaObject)aObjectIterator.First(); aObjectIterator.HasNext(); i = (ArenaObject)aObjectIterator.Next())
                {
                    var obj = i;
                    if (obj.Intersects(GetBounds()))
                    {
                        OnCollision(null, obj);
                    }

                    if (ArenaFacade.Instance.IsPaused)
                    {
                        break;
                    }
                }
            }
        }
예제 #6
0
파일: Bullet.cs 프로젝트: mcbodge/robowarx
        public override bool onHit(ArenaObject other)
        {
            if (other != null)
            {
                if (!(other is Robot))
                {
                    return(false);
                }

                if (type == BulletType.Explosive)
                {
                    owner.parent.spawn(typeof(BigExplosion), x, y, owner, energy);
                }
                else
                {
                    int damage = energy;
                    if (type == BulletType.Rubber)
                    {
                        damage /= 2;
                    }

                    owner.parent.spawn(typeof(Explosion), x, y, owner, other, damage);
                }
            }
            destroy();

            return(true);
        }
예제 #7
0
        public Vector2 ReboundDirection(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj)
        {
            var     ballDirection = b.Direction;
            Vector2 bounceDir     = SharedUtilities.GetBounceDirection(collisionNormal, ballDirection);

            ArenaFacade.Instance.TransferPowerUpToPaddle(p.Id, b.Id, b.PoweredUpData);
            return((bounceDir + Vector2.RandomInUnitCircle().Normalize() * 0.2f).Normalize());
        }
예제 #8
0
        public Vector2 ReboundPosition(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj)
        {
            var ballPos       = b.Position;
            var ballDirection = b.Direction;
            var offset        = ballDirection * 10;

            return(obj.GetBounds().GetClosestPointOnBorder(ballPos) + offset);
        }
예제 #9
0
        public void AddHeigthTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddHeigth(10);
            ArenaObject obj = builder.CreateObject();

            Assert.AreEqual(10, obj.Heigth);
        }
예제 #10
0
        public void AddPosYTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddPosY(10);
            ArenaObject obj = builder.CreateObject();

            Assert.AreEqual(10, obj.PosY);
        }
예제 #11
0
        public Vector2 ReboundDirection(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj)
        {
            var ballDirection = b.Direction;

            var powerup = (obj as PowerUp);

            ArenaFacade.Instance.BallHasCollectedPowerUp(powerup, b);
            return(ballDirection);
        }
예제 #12
0
        public void AddPosYTest()
        {
            PowerUpBuilder builder = new PowerUpBuilder();

            builder.AddPosY(10);
            ArenaObject a = builder.CreateObject();

            Assert.IsTrue(a.PosY == 10);
        }
예제 #13
0
        public void CreateObjectTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddDuration(10).AddHeigth(10).AddPosX(10).AddPosY(10).AddWidth(10);
            ArenaObject obj = builder.CreateObject();

            Assert.IsTrue(obj.Duration == 10 && obj.Heigth == 10 && obj.PosX == 10 && obj.PosY == 10 && obj.Width == 10);
        }
예제 #14
0
        public void AddDurationTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddDuration(10);
            ArenaObject obj = builder.CreateObject();

            Assert.AreEqual(10, obj.Duration);
        }
예제 #15
0
        public Vector2 ReboundDirection(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj)
        {
            var ballDirection = b.Direction;

            if (p != null)
            {
                ArenaFacade.Instance.KillPaddle(p);
            }
            return(ballDirection);
        }
예제 #16
0
        public void AddPosTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();
            Vector2         pos     = new Vector2(10, 10);

            builder.AddPos(pos);
            ArenaObject obj = builder.CreateObject();

            Assert.IsTrue(obj.PosX == 10 && obj.PosY == 10);
        }
예제 #17
0
파일: Lynx.cs 프로젝트: jdong135/CompusciHW
 public override bool IsPassable(ArenaObject mover)
 {
     if (mover == null)
     {
         return(false);
     }
     else
     {
         return(!(mover is Lynx));
     }
 }
예제 #18
0
        public Vector2 ReboundDirection(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj)
        {
            var ballDirection = b.Direction;

            if (collisionNormal.Equals(-ballDirection))
            {
                return(collisionNormal);
            }
            var dir = (collisionNormal + ballDirection).Normalize();

            return(dir);
        }
예제 #19
0
        public Vector2 ReboundDirection(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj)
        {
            var ballDirection = b.Direction;

            if (collisionNormal.Equals(-ballDirection))
            {
                return(collisionNormal);
            }
            var dir = (collisionNormal + ballDirection).Normalize();

            var powerup = (obj as PowerUp);

            ArenaFacade.Instance.BallHasCollectedPowerUp(powerup, b);
            return(dir);
        }
예제 #20
0
        public override bool onHit(ArenaObject other)
        {
            if (other != null)
            {
                if (!(other is Robot))
                {
                    return(false);
                }

                owner.parent.spawn(typeof(StunnerExplosion), x, y, owner, other, energy);
            }
            destroy();

            return(true);
        }
예제 #21
0
        private bool CanSee(ArenaObject other, double vision)
        {
            // First check if it's too far, to avoid calculations if possible
            double distance2 = Vector2D.Distance2(other.Position, Position);

            if (vision * vision < distance2)
            {
                return(false);
            }

            foreach (var plant in Arena.GetNearbyObjects <Obstacle>(Position, Math.Sqrt(distance2)))
            {
                vision -= VisionReduction(other, plant);
                if (vision < 0)
                {
                    return(false);
                }
            }
            return(vision * vision > distance2);
        }
예제 #22
0
파일: Ball.cs 프로젝트: zamixn/PongRoyale
        public void OnCollision(Paddle paddle, ArenaObject arenaObject)
        {
            Vector2 center          = ArenaFacade.Instance.ArenaDimensions.Center;
            float   radius          = ArenaFacade.Instance.ArenaDimensions.Radius;
            Vector2 collisionNormal = null;


            IReboundStrategy reboundStrategy = null;

            if (paddle != null)// collision with a paddle
            {
                float   paddleAngle  = paddle.GetCenterAngle();
                Vector2 paddleCenter = Utilities.GetPointOnCircle(center, radius, paddleAngle);
                collisionNormal = (center - paddleCenter).Normalize();
                ReboundTemplate rbTemplate = new ReboundFromPaddle(paddle.CurrentAngularSpeed, bType, null, Obstacles.ArenaObjectType.NonPassable);
                reboundStrategy = rbTemplate.ChooseStrategy();
                //switch (bType)
                //{
                //    case BallType.Deadly:
                //        reboundStrategy = new BallDeadlyStrategy();
                //        break;
                //    case BallType.Normal:
                //        if (paddle.CurrentAngularSpeed < 0)
                //            reboundStrategy = new PaddleMovingLeft();
                //        else if (paddle.CurrentAngularSpeed > 0)
                //            reboundStrategy = new PaddleMovingRight();
                //        else //if (coll.AngularSpeed == 0)
                //            reboundStrategy = new PaddleNotMoving();
                //        break;
                //}
            }
            else if (arenaObject != null)// collision with an arena object
            {
                ReboundTemplate rbTemplate = new ReboundFromArenaObject(0, BallType.Normal, arenaObject, arenaObject.Type);
                reboundStrategy = rbTemplate.ChooseStrategy();
                var     offset    = (Direction * Diameter * 0.5f);
                Vector2 impactPos = Position + offset;
                collisionNormal = arenaObject.GetCollisionNormal(impactPos, Direction);
            }
            Rebound(reboundStrategy, collisionNormal, paddle, arenaObject);
        }
예제 #23
0
파일: Ball.cs 프로젝트: zamixn/PongRoyale
        private void Rebound(IReboundStrategy reboundStrategy, Vector2 surfaceNormal, Paddle p, ArenaObject obj)
        {
            var dir = reboundStrategy.ReboundDirection(this, surfaceNormal, p, obj);

            //var pos = reboundStrategy.ReboundPosition(Position, Direction, surfaceNormal, p, obj);
            Direction = dir;
            //SetPosition(pos);
        }
예제 #24
0
 public void RegisterCurrentArena(ArenaObject arena)
 {
     m_CurrentArena = arena;
 }
예제 #25
0
 public RemoveObject(ArenaObject obj)
 {
     layer   = obj.Layer;
     objCode = obj.Code;
 }
예제 #26
0
 public override bool IsPassable(ArenaObject mover) => true;
예제 #27
0
        private double VisionReduction(ArenaObject other, Obstacle plant)
        {
            double distanceInPlant = AmountTraversed(Position, other.Position, plant.Size);

            return(distanceInPlant * plant.VisionReductionPerMeter);
        }
예제 #28
0
 public void EndCurrentArena()
 {
     m_CurrentArena = null;
 }
 public BattleArena(int size)
 {
     ArenaSize = size;
     arenaTiles = new ArenaTile[size, size];
     arenaObjects = new ArenaObject[size, size];
 }
예제 #30
0
 public override bool IsPassable(ArenaObject mover = null) => false;
예제 #31
0
 public ReboundFromPaddle(float paddleSpeed, BallType bType, ArenaObject arObject, ArenaObjectType arObjectType) : base(paddleSpeed, bType, arObject, arObjectType)
 {
 }