public void Play() { if (Uhh.Offscreen(transform.position, 1f)) { return; } if (sounds.Count == 0) { return; } if (source == null) { return; } if (source.isPlaying) { source.Stop(); } int r = Random.Range(0, sounds.Count); source.clip = sounds[r]; if (pitchShifting > 0) { source.pitch = 1f + Random.Range(-pitchShifting, pitchShifting); } source.Play(); }
void Update( ) { if (mumbletimer > 0) { mumbletimer -= Time.deltaTime; } // position if (mouseControlled) { //Vector2 mp = Uhh.MousePosition ( ); //body.MovePosition (mp); if (ISGRABBING) { anim.Load("grab"); } else { //Input.GetKey(KeyCode.Space) if (Input.GetKey("joystick button 0") && !justletgo) { anim.Load("one"); } else { if (cangrab) { anim.Load("cangrab"); } else { anim.Load("idle"); } } } if (fakeHand) { anim.color = Color.clear; } else { HandleGrabbing( ); } // rotation Vector2 dir = arm.END - arm.MID; body.rotation = Uhh.AngleFromVector(dir); } else { if (STATIC) { // rotation Vector2 dir = arm.END - arm.MID; ROT = Uhh.AngleFromVector(dir); } } arm.UpdateLine(SHOULDER, POS); }
void Update( ) { if (Input.GetKeyDown(KeyCode.Return)) { Uhh.LoadLevel(levelToLoad); } }
void Update( ) { if (Input.GetKeyDown(KeyCode.Escape)) { Uhh.LoadLevel("StartScreen"); } }
// MATH SHIT public static int RandomLookdir() { if (Uhh.Chance(50f)) { return(1); } return(-1); }
public static Vector2 DirToScreenFrom(Vector2 position, Vector2 size) { return(Uhh.LongestVector( DirToScreenFrom(position + new Vector2(size.x, size.y) * .5f), DirToScreenFrom(position + new Vector2(-size.x, size.y) * .5f), DirToScreenFrom(position + new Vector2(size.x, -size.y) * .5f), DirToScreenFrom(position + new Vector2(-size.x, -size.y) * .5f))); }
public override void Click(GameObject subject) { base.Click(subject); transform.SetParent(null); body.bodyType = RigidbodyType2D.Dynamic; body.AddForceAtPosition(Vector2.up * 15f + Uhh.RandomVector(5f), subject.transform.position, ForceMode2D.Impulse); ren.sortingOrder = Random.Range(25, 55); }
public override void Draw() { if (shieldingtimer > 0) { shieldingtimer -= Time.deltaTime; Debug.DrawRay(transform.position, Uhh.VectorFromAngle(transform.rotation.eulerAngles.z), Color.yellow); } }
public override void Activate() { base.Activate(); Vector2 dir = -Uhh.VectorFromAngle(ROT); body.AddForceAtPosition(LOOKDIR * force, POS, ForceMode2D.Force); // body is null here !! Debug.DrawRay(POS, LOOKDIR, Color.red, .1f); }
public override void Activate() { base.Activate(); Vector2 dir = -Uhh.VectorFromAngle(ROT); ship.body.AddForceAtPosition(LOOKDIR * force * (1 - fixture.thrusterstability), POS, ForceMode2D.Force); ship.body.AddForce(LOOKDIR * force * fixture.thrusterstability, ForceMode2D.Force); sfx.Play(); ShowEffects(); VOICE.Say(voice.thruster); }
public void Teleport(Vector2 newpos, float rotation) { body.position = newpos + Vector2.down * 3f; body.velocity = Vector2.zero; body.angularVelocity = 0; body.rotation = rotation - 90; Vector2 dir = Uhh.VectorFromAngle(body.rotation - 90); float force = 2; body.AddForce(dir * force, ForceMode2D.Impulse); }
public override void Update() { base.Update(); Vector2 targetscale = Vector2.one * Random.Range(.9f, 1.1f); if (SHOWING) { Vector2 r = Uhh.RandomVector(); transform.localPosition = baseposition + r; } else { targetscale = Vector2.zero; } transform.localScale = Vector2.Lerp(transform.localScale, targetscale, .3f); }
public override void Update() { float lerpspeed = 0.3f; base.Update(); Vector2 targetpos = Vector2.zero; Vector2 targetscale = Vector2.one * Random.Range(.9f, 1.1f); if (SHOWING) { Vector2 r = Uhh.RandomVector(); r += new Vector2(transform.up.x, transform.up.y); targetpos = baseposition + r; } else { targetscale = Vector2.zero; targetpos = Vector2.zero; } transform.localScale = Vector2.Lerp(transform.localScale, targetscale, lerpspeed); transform.localPosition = Vector2.Lerp(transform.localPosition, targetpos, lerpspeed); }
void Update( ) { if (updateself) { if (HASTARGET) { line.UpdateLine(POS, target.position); } else { line.UpdateLine(POS, Uhh.MousePosition( )); } // line.START = POS; // if (HASTARGET) line.END = target.position; // else { // line.END = Uhh.MousePosition ( ); // if (Input.GetMouseButton (0)) line.hangamount = -4; // else line.hangamount = 3; // } } }
void Update( ) { if (!Application.isPlaying) { if (ren == null) { ren = GetComponent <SpriteRenderer>( ); } if (sprites.Count > 0) { ren.sprite = sprites[0]; } ren.color = color; ren.sortingOrder = sortingorder; return; } if (CURANIM == null) { print("curanim null on " + name); return; } if (sprites.Count < CURANIM.start + CURANIM.frames) { print("out of range on sprites in " + name + ", anim: " + CURANIM.name); return; } timer += Time.deltaTime; if (timer > exposure) { timer -= exposure; frame++; if (frame >= CURANIM.frames) { if (looping) { frame = 0; } else { frame = CURANIM.frames - 1; } looped = true; } setsprite( ); } ren.transform.localScale = new Vector3(lookdir * scale.x, scale.y, 1); if (bottomPivot) { Vector2 pos = transform.position; float scaleRatio = scale.y / targetscale.y; ren.transform.position = pos + ROT.normalized * (scaleRatio * ren.bounds.size.y - ren.bounds.size.y) * .5f; } UpdateScale( ); if (handleRotation) { targetrotation = Uhh.VectorFromAngle(transform.rotation.eulerAngles.z); } //rotation = Vector2.Lerp( rotation, targetrotation, .175f ); rotation = Vector2.Lerp(rotation, targetrotation, .425f * 60f * Time.deltaTime); ren.transform.rotation = Quaternion.Euler(0, 0, Uhh.AngleFromVector(rotation) + rotationoffset * lookdir); ren.color = color; ren.sortingOrder = sortingorder; }