public void EnterLadder(Ladder ladder) { Debug.Log ("Entering"); this.ladder = ladder; rigidbody.useGravity = false; rigidbody.velocity = new Vector3 (0, 0, 0); ladderStartedClimb = false; }
public void LeaveLadder() { Debug.Log ("Leaving"); rigidbody.useGravity = true; if (!grounded) { Vector3 impulseForward = transform.forward * ladder.impulseForwardForce; Vector3 impulseUp = Vector3.up * ladder.impulseUpForce; rigidbody.AddForce (impulseForward + impulseUp, ForceMode.Impulse); } ladder = null; }
public ActionResult AdminLadders_Create([DataSourceRequest] DataSourceRequest request, Ladder ladder) { // need to redesign the create function using modal view.. instead of Grid /* if (ladder != null && ladder.Name != null) { Ladder.Insert(ladder); } return Json(new[] { ladder }.ToDataSourceResult(request, ModelState));*/ return View(); }
static void Main(string[] args) { Random rand = new Random(); IEloEngine elo = new FideEloEngine(); PlayerPoolFactory ppf = new PlayerPoolFactory(new FileStream(@"d:\temp\names\names.txt", FileMode.Open), rand); List<Player> pool = ppf.CreatePlayerPool(1000, elo.MinRating, elo.MaxRating); Ladder ladder = new Ladder(pool, elo); /*ladder.OnStartGame += player_OnStartGame; ladder.OnEndGame += player_OnEndGame; ladder.RegisterForTracking(pool[rand.Next(0, pool.Count())]);*/ ladder.Compete(10000); evaluateEloAccuracty(pool); Console.ReadLine(); }
// Update is called once per frame void Update() { if (photonView.IsMine) { // Manage ladder climbing motor.enabled = currentLadder == null && isPhysicsEnabled; motor.animator.SetBool("Climbing", currentLadder != null); if (currentLadder != null) { float distanceFromLadder = 0.4f; transform.position = currentLadder.transform.position + Vector3.Project(transform.position - currentLadder.transform.position, currentLadder.transform.up) - currentLadder.transform.forward * distanceFromLadder; transform.forward = currentLadder.transform.forward; float dot = Vector3.Dot(transform.position - currentLadder.transform.position, currentLadder.transform.up); if (dot > currentLadder.height - 1.50f) { currentLadder = null; photonView.RPC("PlayState", RpcTarget.All, "Climb Up", 0.2f); } else if (dot < 0f) { currentLadder = null; } } //motor.canWalk = !isBusy && !isAttacking && !isEvading; //motor.canJump = !isBusy && !isAttacking && !isEvading; //motor.canTurn = !isBusy && !isAttacking && !isEvading; /*motor.canWalk = movementMultiplier > 0.5f; * motor.canTurn = movementMultiplier > 0.5f; * motor.canJump = movementMultiplier > 0.5f;*/ // Turn torwards target /*if (target != null && motor.canTurn) { * motor.TurnTowards((target.transform.position - transform.position), CharacterMotor.TurnBehaviour.Normal); * }*/ if (target != null) { Turn((target.transform.position - transform.position)); } // Manage poise if (poise <= 0f) { Flinch(); poise = MaxPoise; } motor.animator.SetBool("Blocking", isBlocking); if (!isAttacking) { lastAttackTimer -= Time.deltaTime; } // Manage timers timeSinceLastDamage += Time.deltaTime; } }
void LatchLadder(GameObject latchedLadder) { currentLadder = latchedLadder.GetComponent <Ladder>(); climbDirection = currentLadder.ClimbDirection(); moveController.OnLadder(); }
// Use this for initialization void Start () { controller = GetComponent <PlayerController> (); animator = GetComponent<Animator> (); ladder = GetComponent<Ladder> (); }
public LadderGameStartedEvent(Ladder ladder, Game game) : base(game) { this.Ladder = ladder; }
private void OnTriggerExit2D(Collider2D coll) { if (coll.gameObject.tag == "Scratch") { bool found = false; foreach (Transform child in children) { RaycastHit2D[] ray1 = Physics2D.RaycastAll(child.position, new Vector2(1, 0), 0.1f); Debug.DrawRay(child.position, new Vector3(1, 0, 0) * 0.1f, Color.red, 4f); RaycastHit2D[] ray2 = Physics2D.RaycastAll(child.position, new Vector2(-1, 0), 0.1f); Debug.DrawRay(child.position, new Vector3(-1, 0, 0) * 0.1f, Color.red, 4f); foreach (RaycastHit2D ray in ray1) { if (ray.collider.gameObject.tag == "Scratch") { found = true; break; } } if (!found) { foreach (RaycastHit2D ray in ray2) { if (ray.collider.gameObject.tag == "Scratch") { found = true; break; } } } } if (!found) { gameObject.layer = lay; } } if (coll.gameObject.tag == "Climbable") { IsNearLadder = false; climbing = false; rb.gravityScale = 2; if (ladder != null) { ladder.ActivatePlatform(); } ladder = null; jumping = true; hasJumped = true; animator.SetBool("Climbing", false); } if (coll.gameObject.tag == "Quicksand") { jumping = true; m_Jump_force = normal_jump_force; gameObject.GetComponent <Rigidbody2D>().velocity = Vector2.zero; } if (coll.tag == "SafeZone") { canBeGrabbed = true; } }
public void SetLadder(Ladder ladder) { this.m_Ladder = ladder; }
/// <summary> /// Queue player for ladder /// </summary> public void Queue(Guid ladderId, User user) { Ladder ladder = this.unitOfWork.Ladders.Query().First(l => l.Id == ladderId); ladder.QueueUser(user); }
public void UnSetLadder() => this.ladder = null;
public void SetLadder(Ladder ladder) => this.ladder = ladder;
public static Block GetBlockById(byte blockId) { Block block = null; if (CustomBlockFactory != null) { block = CustomBlockFactory.GetBlockById(blockId); } if (block != null) return block; if (blockId == 0) block = new Air(); else if (blockId == 1) block = new Stone(); else if (blockId == 2) block = new Grass(); else if (blockId == 3) block = new Dirt(); else if (blockId == 4) block = new Cobblestone(); else if (blockId == 5) block = new Planks(); else if (blockId == 6) block = new Sapling(); else if (blockId == 7) block = new Bedrock(); else if (blockId == 8) block = new FlowingWater(); else if (blockId == 9) block = new StationaryWater(); else if (blockId == 10) block = new FlowingLava(); else if (blockId == 11) block = new StationaryLava(); else if (blockId == 12) block = new Sand(); else if (blockId == 13) block = new Gravel(); else if (blockId == 14) block = new GoldOre(); else if (blockId == 15) block = new IronOre(); else if (blockId == 16) block = new CoalOre(); else if (blockId == 17) block = new Log(); else if (blockId == 18) block = new Leaves(); else if (blockId == 19) block = new Sponge(); else if (blockId == 20) block = new Glass(); else if (blockId == 21) block = new LapisOre(); else if (blockId == 22) block = new LapisBlock(); else if (blockId == 23) block = new Dispenser(); else if (blockId == 24) block = new Sandstone(); else if (blockId == 25) block = new NoteBlock(); else if (blockId == 26) block = new Bed(); else if (blockId == 27) block = new GoldenRail(); else if (blockId == 28) block = new DetectorRail(); else if (blockId == 30) block = new Cobweb(); else if (blockId == 31) block = new TallGrass(); else if (blockId == 32) block = new DeadBush(); else if (blockId == 35) block = new Wool(); else if (blockId == 37) block = new YellowFlower(); else if (blockId == 38) block = new Flower(); else if (blockId == 39) block = new BrownMushroom(); else if (blockId == 40) block = new RedMushroom(); else if (blockId == 41) block = new GoldBlock(); else if (blockId == 42) block = new IronBlock(); else if (blockId == 43) block = new DoubleStoneSlab(); else if (blockId == 44) block = new StoneSlab(); else if (blockId == 45) block = new Bricks(); else if (blockId == 46) block = new Tnt(); else if (blockId == 47) block = new Bookshelf(); else if (blockId == 48) block = new MossStone(); else if (blockId == 49) block = new Obsidian(); else if (blockId == 50) block = new Torch(); else if (blockId == 51) block = new Fire(); else if (blockId == 52) block = new MonsterSpawner(); else if (blockId == 53) block = new OakWoodStairs(); else if (blockId == 54) block = new Chest(); else if (blockId == 55) block = new RedstoneWire(); else if (blockId == 56) block = new DiamondOre(); else if (blockId == 57) block = new DiamondBlock(); else if (blockId == 58) block = new CraftingTable(); else if (blockId == 59) block = new Wheat(); else if (blockId == 60) block = new Farmland(); else if (blockId == 61) block = new Furnace(); else if (blockId == 62) block = new LitFurnace(); else if (blockId == 63) block = new StandingSign(); else if (blockId == 64) block = new WoodenDoor(); else if (blockId == 65) block = new Ladder(); else if (blockId == 66) block = new Rail(); else if (blockId == 67) block = new CobblestoneStairs(); else if (blockId == 68) block = new WallSign(); else if (blockId == 69) block = new Lever(); else if (blockId == 70) block = new StonePressurePlate(); else if (blockId == 71) block = new IronDoor(); else if (blockId == 72) block = new WoodenPressurePlate(); else if (blockId == 73) block = new RedstoneOre(); else if (blockId == 74) block = new LitRedstoneOre(); else if (blockId == 75) block = new UnlitRedstoneTorch(); else if (blockId == 76) block = new RedstoneTorch(); else if (blockId == 77) block = new StoneButton(); else if (blockId == 78) block = new SnowLayer(); else if (blockId == 79) block = new Ice(); else if (blockId == 80) block = new Snow(); else if (blockId == 81) block = new Cactus(); else if (blockId == 82) block = new Clay(); else if (blockId == 83) block = new Reeds(); else if (blockId == 85) block = new Fence(); else if (blockId == 86) block = new Pumpkin(); else if (blockId == 87) block = new Netherrack(); else if (blockId == 88) block = new SoulSand(); else if (blockId == 89) block = new Glowstone(); else if (blockId == 90) block = new Portal(); else if (blockId == 91) block = new LitPumpkin(); else if (blockId == 92) block = new Cake(); else if (blockId == 93) block = new UnpoweredRepeater(); else if (blockId == 94) block = new PoweredRepeater(); else if (blockId == 95) block = new InvisibleBedrock(); else if (blockId == 96) block = new Trapdoor(); else if (blockId == 97) block = new MonsterEgg(); else if (blockId == 98) block = new StoneBrick(); else if (blockId == 99) block = new BrownMushroomBlock(); else if (blockId == 100) block = new RedMushroomBlock(); else if (blockId == 101) block = new IronBars(); else if (blockId == 102) block = new GlassPane(); else if (blockId == 103) block = new Melon(); else if (blockId == 106) block = new Vine(); else if (blockId == 107) block = new FenceGate(); else if (blockId == 108) block = new BrickStairs(); else if (blockId == 109) block = new StoneBrickStairs(); else if (blockId == 110) block = new Mycelium(); else if (blockId == 111) block = new Waterlily(); else if (blockId == 112) block = new NetherBrick(); else if (blockId == 113) block = new NetherBrickFence(); else if (blockId == 114) block = new NetherBrickStairs(); else if (blockId == 115) block = new NetherWart(); else if (blockId == 116) block = new EnchantingTable(); else if (blockId == 117) block = new BrewingStand(); else if (blockId == 120) block = new EndPortalFrame(); else if (blockId == 121) block = new EndStone(); else if (blockId == 122) block = new LitRedstoneLamp(); else if (blockId == 123) block = new RedstoneLamp(); else if (blockId == 126) block = new ActivatorRail(); else if (blockId == 127) block = new Cocoa(); else if (blockId == 128) block = new SandStoneStairs(); else if (blockId == 129) block = new EmeraldOre(); else if (blockId == 131) block = new TripwireHook(); else if (blockId == 132) block = new Tripwire(); else if (blockId == 133) block = new EmeraldBlock(); else if (blockId == 134) block = new SpruceWoodStairs(); else if (blockId == 135) block = new BirchWoodStairs(); else if (blockId == 136) block = new JungleWoodStairs(); else if (blockId == 139) block = new CobblestoneWall(); else if (blockId == 140) block = new FlowerPot(); else if (blockId == 141) block = new Carrots(); else if (blockId == 142) block = new Potatoes(); else if (blockId == 143) block = new WoodenButton(); else if (blockId == 144) block = new Skull(); else if (blockId == 145) block = new Anvil(); else if (blockId == 146) block = new TrappedChest(); else if (blockId == 147) block = new LightWeightedPressurePlate(); else if (blockId == 148) block = new HeavyWeightedPressurePlate(); else if (blockId == 151) block = new DaylightDetector(); else if (blockId == 152) block = new RedstoneBlock(); else if (blockId == 153) block = new QuartzOre(); else if (blockId == 155) block = new QuartzBlock(); else if (blockId == 156) block = new QuartzStairs(); else if (blockId == 157) block = new DoubleWoodSlab(); else if (blockId == 158) block = new WoodSlab(); else if (blockId == 159) block = new StainedHardenedClay(); else if (blockId == 161) block = new AcaciaLeaves(); else if (blockId == 162) block = new AcaciaLog(); else if (blockId == 163) block = new AcaciaStairs(); else if (blockId == 164) block = new DarkOakStairs(); else if (blockId == 167) block = new IronTrapdoor(); else if (blockId == 170) block = new HayBlock(); else if (blockId == 171) block = new Carpet(); else if (blockId == 172) block = new HardenedClay(); else if (blockId == 173) block = new CoalBlock(); else if (blockId == 174) block = new PackedIce(); else if (blockId == 175) block = new Sunflower(); else if (blockId == 178) block = new DaylightDetectorInverted(); else if (blockId == 183) block = new SpruceFenceGate(); else if (blockId == 184) block = new BirchFenceGate(); else if (blockId == 185) block = new JungleFenceGate(); else if (blockId == 186) block = new DarkOakFenceGate(); else if (blockId == 187) block = new AcaciaFenceGate(); else if (blockId == 198) block = new GrassPath(); else if (blockId == 199) block = new ItemFrame(); else if (blockId == 243) block = new Podzol(); else if (blockId == 244) block = new Beetroot(); else if (blockId == 245) block = new Stonecutter(); else if (blockId == 246) block = new GlowingObsidian(); else if (blockId == 247) block = new NetherReactorCore(); else { // Log.DebugFormat(@" // // Add this missing block to the BlockFactory // else if (blockId == {1}) block = new {0}(); // // public class {0} : Block // {{ // internal {0}() : base({1}) // {{ // }} // }} //", "Missing", blockId); block = new Block(blockId); } return block; }
public List <String> FindWikiLadder(string startPage, string endPage) { // Hashset to keep track of visited pages. HashSet <string> visitedPages = new HashSet <string>(); // PQ to keep ladders in. PriorityQueue <Ladder> pq = new PriorityQueue <Ladder>(); // Client for fetching links from wikipedia. GetWikiPageLinks linkClient = new GetWikiPageLinks(); //Get links for endPage HashSet <string> linksOnEndPage = linkClient.GetListOfLinksForWord(endPage); // Create add a ladder containg start page to queue. Ladder startLadder = new Ladder(); startLadder.ladderList.Add(startPage); startLadder.priority = 1; pq.Enqueue(startLadder); while (pq.count > 0) { //Deque ladder with highest priority. Ladder ladderWithHighestPriority = pq.Dequeue(); string lastLinkFromLadder = ladderWithHighestPriority.ladderList[ladderWithHighestPriority.ladderList.Count - 1]; HashSet <string> linksFromLastPage = linkClient.GetListOfLinksForWord(lastLinkFromLadder); // If end page is in this set, the ladder is found. Return. if (linksFromLastPage.Contains(endPage)) { ladderWithHighestPriority.ladderList.Add(endPage); return(ladderWithHighestPriority.ladderList); } // For each neighbourpage foreach (string neighBourPage in linksFromLastPage) { // Check if already visited. if (!visitedPages.Contains(neighBourPage)) { // Create copy of ladder. Ladder newLadder = new Ladder(ladderWithHighestPriority); // Put neighbor page at end of copied ladder. newLadder.ladderList.Add(neighBourPage); // Set priority of new ladder. By comparing links on last page with links on end page. HashSet <string> linksOnNeighBourPage = linkClient.GetListOfLinksForWord(neighBourPage); int counter = 0; foreach (string link in linksOnNeighBourPage) { if (linksOnEndPage.Contains(link)) { counter++; } } // Inverse the priority to work with binary three with minimum value first. counter *= -1; newLadder.priority = counter; pq.Enqueue(newLadder); visitedPages.Add(neighBourPage); } } } // In case this point is reached no matching ladder was found, so return empty list. List <string> empty = new List <string>(); return(empty); }
public void RemoveLadder() { this.ladder = null; DisableClimbingMode(); }
public void UpdateRankings(Ladder ladder) { IEnumerable<LadderPlayer> AllLadPlayers = LadderPlayerCollection.LoadByLadder(ladder) .OrderByDescending(lp => lp.PlayerPoints) .ThenByDescending(lp => (lp.PlayerPoints - lp.PreviousPoints)); int rank = 1; foreach (LadderPlayer lp in AllLadPlayers) { lp.PlayerRank = rank; lp.Save(); rank++; } }
public ActionResult CreateLadder(CreateLadderViewModel model) { // if the model is valid, this will create a new ladder from the model data if (ModelState.IsValid) { Ladder newLadder = new Ladder(); newLadder.Name = model.Name; newLadder.Description = model.Description; newLadder.MatchTypeId = model.MatchTypeId; newLadder.CreationDate = DateTime.UtcNow; newLadder.isActive = model.isActive; newLadder.MaxPlayers = model.MaxPlayers; newLadder.GenderId = model.GenderId; newLadder.MinAge = model.MinAge; newLadder.MaxAge = model.MaxAge; newLadder.MinRating = model.MinRating; newLadder.MaxRating = model.MaxRating; newLadder.UpperChallengeLimit = model.UpperChallengeLimit; newLadder.LowerChallengeLimit = model.LowerChallengeLimit; newLadder.MaxPendingChallenges = model.MaxPendingChallenges; newLadder.MaxQueuedChallenges = model.MaxQueuedChallenges; newLadder.MaxInactiveDays = model.MaxInactiveDays; newLadder.Penalties = model.Penalties; newLadder.InactivityPointLoss = model.InactivityPointLoss; newLadder.MinReqChallenges = model.MinReqChallenges; newLadder.MinChallengeDays = model.MinChallengeDays; newLadder.MinChallengePointLoss = model.MinChallengePointLoss; newLadder.MinReqMatches = model.MinReqMatches; newLadder.MinMatchDays = model.MinMatchDays; newLadder.MinMatchPointLoss = model.MinMatchPointLoss; newLadder.IgnoreAction = model.IgnoreAction; newLadder.IgnorePointLoss = model.IgnorePointLoss; newLadder.MaxIgnoreDays = model.MaxIgnoreDays; newLadder.ChallengeDecline = model.ChallengeDecline; newLadder.MaxDeclines = model.MaxDeclines; newLadder.DeclineDays = model.DeclineDays; newLadder.DeclinePointLoss = model.DeclinePointLoss; newLadder.ForfeitPointLoss = model.ForfeitPointLoss; newLadder.Save(); Success("<strong>Success!</strong> Ladder has been created.", true); //LadderPoints /*These are constant for now, but planning to add admin ability to edit these values later*/ PlayerRatingCollection allratings = PlayerRatingCollection.LoadAll(); foreach(PlayerRating rating in allratings) { LadderPoints pointSet = new LadderPoints { RatingId = rating.Id, LadderId = newLadder.Id, NumStartingPoints = 10, ExpectedWinPoints = 10, ExpectedLossPoints = 5, UnexpectedWinPoints = 20, UnexpectedLossPoints = 10 }; pointSet.Save(); } return RedirectToAction("AllLadders"); } return View(); }
public TestLevel(Texture2D texture, string mapname, Vector2 position) { this.mapname = mapname; this.position = position; switch (mapname) { case "map": map = new int[, ] { /*items*/ // 1 = blok // 3 = ladder // 5 = item // 7 = schuif obj // 9 = falldoor button // 11 // 2 = steen // 4 = button // 6 = door // 8 = fall door // 10 = pressure plate { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 1, 0, 1, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 0, 0, 0, 0, 0, 10, 0, 10, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }; break; } buttons = new List <Door_button>(); ladders = new List <Ladder>(); stones = new List <Steen>(); Tiles = new List <blok>(); collectibles = new List <CollectItem>(); doors = new List <Door>(); moveObjects = new List <MoveObject>(); Mdoors = new List <MoveDoor>(); Mbuttons = new List <MoveDoorButton>(); plates = new List <PressurePlate>(); CheckRtiles = new List <blok>(); CheckLtiles = new List <blok>(); CheckBtiles = new List <blok>(); this.tiletexture = texture; buttonIndex = 0; ladderIndex = 0; doorIndex = 0; center = new Vector2(this.Width / 2 * 44, this.Heigth / 2 * 44); SpawnNextlvl = false; for (int x = 0; x < Width; x++) { for (int y = 0; y < Heigth; y++) { //Assets in het Grid genereren int textureIndex = map[y, x]; if (textureIndex == 0) { continue; } switch (textureIndex) { case 1: blok tile = new blok(tiletexture, new Vector2(position.X + x * 44, position.Y + y * 44)); Tiles.Add(tile); break; case 2: Steen steen = new Steen(Game1.crushstone, 13, 1); AnimationClass animate = new AnimationClass(); steen.position = new Vector2(position.X + x * 44, position.Y + y * 44); steen.addAnimation(Game1.crushstone, "idle", 1, 13, animate.Copy()); steen.Animation = "idle"; stones.Add(steen); break; case 3: Ladder ladder = new Ladder(Game1.laddertextures[ladderIndex], new Vector2(position.X + x * 44, position.Y + y * 44)); ladderIndex++; ladders.Add(ladder); break; case 4: Door_button button = new Door_button(Game1.button_tex, 12, 1, buttonIndex); AnimationClass animate2 = new AnimationClass(); button.position = new Vector2(position.X + x * 44, position.Y + y * 44); button.addAnimation(Game1.button_tex, "idle", 1, 12, animate2.Copy()); button.Animation = "idle"; buttonIndex++; buttons.Add(button); break; case 5: CollectItem item = new CollectItem(Game1.slaktex, 50, 1); AnimationClass animate3 = new AnimationClass(); item.position = new Vector2(position.X + x * 44, position.Y + y * 44); item.addAnimation(Game1.slaktex, "idle", 1, 50, animate3.Copy()); item.Animation = "idle"; collectibles.Add(item); break; case 6: Door door = new Door(Game1.door_tex, new Vector2(position.X + x * 44, position.Y + y * 44), doorIndex); doorIndex++; doors.Add(door); break; case 7: MoveObject obj = new MoveObject(Game1.stonetex, 15, 1); AnimationClass animate5 = new AnimationClass(); obj.position = new Vector2(position.X + x * 44, position.Y + y * 44); obj.addAnimation(Game1.stonetex, "idle2", 1, 15, animate5.Copy()); obj.Animation = "idle2"; moveObjects.Add(obj); break; case 8: MoveDoor objdoor = new MoveDoor(Game1.fallStone, new Vector2(position.X + x * 44, position.Y + y * 44), moveDoorIndex); moveDoorIndex++; Mdoors.Add(objdoor); break; case 9: MoveDoorButton button2 = new MoveDoorButton(Game1.button_tex, 12, 1, moveButtonIndex); AnimationClass animate6 = new AnimationClass(); button2.position = new Vector2(position.X + x * 44, position.Y + y * 44); button2.addAnimation(Game1.button_tex, "idle", 1, 12, animate6.Copy()); button2.Animation = "idle"; moveButtonIndex++; Mbuttons.Add(button2); break; case 10: PressurePlate plate = new PressurePlate(Game1.pressureplate, new Vector2(position.X + x * 44, position.Y + y * 55)); plates.Add(plate); break; case 11: liftobject = new LiftObject(Game1.liftobj, new Vector2(position.X + x * 44, position.Y + y * 44)); break; } } } }
//Initializes every Block as a GameObject private void InitBlocks() { //To make the edges of the dirt look nice a padded map is added where there is one layer of air around all 4 edges //Currently only used by Dirt.InitializeSprite() //Initializes the empty padded map PrimitiveBlock[][] paddedMap = new PrimitiveBlock[BIOME_WIDTH + 2][]; PrimitiveBlock[][] paddedBackMap = new PrimitiveBlock[BIOME_WIDTH + 2][]; for (int i = 0; i < BIOME_WIDTH + 2; i++) { paddedMap[i] = new PrimitiveBlock[BIOME_HEIGHT + 2]; paddedBackMap[i] = new PrimitiveBlock[BIOME_HEIGHT + 2]; } //Fills the padded map for (int x = 0; x < BIOME_WIDTH + 2; x++) { for (int y = 0; y < BIOME_HEIGHT + 2; y++) { //If it's a piece of padding to be added if (x == 0 || x == BIOME_WIDTH + 1 || y == 0 || y == BIOME_HEIGHT + 1) { paddedMap[x][y] = new PrimitiveBlock(x, y); paddedBackMap[x][y] = new PrimitiveBlock(x, y); } //If the block is a trench block, when initializing dirt sprites a Trench block is considered a Dirt block else if (map[x - 1][y - 1].bt == BlockType.TRENCH) { paddedMap[x][y] = new PrimitiveBlock(x, y, BlockType.DIRT); } //If it's a block that's also present in map else { paddedMap[x][y] = map[x - 1][y - 1]; paddedBackMap[x][y] = backMap[x - 1][y - 1]; } } } GameObject go; PrimitiveBlock pb; //Initializes every block for (int x = 0; x < BIOME_WIDTH; x++) { for (int y = 0; y < BIOME_HEIGHT; y++) { pb = map[x][y]; //Adds the correct scripts (if any) to switch (pb.bt) { case BlockType.DIRT: go = Instantiate <GameObject>(baseDirt); Dirt dirt = go.GetComponent <Dirt>(); dirt.SetPosition(pb.x, pb.y); dirt.InitializeSprite(paddedMap); break; case BlockType.BRIDGE: go = Instantiate <GameObject>(baseBridge); Bridge bridge = go.GetComponent <Bridge>(); bridge.SetPosition(pb.x, pb.y); bridge.InitializeSprite(map); break; case BlockType.LADDER: go = Instantiate <GameObject>(baseLadder); Ladder ladder = go.GetComponent <Ladder>(); ladder.SetPosition(pb.x, pb.y); ladder.InitializeSprite(map); break; case BlockType.TRENCH: go = Instantiate <GameObject>(baseTrench); Trench trench = go.GetComponent <Trench>(); trench.SetPosition(pb.x, pb.y); trench.InitializeSprite(map); break; case BlockType.PLATFORM: go = Instantiate <GameObject>(basePlatform); Platform platform = go.GetComponent <Platform>(); platform.SetPosition(pb.x, pb.y); platform.InitializeSprite(map); break; case BlockType.ROOF: go = Instantiate <GameObject>(baseRoof); Roof roof = go.GetComponent <Roof>(); roof.SetPosition(pb.x, pb.y); roof.InitializeSprite(map); break; case BlockType.BOX: go = Instantiate <GameObject>(baseBox); Box box = go.GetComponent <Box>(); box.SetPosition(pb.x, pb.y); box.InitializeSprite(map); break; case BlockType.EXPLOSIVE: go = Instantiate(baseExplosive); Explosive e = go.GetComponent <Explosive>(); e.SetPosition(pb.x, pb.y); break; } pb = backMap[x][y]; BackgroundBlock bb; switch (pb.bt) { case BlockType.BACKGROUND_BLOCK: go = Instantiate(baseBackgroundBlock); bb = go.GetComponent <BackgroundBlock>(); bb.SetPosition(pb.x, pb.y); bb.InitializeSprite(backMap); //go.isStatic = true; break; case BlockType.DIRT: go = Instantiate(baseBackgroundBlock); bb = go.GetComponent <BackgroundBlock>(); bb.SetPosition(pb.x, pb.y); Dirt.InitializeSprite(paddedBackMap, go.GetComponent <SpriteRenderer>(), pb.x, pb.y); //go.isStatic = true; break; } } } }
private bool _PlayerMove(PlayerCommand command) { // Исходя из команды, выполнить то или иное действие. // Если команда пройдёт успешно, то исчерпать запасы стамины и гонять Think, пока она не восстановится // Перемещение: if ((int)command < (int)PlayerCommand.Wait) { int x = PlayerPawn.X, y = PlayerPawn.Y; switch (command) { case PlayerCommand.Move0: x++; break; case PlayerCommand.Move45: x++; y--; break; case PlayerCommand.Move90: y--; break; case PlayerCommand.Move135: x--; y--; break; case PlayerCommand.Move180: x--; break; case PlayerCommand.Move225: x--; y++; break; case PlayerCommand.Move270: y++; break; case PlayerCommand.Move315: x++; y++; break; } return(_PlayerMove(x, y)); } if (command == PlayerCommand.Wait) { // Во время отдыха игрок должен быстрее регенерировать здоровье // и медленнее становиться голоднее PlayerPawn.Thoughts = ThoughtTypeEnum.Stand; return(true); } // Лестница if (command == PlayerCommand.LadderDown || command == PlayerCommand.LadderUp) { if (!(CurrentFloor.Tiles[PlayerPawn.X, PlayerPawn.Y] is Ladder)) { return(false); } Ladder ourpos = CurrentFloor.Tiles[PlayerPawn.X, PlayerPawn.Y] as Ladder; int nextlevel = currentLevel + ((ourpos.Direction == Ladder.LadderDirection.Up) ? -1 : 1); if (nextlevel < 0) { return(false); } // Если следующий уровень ещё не сгенерирован, то сгенерировать и связать текущую лестницу со случайной if (nextlevel > floors.Count - 1)// Уравнял счетчик с индексами { ourpos.LadderId = random.Next(1, Int32.MaxValue); var newfloor = new DungeonFloor( Spawner.Random.Next(currentLevel + 2 * 10, 81), Spawner.Random.Next(currentLevel + 2 * 10, 81) ); floors.Add(newfloor); newfloor.FloorActors.AddLast(PlayerPawn); int lx = 0; int ly = 0; for (int i = 0; i < newfloor.Width; i++) { for (int j = 0; j < newfloor.Height; j++) { if (newfloor.Tiles[i, j] is Ladder && (newfloor.Tiles[i, j] as Ladder).Direction == Ladder.LadderDirection.Up) { lx = i; ly = j; PlayerPawn.ChangePos(lx, ly); } } } (newfloor.Tiles[lx, ly] as Ladder).LadderId = ourpos.LadderId; SendClientMessage(null, $"Вы {(nextlevel > CurrentLevel ? "спускаетесь" : "поднимаетесь")} на уровень {nextlevel+1}"); } // Если он уже существует, то попытаться найти свободную лестницу, если не выйдет, то скинуть в случ. // позицию. else { //Этаж на который переходим var floor = floors[nextlevel]; if (ourpos.LadderId == 0) { int lx = 0; int ly = 0; //Задаем id для новой лестницы ourpos.LadderId = random.Next(1, Int32.MaxValue); for (int i = 0; i < floor.Width; i++) { for (int j = 0; j < floor.Height; j++) { //Если 2 лестницы не связаны, то ищем свободную if (floor.Tiles[i, j] is Ladder && (floor.Tiles[i, j] as Ladder).LadderId == 0 && (floor.Tiles[i, j] as Ladder).Direction != ourpos.Direction) { lx = i; ly = j; PlayerPawn.ChangePos(lx, ly); } } } (floor.Tiles[lx, ly] as Ladder).LadderId = ourpos.LadderId; } else { for (int i = 0; i < floor.Width; i++) { for (int j = 0; j < floor.Height; j++) { //Если 2 лестницы связаны то перемещаемся по ним if (floor.Tiles[i, j] is Ladder && (floor.Tiles[i, j] as Ladder).LadderId == ourpos.LadderId) { PlayerPawn.ChangePos(i, j); } } } } SendClientMessage(null, $"Вы возвращаетесь на уровень {nextlevel}"); } currentLevel = nextlevel; return(true); } // Поднятие предмета if (command == PlayerCommand.PickupItem) { var item = CurrentFloor.FloorItems.FirstOrDefault(x => x.X == PlayerPawn.X && x.Y == PlayerPawn.Y); if (item == null) { return(false); } CurrentFloor.FloorItems.Remove(item); /*if (item.RemoveOnPickup) * item.Use(PlayerPawn); * else*/ PlayerPawn.AddItem(item); return(true); } // Открытие / закрытие дверей if (command == PlayerCommand.OpenDoor || command == PlayerCommand.CloseDoor) { for (int i = PlayerPawn.X - 1; i <= PlayerPawn.X + 1; i++) { for (int j = PlayerPawn.Y - 1; j <= PlayerPawn.Y + 1; j++) { if (CurrentFloor.Tiles[i, j] is Door) { (CurrentFloor.Tiles[i, j] as Door).IsOpen = (command == PlayerCommand.OpenDoor) ? true : false; return(true); } } } return(false); } if (command == PlayerCommand.EquipItem || command == PlayerCommand.RemoveItem) { return(true); } return(false); }
/// <summary> /// Leave the queue, if currently in it /// </summary> public void LeaveQueue(Guid ladderId, User user) { Ladder ladder = this.unitOfWork.Ladders.GetById(ladderId); ladder.QueueLeaveUser(user); }
private Vector2 DiffToCurrentNode() { if (currentPath == null || currentPath.Unreachable) { return(Vector2.Zero); } if (currentPath.Finished) { Vector2 pos2 = host.SimPosition; if (character != null && character.Submarine == null && CurrentPath.Nodes.Count > 0 && CurrentPath.Nodes.Last().Submarine != null) { pos2 -= CurrentPath.Nodes.Last().Submarine.SimPosition; } return(currentTarget - pos2); } if (canOpenDoors && !character.LockHands && buttonPressCooldown <= 0.0f) { CheckDoorsInPath(); } Vector2 pos = host.SimPosition; if (character != null && currentPath.CurrentNode != null) { if (CurrentPath.CurrentNode.Submarine != null) { if (character.Submarine == null) { pos -= CurrentPath.CurrentNode.Submarine.SimPosition; } else if (character.Submarine != currentPath.CurrentNode.Submarine) { pos -= ConvertUnits.ToSimUnits(currentPath.CurrentNode.Submarine.Position - character.Submarine.Position); } } } bool isDiving = character.AnimController.InWater && character.AnimController.HeadInWater; // Only humanoids can climb ladders bool canClimb = character.AnimController is HumanoidAnimController && !character.LockHands; Ladder currentLadder = currentPath.CurrentNode.Ladders; if (currentLadder != null && !currentLadder.Item.IsInteractable(character)) { currentLadder = null; } Ladder nextLadder = GetNextLadder(); var ladders = currentLadder ?? nextLadder; bool useLadders = canClimb && ladders != null && (!isDiving || Math.Abs(steering.X) < 0.1f && Math.Abs(steering.Y) > 1); if (useLadders && character.SelectedConstruction != ladders.Item) { if (character.CanInteractWith(ladders.Item)) { ladders.Item.TryInteract(character, false, true); } else { // Cannot interact with the current (or next) ladder, // Try to select the previous ladder, unless it's already selected, unless the previous ladder is not adjacent to the current ladder. // The intention of this code is to prevent the bots from dropping from the "double ladders". var previousLadders = currentPath.PrevNode?.Ladders; if (previousLadders != null && previousLadders != ladders && character.SelectedConstruction != previousLadders.Item && character.CanInteractWith(previousLadders.Item) && Math.Abs(previousLadders.Item.WorldPosition.X - ladders.Item.WorldPosition.X) < 5) { previousLadders.Item.TryInteract(character, false, true); } } } var collider = character.AnimController.Collider; if (character.IsClimbing && !useLadders) { character.AnimController.Anim = AnimController.Animation.None; character.SelectedConstruction = null; } if (character.IsClimbing && useLadders) { Vector2 diff = currentPath.CurrentNode.SimPosition - pos; bool nextLadderSameAsCurrent = IsNextLadderSameAsCurrent; if (nextLadderSameAsCurrent) { //climbing ladders -> don't move horizontally diff.X = 0.0f; } //at the same height as the waypoint if (Math.Abs(collider.SimPosition.Y - currentPath.CurrentNode.SimPosition.Y) < (collider.height / 2 + collider.radius) * 1.25f) { float heightFromFloor = character.AnimController.GetColliderBottom().Y - character.AnimController.FloorY; if (heightFromFloor <= 0.0f) { diff.Y = Math.Max(diff.Y, 1.0f); } // We need some margin, because if a hatch has closed, it's possible that the height from floor is slightly negative. bool isAboveFloor = heightFromFloor > -0.1f; // If the next waypoint is horizontally far, we don't want to keep holding the ladders if (isAboveFloor && (nextLadder == null || Math.Abs(currentPath.CurrentNode.WorldPosition.X - currentPath.NextNode.WorldPosition.X) > 50)) { character.AnimController.Anim = AnimController.Animation.None; character.SelectedConstruction = null; } else if (nextLadder != null && !nextLadderSameAsCurrent) { // Try to change the ladder (hatches between two submarines) if (character.SelectedConstruction != nextLadder.Item && nextLadder.Item.IsInsideTrigger(character.WorldPosition)) { nextLadder.Item.TryInteract(character, false, true); } } if (isAboveFloor || nextLadderSameAsCurrent) { currentPath.SkipToNextNode(); } } else if (nextLadder != null) { //if the current node is below the character and the next one is above (or vice versa) //and both are on ladders, we can skip directly to the next one //e.g. no point in going down to reach the starting point of a path when we could go directly to the one above if (Math.Sign(currentPath.CurrentNode.WorldPosition.Y - character.WorldPosition.Y) != Math.Sign(currentPath.NextNode.WorldPosition.Y - character.WorldPosition.Y)) { currentPath.SkipToNextNode(); } } return(diff); } else if (character.AnimController.InWater) { var door = currentPath.CurrentNode.ConnectedDoor; if (door == null || door.CanBeTraversed) { float margin = MathHelper.Lerp(1, 5, MathHelper.Clamp(collider.LinearVelocity.Length() / 10, 0, 1)); Vector2 colliderSize = collider.GetSize(); float targetDistance = Math.Max(Math.Max(colliderSize.X, colliderSize.Y) / 2 * margin, 0.5f); float horizontalDistance = Math.Abs(character.WorldPosition.X - currentPath.CurrentNode.WorldPosition.X); float verticalDistance = Math.Abs(character.WorldPosition.Y - currentPath.CurrentNode.WorldPosition.Y); if (character.CurrentHull != currentPath.CurrentNode.CurrentHull) { verticalDistance *= 2; } float distance = horizontalDistance + verticalDistance; if (ConvertUnits.ToSimUnits(distance) < targetDistance) { currentPath.SkipToNextNode(); } } } else { // Walking horizontally Vector2 colliderBottom = character.AnimController.GetColliderBottom(); Vector2 colliderSize = collider.GetSize(); Vector2 velocity = collider.LinearVelocity; // If the character is very short, it would fail to use the waypoint nodes because they are always too high. // If the character is very thin, it would often fail to reach the waypoints, because the horizontal distance is too small. // Both values are based on the human size. So basically anything smaller than humans are considered as equal in size. float minHeight = 1.6125001f; float minWidth = 0.3225f; // Cannot use the head position, because not all characters have head or it can be below the total height of the character float characterHeight = Math.Max(colliderSize.Y + character.AnimController.ColliderHeightFromFloor, minHeight); float horizontalDistance = Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X); bool isAboveFeet = currentPath.CurrentNode.SimPosition.Y > colliderBottom.Y; bool isNotTooHigh = currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y + characterHeight; var door = currentPath.CurrentNode.ConnectedDoor; float margin = MathHelper.Lerp(1, 10, MathHelper.Clamp(Math.Abs(velocity.X) / 5, 0, 1)); float targetDistance = Math.Max(colliderSize.X / 2 * margin, minWidth / 2); if (horizontalDistance < targetDistance && isAboveFeet && isNotTooHigh && (door == null || door.CanBeTraversed)) { currentPath.SkipToNextNode(); } } if (currentPath.CurrentNode == null) { return(Vector2.Zero); } return(currentPath.CurrentNode.SimPosition - pos); }
private void Awake() { ladder = GetComponentInParent <Ladder>(); infoSignAnim = GetComponentInChildren <Animator>(); }
public void GrabLadder(Vector3 handPos, Ladder currentLadder) { _onLadder = true; transform.position = handPos; }
void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.name == "Ladder") { IsNextToLadder = true; ladderComp = other.gameObject.GetComponent<Ladder>(); Instantiate(textbox, new Vector3(transform.position.x + 0.75f, transform.position.y + 1.4f, -3), Quaternion.identity); } }
void Update() { if (plat.Grounded) { anim.SetInteger("jump", 0); if (fuel < 100) { fuel += FUEL_RECHARGE_RATE * Time.deltaTime; pls.PlayJetpackRefillingSound(); if (fuel > 100) { pls.PlayJetpackRefilledSound(); pls.PauseJetpackRefillingSound(); fuel = 100; } } flytimer = Time.time; } else { pls.PauseJetpackRefillingSound(); canfly = Time.time > flytimer + 0.2f; } if (Input.GetKeyUp(KeyCode.Space)) { pls.PauseJetpackUsingSound(); jetpackParticle.Stop(); } if (InWater) { anim.SetInteger("inwater", 1); } else { anim.SetInteger("inwater", 0); } if (plat.Grounded != oldGrounded) { if (plat.Grounded && oldVelocity.y < -2f) { pls.PlayLandSound(); var p = Instantiate(landParticle, new Vector3( walkParticlePosition.position.x, walkParticlePosition.position.y + 0.2f, walkParticlePosition.position.z), Quaternion.identity); } } oldGrounded = plat.Grounded; oldVelocity = velocity; var cols = Physics2D.BoxCastAll(transform.position, new Vector2(1, 1), 0, Vector2.zero); foreach (var col in cols) { if (col.transform.tag == "Ladder" && !OnLadder && (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.W))) { //Get on the ladder onLadderObject = col.transform.GetComponent <Ladder>(); OnLadder = true; var pos = transform.position; pos.x = onLadderObject.transform.position.x + (onLadderObject.Side == Ladder.LadderSide.RIGHT ? Ladder.LADDER_WIDTH : 0); transform.position = pos; var scale = transform.localScale; scale.x = onLadderObject.Side == Ladder.LadderSide.RIGHT ? -1 : 1; transform.localScale = scale; anim.SetBool("onladder", true); plygrab.Drop(); } } }
public void Resize(int newX, int newY) { width = newX; height = newY; layerGroups.ForEach((LayerGroup l) => l.Resize(newX, newY)); Ladder[,] newLadders = new Ladder[newX, newY]; int oldX = ladders.GetLength(0); int oldY = ladders.GetLength(1); for (int i = 0; i < newX && i < oldX; ++i) { for (int j = 0; j < newY && j < oldY; ++j) { newLadders[i, j] = ladders[i, j]; } } ladders = newLadders; }
/// <summary> /// Dismount the specified Ladder. This is used to stop /// autosticking to the same ladder you just dismounted. /// </summary> /// <param name="ladder">Ladder control to dismount.</param> public void Dismount(Ladder ladder) { Unparent (); dismounting = ladder.control; startedClimbing = false; }
private bool ClimbCheck() { Vector2 ladderCheckPointTop = new Vector2(capsuleCollider2D.bounds.center.x, capsuleCollider2D.bounds.center.y + capsuleCollider2D.size.y); Vector2 ladderCheckPointBottom = new Vector2(capsuleCollider2D.bounds.center.x, capsuleCollider2D.bounds.center.y - capsuleCollider2D.size.y); Collider2D[] ladderCheckTop = Physics2D.OverlapBoxAll(ladderCheckPointTop, new Vector2(capsuleCollider2D.size.x, 0.1f), 0, whatIsLadder); Collider2D[] ladderCheckBottom = Physics2D.OverlapBoxAll(ladderCheckPointBottom, new Vector2(capsuleCollider2D.size.x, 0.1f), 0, whatIsLadder); if (ladderCheckTop.Length > 0 && ladderCheckBottom.Length > 0) //梯子中 { crrentLadder = ladderCheckTop[0].GetComponent <Ladder>(); if (isClimb) //已經在爬 { return(true); } else { return((moveVector.y != 0) ? true : false); } } else if (ladderCheckTop.Length > 0) //梯子在上 { crrentLadder = ladderCheckTop[0].GetComponent <Ladder>(); if (isClimb) //已經在爬 { return((isGround) ? false : true); } else { if (moveVector.y > 0) { transform.position = new Vector2(transform.position.x, transform.position.y + groundCheckLegth * 2); //避免往上爬 馬上判斷為地面直接墜落 return(true); } else { return(false); } } } else if (ladderCheckBottom.Length > 0) //梯子在下 { crrentLadder = ladderCheckBottom[0].GetComponent <Ladder>(); if (isClimb) //已經在爬 { if (isGround) { transform.position = new Vector2(transform.position.x, transform.position.y + groundCheckLegth * 2); //避免往上爬離開梯子EffectorCollider太慢 人物穿過collider直接墜落 return(false); } else { return(true); } } else { if (moveVector.y < 0) { transform.position = new Vector2(transform.position.x, transform.position.y - groundCheckLegth * 2); //避免往下爬 馬上判斷為地面直接墜落 return(true); } else { return(false); } } } else { return(false); } }
protected IEnumerator UseLadder(Ladder ladder, int direction) { if (currentDungeonLevel == 0 && direction == -1) { print ("The door to the outside world is sealed..."); yield break; } // fade out StartCoroutine(Navigator.instance.FadeOut(0.5f)); float x = this.x, y = this.y; if (direction == -1) { y += 0.75f; } else { img.sortingOrder = grid.height - this.y - 10; y -= 1.5f; } float ratio = grid.tileHeight / (float)grid.tileWidth; Vector3 startPos = new Vector3(this.x, 0.4f + this.y * ratio, 0); Vector3 endPos = new Vector3(x, 0.4f + y * ratio, 0); float duration = 0.5f; float t = 0f; while (t <= 1f) { t += Time.deltaTime / duration; transform.localPosition = Vector3.Lerp(startPos, endPos, Mathf.SmoothStep(0, 1, Mathf.SmoothStep(0f, 1f, t))); yield return null; } // emit onExitLevel game event if (OnExitLevel != null) { OnExitLevel.Invoke(direction); } }
void ExitLadder() { OnLadder = false; onLadderObject = null; anim.SetBool("onladder", false); }
void UnlatchLadder() { currentLadder = null; moveController.OffLadder(ladderMovement); }
public void OnCanClimbChanged(bool canClimb, Ladder ladder) { this.canClimb = canClimb; this.ladder = ladder; }
private Vector2 DiffToCurrentNode() { if (currentPath == null || currentPath.Unreachable) { return(Vector2.Zero); } if (currentPath.Finished) { Vector2 pos2 = host.SimPosition; if (character != null && character.Submarine == null && CurrentPath.Nodes.Count > 0 && CurrentPath.Nodes.Last().Submarine != null) { pos2 -= CurrentPath.Nodes.Last().Submarine.SimPosition; } return(currentTarget - pos2); } if (canOpenDoors && !character.LockHands && buttonPressCooldown <= 0.0f) { CheckDoorsInPath(); } Vector2 pos = host.SimPosition; if (character != null && currentPath.CurrentNode != null) { if (CurrentPath.CurrentNode.Submarine != null) { if (character.Submarine == null) { pos -= CurrentPath.CurrentNode.Submarine.SimPosition; } else if (character.Submarine != currentPath.CurrentNode.Submarine) { pos -= ConvertUnits.ToSimUnits(currentPath.CurrentNode.Submarine.Position - character.Submarine.Position); } } } bool isDiving = character.AnimController.InWater && character.AnimController.HeadInWater; // Only humanoids can climb ladders bool canClimb = character.AnimController is HumanoidAnimController; if (canClimb && !isDiving && IsNextLadderSameAsCurrent) { var ladders = currentPath.CurrentNode.Ladders; if (character.SelectedConstruction != ladders.Item && ladders.Item.IsInsideTrigger(character.WorldPosition)) { currentPath.CurrentNode.Ladders.Item.TryInteract(character, false, true); } } var collider = character.AnimController.Collider; if (character.IsClimbing && !isDiving) { Vector2 diff = currentPath.CurrentNode.SimPosition - pos; Ladder nextLadder = GetNextLadder(); bool nextLadderSameAsCurrent = IsNextLadderSameAsCurrent; if (nextLadderSameAsCurrent) { //climbing ladders -> don't move horizontally diff.X = 0.0f; } //at the same height as the waypoint if (Math.Abs(collider.SimPosition.Y - currentPath.CurrentNode.SimPosition.Y) < (collider.height / 2 + collider.radius) * 1.25f) { float heightFromFloor = character.AnimController.GetColliderBottom().Y - character.AnimController.FloorY; if (heightFromFloor <= 0.0f) { diff.Y = Math.Max(diff.Y, 1.0f); } // We need some margin, because if a hatch has closed, it's possible that the height from floor is slightly negative. float margin = 0.1f; bool isAboveFloor = heightFromFloor > -margin && heightFromFloor < collider.height * 1.5f; // If the next waypoint is horizontally far, we don't want to keep holding the ladders if (isAboveFloor && (nextLadder == null || Math.Abs(currentPath.CurrentNode.WorldPosition.X - currentPath.NextNode.WorldPosition.X) > 50)) { character.AnimController.Anim = AnimController.Animation.None; character.SelectedConstruction = null; } else if (nextLadder != null && !nextLadderSameAsCurrent) { // Try to change the ladder (hatches between two submarines) if (character.SelectedConstruction != nextLadder.Item && nextLadder.Item.IsInsideTrigger(character.WorldPosition)) { nextLadder.Item.TryInteract(character, false, true); } } if (nextLadder != null || isAboveFloor) { currentPath.SkipToNextNode(); } } else if (nextLadder != null) { //if the current node is below the character and the next one is above (or vice versa) //and both are on ladders, we can skip directly to the next one //e.g. no point in going down to reach the starting point of a path when we could go directly to the one above if (Math.Sign(currentPath.CurrentNode.WorldPosition.Y - character.WorldPosition.Y) != Math.Sign(currentPath.NextNode.WorldPosition.Y - character.WorldPosition.Y)) { currentPath.SkipToNextNode(); } } return(diff); } else if (!canClimb || character.AnimController.InWater) { // If the character is underwater, we don't need the ladders anymore if (character.IsClimbing && isDiving) { character.AnimController.Anim = AnimController.Animation.None; character.SelectedConstruction = null; } var door = currentPath.CurrentNode.ConnectedDoor; bool blockedByDoor = door != null && !door.IsOpen && !door.IsBroken; if (!blockedByDoor) { float multiplier = MathHelper.Lerp(1, 10, MathHelper.Clamp(collider.LinearVelocity.Length() / 10, 0, 1)); float targetDistance = collider.GetSize().X *multiplier; float horizontalDistance = Math.Abs(character.WorldPosition.X - currentPath.CurrentNode.WorldPosition.X); float verticalDistance = Math.Abs(character.WorldPosition.Y - currentPath.CurrentNode.WorldPosition.Y); if (character.CurrentHull != currentPath.CurrentNode.CurrentHull) { verticalDistance *= 2; } float distance = horizontalDistance + verticalDistance; if (ConvertUnits.ToSimUnits(distance) < targetDistance) { currentPath.SkipToNextNode(); } } } else if (!IsNextLadderSameAsCurrent) { // Walking horizontally Vector2 colliderBottom = character.AnimController.GetColliderBottom(); Vector2 colliderSize = collider.GetSize(); Vector2 velocity = collider.LinearVelocity; // If the character is smaller than this, it would fail to use the waypoint nodes because they are always too high. float minHeight = 1; // Cannot use the head position, because not all characters have head or it can be below the total height of the character float characterHeight = Math.Max(colliderSize.Y + character.AnimController.ColliderHeightFromFloor, minHeight); float horizontalDistance = Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X); bool isAboveFeet = currentPath.CurrentNode.SimPosition.Y > colliderBottom.Y; bool isNotTooHigh = currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y + characterHeight; var door = currentPath.CurrentNode.ConnectedDoor; bool blockedByDoor = door != null && !door.IsOpen && !door.IsBroken; float margin = MathHelper.Lerp(1, 10, MathHelper.Clamp(Math.Abs(velocity.X) / 10, 0, 1)); float targetDistance = collider.radius * margin; if (horizontalDistance < targetDistance && isAboveFeet && isNotTooHigh && !blockedByDoor) { currentPath.SkipToNextNode(); } } if (currentPath.CurrentNode == null) { return(Vector2.Zero); } return(currentPath.CurrentNode.SimPosition - pos); }
public void OnEnterLadder(Ladder ladder) { _countLadder++; Debug.Log("_countladder " + _countLadder); _isOnLadder = _countLadder > 0; if (_isOnLadder) { //_isOnLadder = true; animator.SetBool("On_Ladder", _isOnLadder); rb2d.isKinematic = true; float ladderMiddleX = ladder.transform.position.x; transform.position = new Vector3(ladderMiddleX, transform.position.y, transform.position.z); grounded = true; } }
private void LadderCheck(Vector3 colliderScale, Vector3 direction) { if (_surfer.moveData.velocity.sqrMagnitude <= 0f) { return; } bool foundLadder = false; RaycastHit [] hits = Physics.BoxCastAll(_surfer.moveData.origin, Vector3.Scale(_surfer.collider.bounds.size * 0.5f, colliderScale), Vector3.Scale(direction, new Vector3(1f, 0f, 1f)), Quaternion.identity, direction.magnitude, SurfPhysics.groundLayerMask, QueryTriggerInteraction.Collide); foreach (RaycastHit hit in hits) { Ladder ladder = hit.transform.GetComponentInParent <Ladder> (); if (ladder != null) { bool allowClimb = true; float ladderAngle = Vector3.Angle(Vector3.up, hit.normal); if (_surfer.moveData.angledLaddersEnabled) { if (hit.normal.y < 0f) { allowClimb = false; } else { if (ladderAngle <= _surfer.moveData.slopeLimit) { allowClimb = false; } } } else if (hit.normal.y != 0f) { allowClimb = false; } if (allowClimb) { foundLadder = true; if (_surfer.moveData.climbingLadder == false) { _surfer.moveData.climbingLadder = true; _surfer.moveData.ladderNormal = hit.normal; _surfer.moveData.ladderDirection = -hit.normal * direction.magnitude * 2f; if (_surfer.moveData.angledLaddersEnabled) { Vector3 sideDir = hit.normal; sideDir.y = 0f; sideDir = Quaternion.AngleAxis(-90f, Vector3.up) * sideDir; _surfer.moveData.ladderClimbDir = Quaternion.AngleAxis(90f, sideDir) * hit.normal; _surfer.moveData.ladderClimbDir *= 1f / _surfer.moveData.ladderClimbDir.y; // Make sure Y is always 1 } else { _surfer.moveData.ladderClimbDir = Vector3.up; } } } } } if (!foundLadder) { _surfer.moveData.ladderNormal = Vector3.zero; _surfer.moveData.ladderVelocity = Vector3.zero; _surfer.moveData.climbingLadder = false; _surfer.moveData.ladderClimbDir = Vector3.up; } }
public LadderGameStartedEvent(Ladder ladder, Game game) : base(game) { this.Ladder = ladder; }
public LadderGump(Ladder ladder, int page = 0) : base(50, 50) { m_Ladder = ladder; m_Page = page; AddPage(0); m_List = new List <LadderEntry>(ladder.Entries); var lc = Math.Min(m_List.Count, 150); var start = page * 15; var end = start + 15; if (end > lc) { end = lc; } var ct = end - start; var height = 12 + 20 + ct * 20 + 23 + 12; AddBackground(0, 0, 499, height, 0x2436); for (var i = start + 1; i < end; i += 2) { AddImageTiled(12, 32 + (i - start) * 20, 475, 20, 0x2430); } AddAlphaRegion(10, 10, 479, height - 20); if (page > 0) { AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1); } else { AddImage(446, height - 12 - 2 - 16, 0x2626); } if ((page + 1) * 15 < lc) { AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2); } else { AddImage(466, height - 12 - 2 - 16, 0x2622); } AddHtml( 16, height - 12 - 2 - 18, 400, 20, Color( string.Format("Top {3} of {0:N0} duelists, page {1} of {2}", m_List.Count, page + 1, (lc + 14) / 15, lc), 0xFFC000 ) ); AddColumnHeader(75, "Rank"); AddColumnHeader(115, "Level"); AddColumnHeader(50, "Guild"); AddColumnHeader(115, "Name"); AddColumnHeader(60, "Wins"); AddColumnHeader(60, "Losses"); for (var i = start; i < end && i < lc; ++i) { var entry = m_List[i]; var y = 32 + (i - start) * 20; var x = 12; AddBorderedText(x, y, 75, Center(Rank(i + 1)), 0xFFFFFF, 0); x += 75; /*AddImage( 20, y + 5, 0x2616, 0x96C ); * AddImage( 22, y + 5, 0x2616, 0x96C ); * AddImage( 20, y + 7, 0x2616, 0x96C ); * AddImage( 22, y + 7, 0x2616, 0x96C ); * * AddImage( 21, y + 6, 0x2616, 0x454 );*/ AddImage(x + 3, y + 4, 0x805); var xp = entry.Experience; var level = Ladder.GetLevel(xp); Ladder.GetLevelInfo(level, out var xpBase, out var xpAdvance); int width; var xpOffset = xp - xpBase; if (xpOffset >= xpAdvance) { width = 109; // level 50 } else { width = (109 * xpOffset + xpAdvance / 2) / (xpAdvance - 1); } // AddImageTiled( 21, y + 6, width, 8, 0x2617 ); AddImageTiled(x + 3, y + 4, width, 11, 0x806); AddBorderedText(x, y, 115, Center(level.ToString()), 0xFFFFFF, 0); x += 115; var mob = entry.Mobile; if (mob.Guild != null) { AddBorderedText(x, y, 50, Center(mob.Guild.Abbreviation), 0xFFFFFF, 0); } x += 50; AddBorderedText(x + 5, y, 115 - 5, mob.Name, 0xFFFFFF, 0); x += 115; AddBorderedText(x, y, 60, Center(entry.Wins.ToString()), 0xFFFFFF, 0); x += 60; AddBorderedText(x, y, 60, Center(entry.Losses.ToString()), 0xFFFFFF, 0); x += 60; // AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 ); } }