void EndLevel() { if (levelComplete == false) { if (GameVar.Score[level - 1] < (int)PlanetHealth.planetHealth) { GameVar.Score[level - 1] = (int)PlanetHealth.planetHealth; } GameObject instance = Instantiate(Resources.Load("LevelComplete", typeof(GameObject))) as GameObject; instance.transform.FindChild("TextScore").GetComponent <Text>().text = "Score: " + Mathf.Round(PlanetHealth.planetHealth).ToString(); levelComplete = true; GameVar.LevelsComplete[level - 1] = true; if (LevelUnlocks.Length != 0) { for (var i = 0; i < LevelUnlocks.Length; i++) { GameVar.LevelsUnlocked[LevelUnlocks[i] - 1] = true; } } if (WeaponUnlock != 0) { GameVar.WeaponsUnlocked[WeaponUnlock - 1] = true; } GameVar.Save(); } }
static uint e_Check(IntPtr ptr) { var values = new UIntArray(ptr); Critter virgin = Global.GetCritter(values[0]); if (virgin == null) { return(0); } GameVar virginState = Global.GetGlobalVar(GVars.den_virgin); if (virginState == null) { Global.Log("GetGlobalVar(GVAR_den_virgin) fail."); } else { if (virgin.Stat[Stats.Var0] == 0 && virginState.Value == IsAway) { virginState.Value = IsHome; virgin.AddWalkPlane(0, HomeX, HomeY, Direction.SouthEast, false, 2); } else { virgin.Stat[Stats.Var0]--; } } return(60 * 60); }
static void _VirginTalk(object sender, CritterTalkEventArgs e) { var virgin = sender as Critter; // handle end of dialog if (!e.Attach) { if (virgin.Stat[Stats.Var1] == IsAway) { GameVar virginState = Global.GetGlobalVar(GVars.den_virgin); if (virginState == null) { Global.Log("GetGlobalVar(GVAR_den_virgin) fail."); // no matter what to return } virginState.Value = IsAway; // reset virgin.Stat[Stats.Var1] = IsHome; virgin.AddWalkPlane(0, AwayX, AwayY, Direction.SouthEast, false, 2); } } e.PreventDefaults(); }
void InitGameVars() { GameVars = new Dictionary <string, GameVar>(); GameVars[kCurrentLevel] = new GameVar(); GameVars[kCompletedRows] = new GameVar(); GameVars[kScore] = new GameVar(); }
void Start() { TutorialClass.tutorial = false; TutorialClass.tutorial2 = false; int width = Screen.width; int height = Screen.height; Vector3 vec3 = Camera.main.ScreenToWorldPoint(new Vector3((float)width, (float)height, 0f)); stageRight = vec3.x; stageTop = vec3.y; vec3 = Camera.main.ScreenToWorldPoint(new Vector3(0f, 0f, 0f)); stageLeft = vec3.x; stageBottom = vec3.y; impact = GameObject.Find("ImpactParticles"); GameVar gv = GameObject.Find("GameVar").GetComponent <GameVar>(); planetType = gv.planetType; if (planetType < 5) { impactParticles.sprite = planetMasks[planetType - 1]; bigPlanet.sprite = bigPlanetImage[planetType - 1]; for (int i = 0; i < planetColliders.Length; i++) { if (i != planetType - 1) { Destroy(planetColliders[i]); } } } else if (planetType == 5) { bigPlanet.sprite = null; impactParticles.sprite = null; for (int i = 0; i < planetColliders.Length; i++) { Destroy(planetColliders[i]); } } else if (planetType > 5) { impactParticles.sprite = planetMasks[planetType - 2]; bigPlanet.sprite = bigPlanetImage[planetType - 2]; for (int i = 0; i < planetColliders.Length; i++) { if (i != planetType - 2) { Destroy(planetColliders[i]); } } } level = (byte)gv.Level; LoadLevel(level); }
// Use this for initialization void Start() { remove = transform.FindChild("Remove").gameObject; GameObject gVar = GameObject.Find("GameVar"); gameVar = gVar.GetComponent <GameVar>(); WepArray = new GameObject[12] { HomingLaser, PiercingCannon, Shield, EnergyPrison, FlakCannon, ChargingLaser, RocketLauncher, AOECannon, HomingCannon, LaserCannon, SpreadCannon, SniperCannon }; if (SceneManager.GetActiveScene().name == "Game") { if (Num == 1) { Type = gameVar.Weapon1; } if (Num == 2) { Type = gameVar.Weapon2; } if (Num == 3) { Type = gameVar.Weapon3; } if (Num == 4) { Type = gameVar.Weapon4; } ChangeIcon(Type); } else { if (Num == 1) { gameVar.Weapon1 = Type; } if (Num == 2) { gameVar.Weapon2 = Type; } if (Num == 3) { gameVar.Weapon3 = Type; } if (Num == 4) { gameVar.Weapon4 = Type; } } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f); for (var r = 0; r < hitInfo.Length; r++) { if (hitInfo[r].collider != null) { if (hitInfo[r].collider.gameObject.name == "sOn") { GameVar.sound = true; GameVar.SaveOptions(); } if (hitInfo[r].collider.gameObject.name == "sOff") { GameVar.sound = false; GameVar.SaveOptions(); } if (hitInfo[r].collider.gameObject.name == "mOn") { GameVar.music = true; GameVar.SaveOptions(); } if (hitInfo[r].collider.gameObject.name == "mOff") { GameVar.music = false; GameVar.SaveOptions(); } } ChangeOpacity(); } } }
// Use this for initialization void Start() { GameObject gameVar = GameObject.Find("GameVar"); if (gameVar != null) { GameVar gVar = gameVar.GetComponent <GameVar>(); if (position == 1) { type = gVar.Weapon1; } if (position == 2) { type = gVar.Weapon2; } if (position == 3) { type = gVar.Weapon3; } if (position == 4) { type = gVar.Weapon4; } if (position == 5) { if (GameVar.WeaponsUnlocked[12] == false) { Destroy(this.gameObject); } } if (position == 6) { if (GameVar.WeaponsUnlocked[13] == false) { Destroy(this.gameObject); } } if (position == 7) { if (GameVar.WeaponsUnlocked[14] == false) { Destroy(this.gameObject); } } if (type == "Empty") { Destroy(this.gameObject); } } Canvas myCanvasObject = GetComponent <Canvas>(); myCanvasObject.sortingLayerName = "ui"; cost = GetCost(type); int height = Camera.main.pixelHeight; int width = 0; Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3((float)width, (float)height, 0)); if (position < 5) { this.transform.position = new Vector3(worldPos.x + 0.35f + .7f * position - .7f, worldPos.y - 0.35f, worldPos.z); this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, 0); } else { this.transform.position = new Vector3(worldPos.x + 0.35f + .7f * (position - 4) - .7f, worldPos.y - 0.35f - .7f, worldPos.z); this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, 0); } Transform text = transform.Find("Cost"); t = text.GetComponent <Text>(); t.text = cost.ToString(); Transform go = transform.Find("Box"); box = go.GetComponent <Transform>(); go = transform.Find("SpriteGreen"); green = go.gameObject; GameObject xo = GameObject.Find("EnergyBox"); energy = xo.GetComponent <Energy>(); go = transform.Find(type); if (type != "Empty") { go.gameObject.SetActive(true); } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f); for (var r = 0; r < hitInfo.Length; r++) { if (hitInfo[r].collider != null) { if (hitInfo[r].collider.gameObject.name == "ResumeGame") { goBack(); } if (hitInfo[r].collider.gameObject.name == "RestartLevel") { GameObject instance = Instantiate(Resources.Load("WeaponSelectPrefab", typeof(GameObject))) as GameObject; WeaponSelect ws = instance.gameObject.GetComponentInChildren <WeaponSelect>(); ws.map = false; Destroy(gameObject); //SceneManager.LoadScene(1); } if (hitInfo[r].collider.gameObject.name == "ReturnToMap") { SceneManager.LoadScene(2); MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>(); mp.ChangeSong = true; mp.nextSong = 0; } if (hitInfo[r].collider.gameObject.name == "gOn") { GameVar.graphics = true; } else if (hitInfo[r].collider.gameObject.name == "gOff") { GameVar.graphics = false; } if (hitInfo[r].collider.gameObject.name == "sOn") { GameVar.sound = true; GameVar.SaveOptions(); } if (hitInfo[r].collider.gameObject.name == "sOff") { GameVar.sound = false; GameVar.SaveOptions(); } if (hitInfo[r].collider.gameObject.name == "mOn") { MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>(); mp.MusicOn(); GameVar.music = true; GameVar.SaveOptions(); } if (hitInfo[r].collider.gameObject.name == "mOff") { MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>(); mp.MusicOff(); GameVar.music = false; GameVar.SaveOptions(); } if (hitInfo[r].collider.gameObject.name == "Back") { goBack(); } } ChangeOpacity(); } } }
// Use this for initialization void Start() { sp = transform.FindChild("Sprite").gameObject.GetComponent <SpriteRenderer>(); add = transform.FindChild("Add").gameObject; int[] BlockedWeapons = new int[15]; GameObject g = GameObject.Find("GameVar"); GameVar gv = g.GetComponent <GameVar>(); if (gv.Level == 11) { BlockedWeapons = new int[] { 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; } else if (gv.Level == 15) { BlockedWeapons = new int[] { 1 }; } else if (gv.Level == 16) { BlockedWeapons = new int[] { 3 }; } else if (gv.Level == 20) { BlockedWeapons = new int[] { 3, 1, 2, 4, 6, 8, 9, 10, 5, 12 }; } else if (gv.Level == 21) { BlockedWeapons = new int[] { 2, 4, 8, 9 }; } else if (gv.Level == 22) { BlockedWeapons = new int[] { 1, 6, 9, 7 }; } else if (gv.Level == 23) { BlockedWeapons = new int[] { 8 }; } else if (gv.Level == 24) { BlockedWeapons = new int[] { 1, 2, 4, 11, 6, 8, 7, 5 }; } else if (gv.Level == 28) { BlockedWeapons = new int[] { 10 }; } for (int i = 0; i < BlockedWeapons.Length; i++) { if (BlockedWeapons[i] == num) { unavailable = true; } } if (unavailable == false) { if (GameVar.WeaponsUnlocked[num - 1] == false) { Locked = true; transform.FindChild("Sprite").gameObject.SetActive(false); transform.FindChild("Locked").gameObject.SetActive(true); } } else { Locked = true; transform.FindChild("Sprite").gameObject.SetActive(false); transform.FindChild("Locked").gameObject.SetActive(false); transform.FindChild("UnAvailable").gameObject.SetActive(true); } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f); for (var r = 0; r < hitInfo.Length; r++) { if (hitInfo[r].collider.gameObject.name == "OptionButton") { Map mapScript = map.GetComponent <Map>(); if (options == false && mapScript.active == true) { options = true; mapScript.active = false; GameObject instance = Instantiate(Resources.Load("OptionsMenu", typeof(GameObject))) as GameObject; OptionsMenu om = instance.GetComponent <OptionsMenu>(); om.map = true; om.mouseCheck = this.gameObject; return; } } } for (var r = 0; r < hitInfo.Length; r++) { if (hitInfo[r].collider != null) { if (hitInfo[r].collider.gameObject.name == "HitTest") { Map mapScript = map.GetComponent <Map>(); if (mapScript.active == true) { Planet planet = hitInfo[r].collider.gameObject.GetComponentInParent <Planet>(); if (planet.unlocked == true) { GameObject instance = Instantiate(Resources.Load("WeaponSelectPrefab", typeof(GameObject))) as GameObject; mapScript.active = false; GameVar gv = GameObject.Find("GameVar").GetComponent <GameVar>(); gv.Level = planet.level; gv.planetType = (byte)planet.planetType; } } } else if (hitInfo[r].collider.gameObject.name == "Go") { if (hitInfo[r].collider.transform.parent.FindChild("WeaponSelect").FindChild("ActiveBox1").GetComponent <ActiveBox>().Type != "Empty") { SceneManager.LoadScene(1); MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>(); mp.ChangeSong = true; mp.nextSong = Random.Range(1, 4); } else { hitInfo[r].collider.gameObject.transform.parent.FindChild("WeaponSelect").FindChild("NoweaponsSelected").GetComponent <Text>().color = new Color(1f, 0f, 0f, 1f); } } else if (hitInfo[r].collider.gameObject.name == "ReturnToMap") { Destroy(hitInfo[r].collider.gameObject.transform.parent.gameObject); Map mapScript = map.GetComponent <Map>(); mapScript.active = true; return; } else if (hitInfo[r].collider.gameObject.name == "UnLockAll") { Map mapScript = map.GetComponent <Map>(); if (mapScript.active == true) { GameObject.Find("GameVar").GetComponent <GameVar>().UnlockAll(); SceneManager.LoadScene(2); } } else { for (int i = 1; i < 4; i++) { if (hitInfo[r].collider.gameObject.name == i.ToString()) { if (GameVar.WeaponsUnlocked[11 + i] == true) { info = GameObject.Find("Info").GetComponent <Info>(); info.ChangeInfo((byte)(12 + i)); } } } string PassiveSlotName; for (int i = 1; i < 13; i++) { PassiveSlotName = "PassiveBox" + i; if (hitInfo[r].collider.gameObject.name == PassiveSlotName) { PassiveBox passiveBox = hitInfo[r].collider.gameObject.GetComponent <PassiveBox>(); passiveBox.AddWeapon(); if (passiveBox.Locked == false) { info = GameObject.Find("Info").GetComponent <Info>(); info.ChangeInfo((byte)passiveBox.num); } } } for (int i = 1; i < 5; i++) { PassiveSlotName = "ActiveBox" + i; if (hitInfo[r].collider.gameObject.name == PassiveSlotName) { ActiveBox activeBox = hitInfo[r].collider.gameObject.GetComponent <ActiveBox>(); activeBox.ResetIcons(); } } } } } } }