public Agent(Glider glider) { this.Lda = glider.getLda(); this.Mde = glider.getMde(); this.Ndr = glider.getNdr(); this.glider = glider; }
private bool collideOrOffscreenCheck(Level level, Glider jellyfish) { return(jellyfish.Position.X + jellyfish.Collider.Right > level.Bounds.Right || jellyfish.Position.X + jellyfish.Collider.Left < level.Bounds.Left || jellyfish.Position.Y + jellyfish.Collider.Top < level.Bounds.Top || Collide.Check(jellyfish, level.Tracker.Entities[typeof(Solid)])); }
void Start() { winScreen.enabled = false; gliders = new GameObject[numAI + 1]; Glider glider = GameObject.Instantiate(gliderPrefab, start.position - start.forward * 20, start.rotation).GetComponent <Glider>(); glider.setAgent(new PlayerAgent(glider)); //glider.transform.Find("Main Camera").gameObject.SetActive(true); GameObject cam = GameObject.Instantiate(camPrefab, glider.transform.position, glider.transform.rotation); cam.GetComponent <CameraControl>().target = glider.transform; glider.indicator = indicator; glider.setRaceStats(SelectedRaceParameters.wingspan, SelectedRaceParameters.dragMultiplier, SelectedRaceParameters.mass, SelectedRaceParameters.controlAuthority); glider.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePosition; gliders[0] = glider.gameObject; float aiMinSpan = Mathf.Max(SelectedRaceParameters.wingspan, RaceStatsCalculator.MIN_WINGSPAN); float aiMaxSpan = Mathf.Min(SelectedRaceParameters.wingspan, RaceStatsCalculator.MAX_WINGSPAN); float aiMinDrag = Mathf.Max(SelectedRaceParameters.wingspan, RaceStatsCalculator.MIN_DRAG_MULT); float aiMaxDrag = Mathf.Min(SelectedRaceParameters.wingspan, RaceStatsCalculator.MAX_DRAG_MULT); float aiMinMass = Mathf.Max(SelectedRaceParameters.wingspan, RaceStatsCalculator.MIN_MASS); float aiMaxMass = Mathf.Min(SelectedRaceParameters.wingspan, RaceStatsCalculator.MAX_MASS); float aiMinCtrl = Mathf.Max(SelectedRaceParameters.wingspan, RaceStatsCalculator.MIN_AUTHORITY); float aiMaxCtrl = Mathf.Min(SelectedRaceParameters.wingspan, RaceStatsCalculator.MAX_AUTHORITY); for (int i = 0; i < numAI; i++) { glider = GameObject.Instantiate(gliderPrefab, start.position + start.right * (i + 1) * 3, start.rotation).GetComponent <Glider>(); glider.setAgent(new AIAgent(glider, goal.position)); glider.setRaceStats(Random.Range(aiMinSpan, aiMaxSpan), Random.Range(aiMinDrag, aiMaxDrag), Random.Range(aiMinMass, aiMaxMass), Random.Range(aiMinCtrl, aiMaxCtrl)); glider.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePosition; gliders[i + 1] = glider.gameObject; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); easingList = FindViewById <ListView> (Resource.Id.easing_list); adapter = new EasingAdapter(this); easingList.Adapter = adapter; target = FindViewById(Resource.Id.target); history = FindViewById <DrawView> (Resource.Id.history); easingList.ItemClick += (sender, e) => { history.Clear(); var s = (Skill)e.View.Tag; var set = new AnimatorSet(); target.TranslationX = 0; target.TranslationY = 0; set.PlayTogether( Glider.Glide(s, 1200, ObjectAnimator.OfFloat(target, "translationY", 0, DrawView.DipToPixels(this, -(160 - 3))), args => { history.DrawPoint(args.Time, args.Duration, args.Value - DrawView.DipToPixels(this, 60)); })); set.SetDuration(1200); set.Start(); }; }
private void OnHoldable(Holdable h) { bool flag = h.HitSpring(this); if (flag) { BounceAnimate(); TryBreak(); if (h.Entity is Glider) { Glider glider = h.Entity as Glider; if (Orientation == Orientations.Floor) { glider.Speed.Y *= speedMult.Y; } else { glider.Speed *= speedMult; } } else if (h.Entity is TheoCrystal) { TheoCrystal theo = h.Entity as TheoCrystal;//.Speed = theoSpeed; if (Orientation == Orientations.Floor) { theo.Speed.Y *= speedMult.Y; } else { theo.Speed *= speedMult; } } } }
public void Glider_Added(On.Celeste.Glider.orig_Added orig, Glider self, Monocle.Scene scene) { if (Settings.Enabled) { DynData <Glider> gliderData = new DynData <Glider>(self); gliderData["fresh"] = true; } orig(self, scene); }
void UnconstrainFromSource(GameObject obj) { Destroy(obj.GetComponent <FixedJoint>()); Glider glider = obj.GetComponent <Glider>(); if (glider != null) { glider.flying = true; } }
public void SpawnGlider() { GameObject newGlider; newGlider = Instantiate(gliderPrefab); newGlider.transform.SetParent(gameObject.transform); CurrentGlider = newGlider.GetComponent <Glider>(); newGlider.active = true; isGliderReady = true; }
private static void RecreateDuplicateGlider(Entity loadedEntity, List <Entity> savedDuplicateIdList) { if (loadedEntity.IsType <Glider>() && savedDuplicateIdList.FirstOrDefault(entity => entity.IsType <Glider>()) is Glider savedGlider) { if (savedGlider.GetEntityData() != null) { Glider newGlider = new Glider(savedGlider.GetEntityData(), Vector2.Zero); newGlider.CopyEntityData(savedGlider); newGlider.CopyEntityId2(savedGlider); newGlider.CopyAllFrom(savedGlider); loadedEntity.SceneAs <Level>().Add(newGlider); } } }
public void OnDeathPower(bool value) { if (value && !inOptions) { if (hasControls) { if (player.velocity.magnitude * 2f > deathMinSpeed) { if (player.isKinematic) { player.isKinematic = false; } swapper.SwapToDeath(); isDeathPowerInUse = true; ActivateTrail(3, true); GetComponent <ElementalMovementController>().setPowerInUse(3, true); GameObject FX = Instantiate(deathFirstPower); FX.transform.position = transform.position; FX.transform.localScale = Vector3.one * 2f; Destroy(FX, 5f); GameObject FX2 = Instantiate(deathSecondPower); FX2.transform.position = transform.position; Destroy(FX2, 5f); emotions.PowerUp(); shoutHandler.PlayAudio(true); SlowTime(); BlackAndWhite(0.1f); Glider leaf = follower.GetComponentInChildren <Glider>(); if (leaf != null) { StopEarthPower(); } } } } else if (!value && !inOptions && isDeathPowerInUse) { StopDeathPower(); } }
public void StopEarthPower() { //EndEarthSpiderClimb(); isEarthPowerInUse = false; ActivateTrail(2, false); GetComponent <ElementalMovementController>().setPowerInUse(2, false); Glider leaf = follower.GetComponentInChildren <Glider>(); if (leaf != null) { Destroy(leaf.transform.parent.gameObject, 0f); swapper.SwapToFire(); } }
public void Glider_OnPickup(On.Celeste.Glider.orig_OnPickup orig, Glider self) { if (Settings.Enabled) { if (Settings.Week == 2 && (self.Scene as Level).Session.Area.SID == "Celeste/LostLevels") { DynData <Glider> gliderData = new DynData <Glider>(self); if (gliderData.Get <bool>("fresh") != false) { Session.Jellies.Add(self.Position); gliderData["fresh"] = false; } } } orig(self); }
public void OnEarthPower(bool value) { if (value && !inOptions) { if (hasControls) { //Earth //No idea if (ActualSave.actualSave.earthSecondUnlocked && ActualSave.actualSave.stats[playerNb].powerTime[2][0] > 0f) { if (player.isKinematic) { player.isKinematic = false; } swapper.SwapToEarth(); shoutHandler.PlayAudio(true); emotions.PowerUp(); isEarthPowerInUse = true; ActivateTrail(2, true); GetComponent <ElementalMovementController>().setPowerInUse(2, true); GameObject leaf = Instantiate(earthSecondPower, follower.transform); if (nextPowerEmptiesAll) { EmptyPower(); } /*Invoke("EarthSpiderClimb", 0.21f); * this.enabled = false; * player.isKinematic = true; * Transform tsf = transform.parent.GetComponent<swapCharacter>().playerFollower.transform; * transform.LeanMoveLocal(tsf.localPosition + tsf.up * 0.2f, 0.2f); * transform.LookAt(faceCamera.transform.position, Vector3.up);*/ } } } else if (!value && !inOptions) { Glider leaf = follower.GetComponentInChildren <Glider>(); if (leaf != null) { StopEarthPower(); } } }
void OnTriggerEnter(Collider other) { Debug.Log("colliding"); Glider g = other.gameObject.GetComponent <Glider>(); if (g != null) { if (g.getAgent() is PlayerAgent) { Debug.Log("Player reaches end"); raceControl.endRace(true); //SceneManager.LoadScene("Raise"); } else { Debug.Log("Player loses"); raceControl.endRace(false); } } }
//--------------------- On Space or A Button -------------------------------- public void OnIcePower(bool value) { if (value && !inOptions) { if (hasControls) { if (ActualSave.actualSave.iceUnlocked && ActualSave.actualSave.stats[playerNb].powerTime[1][0] > 0f) { if (player.isKinematic) { player.isKinematic = false; } swapper.SwapToIce(); isIcePowerInUse = true; GetComponent <ElementalMovementController>().setPowerInUse(1, true); ActivateTrail(1, true); //Ice //Ice platform generation //We make sure that when the power gauge reaches 0, the player cannot use the power anymore shoutHandler.PlayAudio(true); //invokingTime = 15; //InvokeIce(); Glider leaf = follower.GetComponentInChildren <Glider>(); if (leaf != null) { StopEarthPower(); } } } } else if (!value && !inOptions) { StopIcePower(); } }
private static void Main() { var blinker = new Blinker(); for (int i = 0; i < 3; i++) { blinker.Print(new Cell(-1, -2), new Cell(4, 4)); blinker.Step(); } var glider = new Glider(); for (int i = 0; i < 3; i++) { var top = glider.Top; var left = glider.Left; var bottom = glider.Bottom; var right = glider.Right; glider.Print(new Cell(left - 1, top - 1), new Cell(right - left + 2, bottom - top + 2)); glider.Step(); } }
public override void applySpecificEffect(Glider glider) { }
internal static void Has_unlock_items(this Glider actual) => Assert.NotNull(actual.UnlockItems);
//Applies all effects of the hinderance or boost public void applyAllEffects(Glider glider) { Debug.Log("Collision"); applyGeneralEffect(glider); applySpecificEffect(glider); }
//Applies effects of that specific hinderance or boost public abstract void applySpecificEffect(Glider glider);
public override void applySpecificEffect(Glider glider) { Rigidbody rb = glider.GetComponent <Rigidbody>(); rb.velocity *= Vulture.BOOST_STRENGTH; }
public override void applyGeneralEffect(Glider glider) { //TODO: Do general boost things here //Luckily, destory waits until after the current update loop, so applySpecificEffect will still execute Destroy(this.gameObject); }
public override void applyGeneralEffect(Glider glider) { //TODO: Do general hinderance things here }
public void boost(Glider glider) { Rigidbody rb = glider.GetComponent <Rigidbody>(); rb.velocity = rb.velocity + new Vector3(0, 1000 * Time.deltaTime, 0); }
internal static void Has_id(this Glider actual) => Assert.True(actual.Id > 0);
public void SpawnGlider() { SpawnTemplate template = new Glider(new GameCell(0, 0)); Assert.AreEqual(5, template.LivingCells.Count); }
public PlayerAgent(Glider glider) : base(glider) { }
//Applies effects common to all hinderances or boosts public abstract void applyGeneralEffect(Glider glider);
//--------------------- On Space or A Button -------------------------------- public void OnFirePower(bool value) { if (value && !inOptions) { if (hasControls) { if (CanInteract) { StartDialogue(); return; } if (ActualSave.actualSave.fireUnlocked && ActualSave.actualSave.stats[playerNb].powerTime[0][0] >= ActualSave.actualSave.stats[playerNb].maxPowerTime[0][0]) { isFirePowerInUse = true; if (player.isKinematic) { player.isKinematic = false; } swapper.SwapToFire(); //Fire //Upward propulsion emotions.PowerUp(); shoutHandler.PlayAudio(true); if (player.velocity.y < 0) { player.velocity = new Vector3(player.velocity.x, 0, player.velocity.z); } float modifier = 1f; Vector3 direction = Vector3.up; ApplyForce(direction * Character.getCharacterInfo(ActualSave.actualSave.stats[playerNb].activePlayer).jumpForce *modifier / (Time.timeScale * (1 + player.velocity.magnitude / 90f))); rumble(0.1f, 0.8f); GameObject instantiatedBoom = Instantiate(fireFirstPower); instantiatedBoom.transform.localScale = Vector3.one * 0.5f; instantiatedBoom.transform.position = this.transform.position; Destroy(instantiatedBoom, 2f); GetComponent <ElementalMovementController>().setPowerInUse(0, true); ActualSave.actualSave.stats[playerNb].powerTime[0][0] = 0f; Glider leaf = follower.GetComponentInChildren <Glider>(); if (leaf != null) { StopEarthPower(); } } } } else { if (!value && !inOptions) { GetComponent <ElementalMovementController>().setPowerInUse(0, false); if (isFireGrinding) { GameObject instantiatedBoom = Instantiate(fireFirstPower); instantiatedBoom.transform.position = this.transform.position; Destroy(instantiatedBoom, 2f); player.velocity = player.velocity + player.velocity.normalized * Mathf.Min(timeSincePowerStart * 1f, 10f) * 1.5f; GetComponent <ElementalMovementController>().SetLastVelocity(player.velocity + player.velocity.normalized * Mathf.Min(timeSincePowerStart * 1f, 10f) * 1f); GetComponent <ElementalViewController>().EndDrift(); } isFirePowerInUse = false; isFireGrinding = false; ActivateTrail(0, false); timeSincePowerStart = 0f; } } }
private void addJellyfishToLevel(Level level) { for (int i = 0; i < Settings.JellyfishEverywhere; i++) { Player player = level.Tracker.GetEntity <Player>(); if (player != null && player.Holding?.Entity?.GetType() != typeof(Glider)) { // player is here, and is not holding jellyfish. // spawn a jellyfish near them. Vector2 playerPosition = player.Position; Glider jellyfish = new Glider(playerPosition, true, false); // offset the jellyfish if there are multiple if (Settings.JellyfishEverywhere == 2) { if (i == 0) { jellyfish.Position.X -= 10; } else { jellyfish.Position.X += 10; } } else if (Settings.JellyfishEverywhere == 3) { if (i == 1) { jellyfish.Position.X -= 20; } else if (i == 2) { jellyfish.Position.X += 20; } } // move it up 20px jellyfish.Position.Y -= 20; if (collideOrOffscreenCheck(level, jellyfish)) { // ... 20px right then? jellyfish.Position.Y += 20; jellyfish.Position.X += 20; if (collideOrOffscreenCheck(level, jellyfish)) { // okay, let's try 20px left jellyfish.Position.X -= 40; if (collideOrOffscreenCheck(level, jellyfish)) { // still not good? last try: 20px below jellyfish.Position.X += 20; jellyfish.Position.Y += 20; } } } if (collideOrOffscreenCheck(level, jellyfish)) { Logger.Log(LogLevel.Warn, "ExtendedVariantMode/JellyfishEverywhere", "Could not find a position to spawn that jellyfish!"); } else { // spawn that jellyfish then // (we spawn a new one because we want its startPos to be the right one.) level.Add(new Glider(jellyfish.Position, true, false)); level.Entities.UpdateLists(); } } } }