public AddObject(ArenaObject obj) { layer = obj.Layer; objCode = obj.Code; graphicCode = obj.GraphicCode; coord = obj.Position; }
public ReboundTemplate(float paddleSpeed, BallType bType, ArenaObject arObject, ArenaObjectType arObjectType) { PaddleSpeed = paddleSpeed; BType = bType; ArObject = arObject; ArObjectType = arObjectType; }
public Vector2 ReboundPosition(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj) { var ballPos = b.Position; var ballDirection = b.Direction; return(ballPos); }
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(); }
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; } } } }
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); }
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()); }
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); }
public void AddHeigthTest() { ObstacleBuilder builder = new ObstacleBuilder(); builder.AddHeigth(10); ArenaObject obj = builder.CreateObject(); Assert.AreEqual(10, obj.Heigth); }
public void AddPosYTest() { ObstacleBuilder builder = new ObstacleBuilder(); builder.AddPosY(10); ArenaObject obj = builder.CreateObject(); Assert.AreEqual(10, obj.PosY); }
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); }
public void AddPosYTest() { PowerUpBuilder builder = new PowerUpBuilder(); builder.AddPosY(10); ArenaObject a = builder.CreateObject(); Assert.IsTrue(a.PosY == 10); }
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); }
public void AddDurationTest() { ObstacleBuilder builder = new ObstacleBuilder(); builder.AddDuration(10); ArenaObject obj = builder.CreateObject(); Assert.AreEqual(10, obj.Duration); }
public Vector2 ReboundDirection(Ball b, Vector2 collisionNormal, Paddle p, ArenaObject obj) { var ballDirection = b.Direction; if (p != null) { ArenaFacade.Instance.KillPaddle(p); } return(ballDirection); }
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); }
public override bool IsPassable(ArenaObject mover) { if (mover == null) { return(false); } else { return(!(mover is Lynx)); } }
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); }
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); }
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); }
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); }
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); }
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); }
public void RegisterCurrentArena(ArenaObject arena) { m_CurrentArena = arena; }
public RemoveObject(ArenaObject obj) { layer = obj.Layer; objCode = obj.Code; }
public override bool IsPassable(ArenaObject mover) => true;
private double VisionReduction(ArenaObject other, Obstacle plant) { double distanceInPlant = AmountTraversed(Position, other.Position, plant.Size); return(distanceInPlant * plant.VisionReductionPerMeter); }
public void EndCurrentArena() { m_CurrentArena = null; }
public BattleArena(int size) { ArenaSize = size; arenaTiles = new ArenaTile[size, size]; arenaObjects = new ArenaObject[size, size]; }
public override bool IsPassable(ArenaObject mover = null) => false;
public ReboundFromPaddle(float paddleSpeed, BallType bType, ArenaObject arObject, ArenaObjectType arObjectType) : base(paddleSpeed, bType, arObject, arObjectType) { }