void Start() { me = this; tr = transform; int x, y; camTr = tr.Find("cam"); cam = camTr.GetComponent <Camera>(); staticTr = tr.Find("static"); eventTr = tr.Find("event"); collisionTr = tr.Find("collision"); cursorTr = camTr.Find("cursor"); cursorRend = cursorTr.GetComponent <Renderer>(); if (cursorTex == null) { cursorTex = new Texture2D[] { Resources.Load <Texture2D>("ui/cursor1"), Resources.Load <Texture2D>("ui/cursor2"), Resources.Load <Texture2D>("ui/cursor3") }; headIdle = new Texture2D[] { Resources.Load <Texture2D>("ui/mind/parado1"), Resources.Load <Texture2D>("ui/mind/parado2"), Resources.Load <Texture2D>("ui/mind/parado3") }; headTalk = new Texture2D[] { Resources.Load <Texture2D>("ui/mind/falando1"), Resources.Load <Texture2D>("ui/mind/falando2"), Resources.Load <Texture2D>("ui/mind/falando3") }; headPress = new Texture2D[] { Resources.Load <Texture2D>("ui/mind/atacando1"), Resources.Load <Texture2D>("ui/mind/atacando2"), Resources.Load <Texture2D>("ui/mind/atacando3") }; headCulture = new Texture2D[] { Resources.Load <Texture2D>("ui/mind/admirando1"), Resources.Load <Texture2D>("ui/mind/admirando2"), Resources.Load <Texture2D>("ui/mind/admirando3") }; } cursorPing = cursorTr.Find("ping").GetComponent <QuickAnim>(); cursorHit = cursorTr.Find("hit").GetComponent <QuickAnim>(); headCorner = camTr.Find("mind").GetComponent <Renderer>(); hudTr = camTr.Find("hud"); hudProgress = new ProgressBar[] { hudTr.Find("health").GetComponent <ProgressBar>(), hudTr.Find("peace").GetComponent <ProgressBar>(), hudTr.Find("exploration").GetComponent <ProgressBar>(), hudTr.Find("power").GetComponent <ProgressBar>(), hudTr.Find("wealth").GetComponent <ProgressBar>(), hudTr.Find("culture").GetComponent <ProgressBar>(), hudTr.Find("penitence").GetComponent <ProgressBar>(), hudTr.Find("friendship").GetComponent <ProgressBar>() }; for (x = 0; x < 8; x++) { hudProgress[x].Initialise(); } var reader = new MapReader(); if (overrideLevel.Length > 0) { currentLevel = overrideLevel; } else { currentLevel = requestedLevel; } reader.Read(currentLevel); //Debug.Log("size: "+width+"x"+height); //MapReader.DebugTiles(tileBg); //MapReader.DebugTiles(tileEv); //MapReader.DebugTiles(tileFg); //MapReader.DebugTiles(tileCo); heightR = 1f / height; events = new List <Event>(); for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { if (tileBg[x, y] > 0) { AddStatic(tileBg[x, y], x, y, false); } if (tileFg[x, y] > 0) { AddStatic(tileFg[x, y], x, y, true); } if (tileEv[x, y] > 0) { AddEvent(tileEv[x, y], x, y); } if (tileCo[x, y] == 1) { AddCollision(x, y); } } } Event a, b; int4 i; for (x = 0; x < wires.Count; x++) { a = b = null; i = wires[x]; //Debug.Log("wire at "+i.x0+"x"+i.y0+" <-> "+i.x1+"x"+i.y1); if (tileEv[i.x0, i.y0] <= 0 || tileEv[i.x1, i.y1] <= 0) { continue; } for (y = 0; y < events.Count; y++) { if (Mathf.Approximately(events[y].x, i.x0) && Mathf.Approximately(events[y].y, i.y0)) { a = events[y]; if (b != null) { break; } } else if (Mathf.Approximately(events[y].x, i.x1) && Mathf.Approximately(events[y].y, i.y1)) { b = events[y]; if (a != null) { break; } } } if (a != null && b != null) { if (!a.connected.Contains(b)) { a.connected.Add(b); } if (!b.connected.Contains(a)) { b.connected.Add(a); } } } if (player == null) { AddEvent(1, width / 2, height / 2); } if (useRoute) { int f = (currentRoute.facing + 2) % 4; if (f == 0) { player.y = (height - 1) * .5f; for (y = 1; y < height - 1; y++) { if (tileCo[width - 1, y] != 1) { player.y = y + .5f; break; } } player.x = width - 1; } else if (f == 1) { player.x = (width - 1) * .5f; for (x = width - 2; x > 0; x--) { if (tileCo[x, height - 1] != 1) { player.x = x - .5f; break; } } player.y = height - 1; } else if (f == 2) { player.y = (height - 1) * .5f; for (y = height - 2; y > 0; y--) { if (tileCo[0, y] != 1) { player.y = y - .5f; break; } } player.x = 0; } else { player.x = (width - 1) * .5f; for (x = 1; x < width - 1; x++) { if (tileCo[x, 0] != 1) { player.x = x + .5f; break; } } player.y = 0; } useRoute = false; } EventProps evs; for (x = 0; x < events.Count; x++) { events[x].Initialise(); if (eventProps.TryGetValue(events[x].id, out evs)) { evs.GetState(events[x]); } } if (!visited.ContainsKey(currentLevel)) { visited[currentLevel] = true; exploration += 5; if (exploration > 100) { exploration = 100; } } UpdateCamera(true); }
public override void Initialise() { if (loadTexture) { loadTexture = false; texIdle = new Texture2D[] { Resources.Load <Texture2D>("events/player/parado1"), Resources.Load <Texture2D>("events/player/parado2"), Resources.Load <Texture2D>("events/player/parado3") }; texCulture = new Texture2D[] { Resources.Load <Texture2D>("events/player/admirando1"), Resources.Load <Texture2D>("events/player/admirando2"), Resources.Load <Texture2D>("events/player/admirando3") }; texAttack = new Texture2D[] { Resources.Load <Texture2D>("events/player/atacando1"), Resources.Load <Texture2D>("events/player/atacando2"), Resources.Load <Texture2D>("events/player/atacando3"), Resources.Load <Texture2D>("events/player/atacando4") }; texChirp = new Texture2D[] { Resources.Load <Texture2D>("events/player/falando1"), Resources.Load <Texture2D>("events/player/falando2"), Resources.Load <Texture2D>("events/player/falando3") }; texUp = new Texture2D[] { Resources.Load <Texture2D>("events/player/andando_tras1"), Resources.Load <Texture2D>("events/player/andando_tras2"), Resources.Load <Texture2D>("events/player/andando_tras3"), Resources.Load <Texture2D>("events/player/andando_tras4"), Resources.Load <Texture2D>("events/player/andando_tras5"), Resources.Load <Texture2D>("events/player/andando_tras6") }; texDown = new Texture2D[] { Resources.Load <Texture2D>("events/player/andando_baixo1"), Resources.Load <Texture2D>("events/player/andando_baixo2"), Resources.Load <Texture2D>("events/player/andando_baixo3"), Resources.Load <Texture2D>("events/player/andando_baixo4"), Resources.Load <Texture2D>("events/player/andando_baixo5"), Resources.Load <Texture2D>("events/player/andando_baixo6") }; texLeft = new Texture2D[] { Resources.Load <Texture2D>("events/player/andando_esquerda1"), Resources.Load <Texture2D>("events/player/andando_esquerda2"), Resources.Load <Texture2D>("events/player/andando_esquerda3") }; texRight = new Texture2D[] { Resources.Load <Texture2D>("events/player/andando_direita1"), Resources.Load <Texture2D>("events/player/andando_direita2"), Resources.Load <Texture2D>("events/player/andando_direita3") }; clips = new AudioClip[] { Resources.Load <AudioClip>("events/player/hit"), Resources.Load <AudioClip>("events/player/body"), Resources.Load <AudioClip>("events/player/head"), Resources.Load <AudioClip>("events/player/attack"), Resources.Load <AudioClip>("events/player/press") }; } tr.localPosition = Pos(); tr.localScale = Vector3.one; tr.localRotation = Quaternion.identity; sprite = tr.Find("sprite"); rend = sprite.GetComponent <Renderer>(); ping = tr.Find("ping").GetComponent <QuickAnim>(); aud = GetComponent <AudioSource>(); range = 1.5f; offset = .3f; pressed = false; attacked = false; holdTempo = 0; chirpTempo = 0; attackTempo = 0; animTempo = 0; pulseTempo = 0; }