/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Platformer game = new Platformer()) { game.Run(); } }
void Awake() { eventPlayer = GetComponent <EventPlayer>(); eventPlayer.AddParameters(new CustomParameter[] { new CustomParameter("Agitated", false), }); ragdollController = GetComponent <RagdollController>(); movement = GetComponent <MovementController>(); turner = GetComponent <Turner>(); //jumper = GetComponent<Jumper>(); platformer = GetComponent <Platformer>(); combat = GetComponent <CharacterCombat>(); charAnimationMover = GetComponent <CharacterAnimatorMover>(); characterMovement = GetComponent <CharacterMovement>(); turner.doAutoTurn = true; cam = Camera.main; combat.SetAimTargetCallback(() => cam.transform.position + cam.transform.forward * 500); turner.SetTurnTargetCallback(() => CalculateFaceDir()); }
//should player come in contact to win condition game is over and win scene is shown private void OnTriggerEnter2D(Collider2D collision) { Platformer player = collision.GetComponent <Platformer>(); if (player != null) { player.Victory(); } }
void BuildPlatformUpLinks() { Transform linkHolder = new GameObject("PlatFormUpLinks").transform; // get all static colliders that arent floor colliders (so we dont build platforms inside of geometry) Collider[] cols = GameObject.FindObjectsOfType <Collider>().Where(c => c.gameObject.isStatic && !groundCols.Contains(c)).ToArray(); //make the templates GameObject shortPlatformUpLinkPrefab = CreatePlatformLink(true, "ShortPlatformUpLink"); GameObject tallPlatformUpLinkPrefab = CreatePlatformLink(false, "TallPlatformUpLink"); // get all the navmesh borders, and split them evenly by maxEdgeSize HashSet <LineSegment> bordersSegmented = LineSegment.SplitSegments(NavigationManager.FindNavMeshBorders(), maxEdgeSize); foreach (var b in bordersSegmented) { // check if we're inside static geometry bool isInCol = false; for (int i = 0; i < cols.Length; i++) { if (cols[i].bounds.Contains(b.midPoint)) { isInCol = true; break; } } if (isInCol) { continue; } bool isShort; Vector3 position; Quaternion rotation; if (Platformer.CheckForPlatformUp(b.midPoint, b.normal, 1.0f, layerMask, out isShort, out position, out rotation)) { GameObject link = MonoBehaviour.Instantiate(isShort ? shortPlatformUpLinkPrefab : tallPlatformUpLinkPrefab, position, rotation); OffMeshLink linC = link.GetComponent <OffMeshLink>(); // if the other end of our generated link isnt on the navmesh, delete it if (!NavMesh.SamplePosition(linC.endTransform.position, out _, .01f, NavMesh.AllAreas)) { MonoBehaviour.DestroyImmediate(link); } else { link.transform.SetParent(linkHolder); } } } //delete the templates MonoBehaviour.DestroyImmediate(shortPlatformUpLinkPrefab); MonoBehaviour.DestroyImmediate(tallPlatformUpLinkPrefab); }
public void TestSmall(Func <int, int, Platformer> build) { Platformer platformer = build(6, 3); Debug.Assert(platformer.Position() == 3); platformer.JumpLeft(); Debug.Assert(platformer.Position() == 1); platformer.JumpRight(); Debug.Assert(platformer.Position() == 4); }
/* * makes platforms not try and double back if the jump overshoots the intended path corner */ void TriggerEndWaypointAfterPlatformChange(Vector3 myPos) { Vector3 nextWaypoint = path[currentPathCorner]; float triggerRadius = aiAgent.aiBehavior.platformEndWaypointTriggerRadius * aiAgent.aiBehavior.platformEndWaypointTriggerRadius; //if we're within trigger end radius, if (Vector3.SqrMagnitude(nextWaypoint - myPos) < triggerRadius) { //and the next target path corner is on our 'platform level' if (Platformer.SamePlatformLevels(myPos, nextWaypoint)) { //manually trigger waypoint arrival, // Debug.LogError("manually triggered after platform"); waypointTracker.ManuallyTriggerWaypointArrival(false);//"platform change"); } } }
public void TestLarge(Func <int, int, Platformer> build) { Console.WriteLine("Running large test..."); const int tiles = int.MaxValue / 2; const int center = tiles / 2; Platformer platformer = build(tiles, center + 3); Debug.Assert(platformer.Position() == center + 3); var watch = Stopwatch.StartNew(); platformer.JumpLeft(); Debug.Assert(platformer.Position() == center + 1); platformer.JumpRight(); Debug.Assert(platformer.Position() == center + 4); platformer.JumpRight(); Debug.Assert(platformer.Position() == center + 6); platformer.JumpRight(); Debug.Assert(platformer.Position() == center + 8); platformer.JumpLeft(); Debug.Assert(platformer.Position() == center + 5); platformer.JumpLeft(); Debug.Assert(platformer.Position() == center + 0); platformer.JumpRight(); Debug.Assert(platformer.Position() == center + 7); platformer.JumpRight(); Debug.Assert(platformer.Position() == center + 10); platformer.JumpRight(); Debug.Assert(platformer.Position() == center + 12); platformer.JumpLeft(); Debug.Assert(platformer.Position() == center + 9); Console.WriteLine($"{platformer.GetType().Name} completes in {watch.ElapsedMilliseconds} ms"); }
protected override void Awake() { base.Awake(); aiAgent = GetComponent <AIAgent>(); waypointTracker = GetComponent <WaypointTracker>(); platformer = GetComponent <Platformer>(); platformer.onPlatformEnd += OnPlatformEnd; agent = GetComponentInChildren <NavMeshAgent>(); agent.updateRotation = false; agent.updatePosition = false; turner = GetComponent <Turner>(); animationMover = GetComponent <CharacterAnimatorMover>(); animationMover.SetMoveModifier(ModifyCharacterMovement); }
static void Main(string[] args) { // P E T S var biscuit = new Cat() { Name = "Biscuit", PetType = PetType.Cat, YearsOld = 2, IsChonky = true, IsIndoorCat = true }; var basil = new Dog() { Name = "Basil", PetType = PetType.Dog, YearsOld = 3, IsChonky = true, Breed = "Puggle" }; var rocky = new Rock() { Name = "Rocky", PetType = PetType.Rock, YearsOld = 1000, IsChonky = false }; biscuit.SlowlyPushSomethingOffOfTheTable(); biscuit.Hunt("toy mouse"); basil.Talk(); basil.Fetch(); rocky.Nothing(); // B U R R I T O S var beanAndCheeseBurrito = new Bean_Burrito() { BurritoType = BurritoType.Bean, Vegetarian = true, PercentBeans = 90 }; var baconEggAndCheeseBurrito = new Breakfast_Burrito() { BurritoType = BurritoType.Breakfast, Vegetarian = false, ContainsBacon = true }; var sushiBurrito = new Sushi_Burrito() { BurritoType = BurritoType.Sushi, Vegetarian = false }; beanAndCheeseBurrito.OfferToVegetarianFriend(); baconEggAndCheeseBurrito.GetConsumed(); beanAndCheeseBurrito.GetWrapped(); baconEggAndCheeseBurrito.ScrambleEggs(); sushiBurrito.Contemplate(); // A L B U M S var moonSafari = new Cassette_Tape() { Title = "Moon Safari", Genre = "Electronica/Dance", Artist = "Air", NumberOfTracks = 10, NeedsRewinding = true }; var plasticBeach = new CD() { Title = "Plastic Beach", Genre = "Pop/Electronic/Hip-Hop", Artist = "Gorillaz", NumberOfTracks = 17, IsScratched = false }; var ambient1 = new Vinyl_Record() { Title = "Ambient 1 / Music For Airports", Genre = "Experimental", Artist = "Brian Eno", NumberOfTracks = 4, Weight = 180, Speed = 44 }; moonSafari.Play(); plasticBeach.ListenToTrack11(); moonSafari.Rewind(); plasticBeach.Listen(); ambient1.Spin(); // V I D E O _ G A M E S var celeste = new Platformer() { Genre = "2D Platformer", Title = "Celeste", Platform = Platform.Nintendo_Switch, NumberOfDimensions = 2, Protagonist = "Madeline" }; var gettingOverIt = new Video_Game() { Genre = "Physics/Experimental", Title = "Getting Over It With Bennet Foddy", Platform = Platform.PC }; var overwatch = new FPS() { Genre = "FPS", Title = "Overwatch", Platform = Platform.PC, PlayersPerTeam = 6 }; var mother3 = new RPG() { Genre = "RPG", Title = "Mother 3", Platform = Platform.GBA, IsTurnBased = true }; celeste.Jump(); celeste.RageQuit(); gettingOverIt.Play(); overwatch.Headshot(); mother3.Battle(); Console.ReadLine(); }
// Use this for initialization void Start() { player = transform.parent.gameObject.GetComponent <Platformer> (); }
// Use this for initialization void Start() { player = GameObject.FindGameObjectsWithTag("Player")[0]; playerCollider = player.GetComponent <BoxCollider2D>(); playerScript = player.GetComponent <Platformer>(); beatManager = GameObject.Find("BeatManager"); beatCounter = 0; //Checks to see if the types of platforms can be found and then adds their behaviors accordingly if (platforms != null) { BeatMan.onBeat += platformBehavior; //Changes Platform Color for (int i = 0; i < platforms.Length; i++) { platformSpriteRens[i].color = color1; } for (int i = platforms.Length; i < platformSpriteRens.Length; i++) { platformSpriteRens[i].color = color2; } } if (conPlatformsLeft != null) { BeatMan.endBeat += leftConveyorBehavior; for (int i = 0; i < conPlatformsLeft.Length; i++) { conPlatformsLeft[i].GetComponent <SpriteRenderer>().color = Color.yellow; } } if (conPlatformsRight != null) { BeatMan.endBeat += rightConveyorBehavior; for (int i = 0; i < conPlatformsRight.Length; i++) { conPlatformsRight[i].GetComponent <SpriteRenderer>().color = Color.green; } } if (movPlatformsHor != null) { BeatMan.onBeat += horPlatBehavior; for (int i = 0; i < movPlatformsHor.Length; i++) { movPlatformsHor[i].GetComponent <SpriteRenderer>().color = Color.blue; } } if (movPlatformsVer != null) { BeatMan.onBeat += vertPlatBehavior; for (int i = 0; i < movPlatformsVer.Length; i++) { movPlatformsVer[i].GetComponent <SpriteRenderer>().color = Color.cyan; } } if (spikes != null) { //BeatMan.onBeat += spikeBehavior; for (int i = 0; i < spikes.Length; i++) { spikes[i].GetComponent <SpriteRenderer>().color = Color.red; } } if (fallThroughPlatforms != null) { //BeatMan.onBeat += fallThroughBehavior; Color color = Color.magenta; color.a = 0.1f; //Changes Platform Color for (int i = 0; i < fallThroughPlatforms.Length; i++) { fallThroughPlatforms[i].GetComponent <SpriteRenderer>().color = color; } } BeatMan.startBeat += setPlayerPos; BeatMan.onBeat += beatCount; }
void Awake() { transform = gameObject.transform; this.platformer = target.GetComponent <Platformer>(); }
public Controller(Platformer parent) { this.parent = parent; }
// Use this for initialization void Start() { lists[0] = colList; lists[1] = hardTopList; lists[2] = softTopList; parent = transform.parent.gameObject; pScript = parent.GetComponent<Platformer>(); if (!pScript){ Debug.LogWarning("Your detector box doesn't have a platformer for a parent! WTF!"); } bc = GetComponent<BoxCollider>(); bc.isTrigger = true; }