private void CheckIfTouchesFluid(BlockType lava) { if (ActiveElements.GetActiveFluids(position).FindAll(s => s.Id == lava).Any(s => Collide(s))) { status.DealDamageFromLava(); } }
protected override void ReorientElement(ReorientMethod reorientMethod, int elementsCulledAbove) { if (ActiveElements.Count <= 1) { return; } if (reorientMethod == ReorientMethod.TopToBottom) { var top = ActiveElements[0]; ActiveElements.RemoveAt(0); ActiveElements.Add(top); top.transform.SetSiblingIndex(ActiveElements[ActiveElements.Count - 2].transform.GetSiblingIndex() + 1); top.Data = Data[elementsCulledAbove + ActiveElements.Count - 1]; } else { var bottom = ActiveElements[ActiveElements.Count - 1]; ActiveElements.RemoveAt(ActiveElements.Count - 1); ActiveElements.Insert(0, bottom); bottom.transform.SetSiblingIndex(ActiveElements[1].transform.GetSiblingIndex()); bottom.Data = Data[elementsCulledAbove]; } }
private void ApplyGravity() { var touchesFluid = ActiveElements.GetActiveFluids(position).Any(s => Collide(s)); if (moveDefiner.key(command.Jump) && Grounded) { Grounded = false; speed = touchesFluid ? Parameters.WaterJumpSpeed : Parameters.MaxFallSpeed; } foreach (var block in ActiveElements.GetActiveToppings(position)) { if (Collide(block) && TicksElapsed >= Parameters.BlocksCollisionDelay) { Grounded = true; if (speed < 0) { speed = 0; } status.DealDamage(DistanceFalled); DistanceFalled = 0; break; } } move(roation.Up, speed); ChangeMoveSpeed(touchesFluid); }
private void PlayMoveSound() { if (ActiveElements.GetActiveToppings(position).Any(s => Collide(s))) { Sound.PlaySound(SoundType.Walking); } }
public void CheckIfUnderwater() { foreach (var item in ActiveElements.GetActiveFluids(position)) { if (Collide(item)) { if (!IsInWater) { Sound.PlaySound(SoundType.WaterEnter); IsInWater = true; } WaterTicks++; if (WaterTicks > 19) { status.DealBreathBuuble(); WaterTicks = 0; } return; } } if (IsInWater) { Sound.PlaySound(SoundType.WaterExit); IsInWater = false; } status.RestoreBreath(); }
protected override void ReorientElement(ReorientMethod reorientMethod, int elementsCulledAbove) { if (ActiveElements.Count == 0) { return; } var count = Mathf.Abs(elementsCulledAbove - LastElementsCulledAbove); if (reorientMethod == ReorientMethod.TopToBottom) { for (var i = 0; i < count; i++) { var top = ActiveElements[0]; ActiveElements.RemoveAt(0); ActiveElements.Add(top); top.transform.SetSiblingIndex(ActiveElements[ActiveElements.Count - 2].transform.GetSiblingIndex() + 1); top.Data = Data[elementsCulledAbove + (i + 1 - count) + ActiveElements.Count - 1]; } } else { for (var i = 0; i < count; i++) { var bottom = ActiveElements[ActiveElements.Count - 1]; ActiveElements.RemoveAt(ActiveElements.Count - 1); ActiveElements.Insert(0, bottom); bottom.transform.SetSiblingIndex(ActiveElements[1].transform.GetSiblingIndex()); bottom.Data = Data[elementsCulledAbove - (i + 1 - count)]; } } }
void Awake() { gameController = GameObject.FindGameObjectWithTag("GameController"); eleDB = gameController.GetComponent <ElementDatabase>(); parent = GameObject.FindGameObjectWithTag("CombinationView").transform; activeElements = gameController.GetComponent <ActiveElements>(); comboDB = gameController.GetComponent <CombinationDatabase>(); inventory = gameController.GetComponent <Inventory>(); grid = GameObject.FindGameObjectWithTag("InventoryView").GetComponent <PopulateGrid>(); }
private void MoveLeft() { flip = true; move(roation.Left, Parameters.moveSpeed); foreach (var b in ActiveElements.GetActiveBlocks(position)) { if (Collide(b)) { move(roation.Right, Parameters.moveSpeed); OnWallHit?.Invoke(this, null); break; } } }
private void ApplyBlocksCollisions() { foreach (var b in ActiveElements.GetActiveBlocks(position)) { if (Collide(b as GenericSprite)) { if (speed > 0) { TicksElapsed = 0; speed = -speed; } } } if (TicksElapsed != Parameters.BlocksCollisionDelay) { TicksElapsed++; } }
public override void update() { if (Randomizer.Next(200) == 0 && Engine.entities.Count < 2) { var zombie = new Zombie(ActiveElements, Drawer, Sound, new Parameters(), Player); zombie.status.OnKill = () => Kill(zombie); zombie.position.x = Randomizer.Next(-110, 110); zombie.position.y = 70; if (!ActiveElements.GetActiveBlocks(zombie.position).Any(s => s.Collide(zombie))) { Engine.entities.Add(zombie); } } for (int i = 0; i < Engine.entities.Count(); i++) { var zombie = Engine.entities[i] as MovableObject; if (!zombie.IsInRange(150)) { Engine.entities.Remove(zombie); } } }