public static Rayman2.Persos.Alw_Explosion_model CreateExplosion(PersoController spawner, Vector3 pos, float radius = 6) { var expl = (Rayman2.Persos.Alw_Explosion_model)Clone(typeof(Rayman2.Persos.Alw_Explosion_model), out var c, pos, Quaternion.identity, spawner); expl.radius = radius; expl.Explode(); return(expl); }
public void UpdatePersoEnvGroups() { foreach (var p in PersoController.GetPersos(typeof(PersoController))) { foreach (var s in p.sfx.Values) { s.asrc.outputAudioMixerGroup = envGroup; } } }
public PersoController CarryPerso(PersoController persoToHold, int handChannel) { carryPerso = persoToHold; this.handChannel = handChannel; if (carryPerso != null) { carryPerso.SetCollision(false); carryPerso.vel = Vector3.zero; } return(persoToHold); }
public void SetMount(PersoController mount) { if (mount == null) { this.mount = null; } else if (!Timers("MountHyst").active) { this.mount = mount; SetRule("Mounted"); } }
// Collision public bool StoodOnBy(PersoController perso) { if (perso == this || perso.velY != 0) { return(false); } foreach (var c in GetComponentsInChildren <Collider>()) { if (perso.col.ground.hit.collider == c) { return(true); } } return(false); }
public static Waypoint GetNearest(Vector3 pos) { Waypoint closest = null; float cdist = 1000000; foreach (var wp in all) { float dist = PersoController.Dist(pos, wp.pos); if (dist < cdist) { cdist = dist; closest = wp; } } return(closest); }
public void ApplyZDRCollision() { if (perso == null || !perso.HasCollisionType(CollideType.ZDR)) { return; } foreach (var p in PersoController.GetPersos(typeof(PersoController)).Where((x) => x.HasCollisionType(CollideType.ZDR))) { var zdr1 = perso.GetCollisionSphere(CollideType.ZDR); var zdr2 = p.GetCollisionSphere(CollideType.ZDR); float dist = PersoController.Dist(zdr1.position, zdr2.position); float maxDist = zdr1.radius + zdr2.radius; if (dist < maxDist) { perso.pos += (zdr1.position - zdr2.position).normalized * (maxDist - dist); } } }
ParticleSystem SpawnParticle(PersoController attachTo, Vector3 pos, string name, object type = null) { var p = ResManager.Inst("Particles/" + name, attachTo).GetComponent <ParticleSystem>(); p.transform.position = attachTo == null ? pos : pos; foreach (var pr in p.GetComponentsInChildren <ParticleSystemRenderer>()) { pr.material = Instantiate(pr.material); string tex = null; switch (type) { case LumType.Red: tex = "etincelle_rouge_ad"; break; case LumType.Yellow: tex = "etincelle_doree_ad"; break; case LumType.Blue: case LumType.SuperBlue: tex = "etincelle_bleu_ad"; break; case LumType.Green: tex = "etincelle_VERT_ad"; break; case LumType.Purple: tex = "etincelle_mauve_ad"; break; } if (tex != null) { pr.material.mainTexture = ResManager.Get <Texture2D>("effets_speciaux/" + tex); } } if (!p.main.loop) { Timer.StartNew(p.main.startLifetime.constantMax + p.main.startLifetime.constantMax, () => Destroy(p.gameObject)); } return(p); }
public PersoController ReceiveProjectiles(out PersoController projectile, float iFrame = 0) => projectile = ReceiveProjectiles(iFrame);
public bool CheckCollisionZone(PersoController perso, CollideType collideType) { return(perso.DistTo(GetCollisionSphere(collideType).position) < GetCollisionSphere(collideType).radius + perso.GetCollisionSphere(collideType).radius || GetCollisionBox(collideType).Contains(perso.pos)); }
public static PersoController SetMainActor(PersoController perso) { return(main._mainActor = mainActor = perso); }
public void Load() { // Set physics clock nice and high and enable the ambience/SFX environment effects Time.fixedDeltaTime = 1f / 144; FindObjectOfType <EnvHandler>().Enable(); // Do a few things if Empty Level is ticked if (emptyLevel) { ClearLevel(true, emptyLevelPersoTest); } // Remove colliders on everything but actual world collision GameObject root = null; if (!isRom) { root = GameObject.Find("Actual World"); } else { foreach (var r in SceneManager.GetActiveScene().GetRootGameObjects()) { if (r.name.Contains("Hierarchy Root")) { root = r; } } } if (root != null) { foreach (var col in root.GetComponentsInChildren <Collider>()) { var comp = col.GetComponent <CollideComponent>(); var so = comp?.GetComponentInParent <SuperObjectComponent>(); if (comp == null || (comp.type != CollideType.None && comp.type != CollideType.ZDR)) { Destroy(col); } else if (so != null && so.flagPreview.Contains("NoRayTracing")) { comp.gameObject.layer = 2; } } } // Find Waypoint graphs if (controller.graphManager.transform.childCount > 0) { foreach (Transform gr in controller.graphManager.transform.GetChild(0)) { gr.gameObject.AddComponent <WaypointGraph>(); } } // Find isolate Waypoints foreach (Transform w in GameObject.Find("Isolate WayPoints").transform) { w.gameObject.AddComponent <Waypoint>(); } var gameMode = Settings.Mode.Rayman2PC; #if UNITY_EDITOR gameMode = UnitySettings.GameMode; #endif // Make sure spawnable persos are far-out foreach (Transform p in GameObject.Find("Spawnable persos").transform) { p.transform.position = PersoController.nullPos; } // Perso script loading for different games - applied with (Model > Family) priority switch (gameMode) { case Settings.Mode.Rayman2PC: case Settings.Mode.Rayman2DC: case Settings.Mode.Rayman3PC: // The OGs work the best foreach (var pb in FindObjectsOfType <PersoBehaviour>()) { Type matchModel = null, matchFamily = null; foreach (var s in persoScripts) { if (s.Name == pb.perso.nameModel) { matchModel = s; } if (s.Name == pb.perso.nameFamily) { matchFamily = s; } } if (matchModel != null) { persos.Add((PersoController)pb.gameObject.AddComponent(matchModel)); } else if (matchFamily != null) { persos.Add((PersoController)pb.gameObject.AddComponent(matchFamily)); } } break; case Settings.Mode.Rayman2N64: isRom = true; // ROM method with gameObject name splitting, since idk how names are getting there in the first place foreach (var pb in FindObjectsOfType <ROMPersoBehaviour>()) { var names = pb.name.Replace("[", "").Split(new string[] { "] ", " | " }, StringSplitOptions.None); if (names.Length != 3) { continue; } Type matchModel = null, matchFamily = null; foreach (var s in persoScripts) { if (s.Name == names[1]) { matchModel = s; } if (s.Name == names[0]) { matchFamily = s; } } PersoController pc = null; if (matchModel != null) { persos.Add(pc = (PersoController)pb.gameObject.AddComponent(matchModel)); } else if (matchFamily != null) { persos.Add(pc = (PersoController)pb.gameObject.AddComponent(matchFamily)); } if (pc != null && names.Length >= 3) { pc.persoFamily = names[0]; pc.persoModel = names[1]; pc.persoName = names[2]; } } // Camera is currently applied arbitrarily cam = FindObjectOfType <ROMPersoBehaviour>().gameObject.AddComponent <StdCam>(); break; case Settings.Mode.Rayman2PS2: // Names don't exist. Rayman is always last in the perso list and StdCam is applied arbitrarily var world = GameObject.Find("Dynamic World").transform; rayman = world.GetChild(world.childCount - 1).gameObject.AddComponent <YLT_RaymanModel>(); cam = FindObjectOfType <PersoBehaviour>().gameObject.AddComponent <StdCam>(); break; } // HD Shaders? if (HDShaders) { GameObject.Find("HD").SetActive(HDShaders); foreach (var l in controller.lightManager.GetComponentsInChildren <LightBehaviour>()) { var light = l.gameObject.AddComponent <Light>(); light.shadows = LightShadows.None; light.intensity = 2; light.color = l.color; light.range = 20; } foreach (var sec in controller.sectorManager.sectors) { foreach (var mr in sec.GetComponentsInChildren <MeshRenderer>()) { if (mr.material.name == "mat_gouraud (Instance)") { var tex = mr.material.GetTexture("_Tex0"); mr.material = new Material(Shader.Find("Standard")); mr.material.mainTexture = tex; mr.receiveShadows = true; mr.material.SetFloat("_Glossiness", 0.1f); } } } } // Done loading onLoad.Invoke(this, EventArgs.Empty); loaded = true; }
void Start() { mr = GetComponent <MeshRenderer>(); mr.enabled = false; caster = transform.parent.GetComponent <PersoController>(); }
public PersoController CarryPerso(PersoController persoToHold, int handChannel) { carryPerso = persoToHold; this.handChannel = handChannel; return(persoToHold); }
public PersoController HoldPerso(PersoController persoToHold) => CarryPerso(persoToHold, handChannel);
public ParticleSystem SpawnParticle(PersoController attachTo, string name, object type = null) => SpawnParticle(attachTo, pos, name, type);
public float DistTo2D(PersoController perso) => perso == null ? float.PositiveInfinity : DistTo2D(perso.pos);
public static void SetMainActor(PersoController perso) => Main.SetMainActor(perso);