public static ScriptCmd CreateDefault(int index) { string text = string.Empty; switch (index) { case 0: text = EnableScript.GetDefaultDescription(); break; case 1: text = ShowDialog.GetDefaultDescription(); break; case 2: text = PlaySound.GetDefaultDescription(); break; case 3: text = Sleep.GetDefaultDescription(); break; case 4: text = Exit.GetDefaultDescription(); break; case 5: text = ShowScript.GetDefaultDescription(); break; case 6: text = GiveWeapon.GetDefaultDescription(); break; case 7: text = TakeAwayAll.GetDefaultDescription(); break; case 8: text = SetMission.GetDefaultDescription(); break; } if (text.Length <= 0) { return(null); } return(Create(text)); }
// Get the player object protected virtual void Start() { player = GameObject.FindGameObjectWithTag("Player"); startPos = gameObject.transform.position; startRot = gameObject.transform.rotation; toggler = GetComponent <EnableScript>(); if (adaptive) { deaths = PlayerPrefs.GetInt("Deaths"); activationTimeValue = 2f * activationTime * (1 / (1 + Mathf.Exp(-0.3f * deaths))); cooldownTimeValue = 2f * cooldownTime * (1 / (1 + Mathf.Exp(-0.3f * deaths))); } rendererStatue = gameObject.GetComponent <Renderer>(); color = rendererStatue.material.color; flicker = new Color(255f, 255f, 255f); // white flicker.a = 0.2f; }
// Use this for initialization void Start() { //queenbee moves between pos1 and pos 2 pos1 = new Vector3(transform.position.x - PingPongRange, transform.position.y, transform.position.z); pos2 = new Vector3(transform.position.x + PingPongRange, transform.position.y, transform.position.z); clouds = GameObject.FindGameObjectsWithTag("Cloud"); cloudRenderer = new Renderer[clouds.Length][]; enable = GetComponent <EnableScript>(); for (int i = 0; i < clouds.Length; i++) { Debug.Log(i); cloudRenderer [i] = clouds [i].gameObject.GetComponentsInChildren <Renderer> (); //Debug.Log (cloudRenderer [i]); } int start_Birth = UnityEngine.Random.Range(1, Birthtime); int Birth_repeat = UnityEngine.Random.Range(MinBirthRepeatTime, MaxBirthRepeatTime); InvokeRepeating("Lay_Eggs", start_Birth, Birth_repeat); }
private void DoEnableScript(EnableScript enableScript) { BrickProperty[] allScriptables = BrickManager.Instance.GetAllScriptables(); if (allScriptables != null) { int num = -1; List <Texture> list = new List <Texture>(); for (int i = 0; i < allScriptables.Length; i++) { Brick brick = BrickManager.Instance.GetBrick(allScriptables[i].Index); if (brick != null) { list.Add(brick.Icon); } else { Debug.LogError("Fail to get scriptables icon "); } if (enableScript.Id == allScriptables[i].Seq) { num = i; } } if (num < 0) { num = 0; } Texture[] array = list.ToArray(); int num2 = array.Length; Rect rect = new Rect(0f, 0f, 48f, (float)(num2 * 48)); Rect position = new Rect(size.x / 2f + 4f, 112f, size.x / 2f - 8f, 192f); spId = GUI.BeginScrollView(position, spId, rect); num = GUI.SelectionGrid(rect, num, array, 1); enableScript.Id = allScriptables[num].Seq; Color color = GUI.color; Vector2 vector = new Vector2(52f, 0f); for (int j = 0; j < allScriptables.Length; j++) { if (j == num) { GUI.color = new Color(0.83f, 0.49f, 0.29f); } else { GUI.color = Color.white; } BrickInst brickInst = BrickManager.Instance.GetBrickInst(allScriptables[j].Seq); if (brickInst == null || brickInst.BrickForceScript == null || brickInst.BrickForceScript.Alias.Length <= 0) { GUI.Label(new Rect(vector.x, vector.y, size.x / 2f - 60f, 48f), allScriptables[j].Seq.ToString(), "MiniLabel"); } else { string text = (allScriptables[j].Seq != prop.Seq) ? brickInst.BrickForceScript.Alias : alias; GUI.Label(new Rect(vector.x, vector.y, size.x / 2f - 60f, 48f), text, "MiniLabel"); } vector.y += 48f; } GUI.color = color; GUI.EndScrollView(); } enableScript.Enable = GUI.Toggle(new Rect(size.x / 2f + 4f, 310f, 128f, 13f), enableScript.Enable, StringMgr.Instance.Get("ENABLE_OR")); }
public static ScriptCmd Create(string description) { ScriptCmd result = null; string[] array = description.Split(ScriptCmd.ArgDelimeters, StringSplitOptions.RemoveEmptyEntries); if (array != null && array.Length > 0) { for (int i = 0; i < array.Length; i++) { array[i] = array[i].Trim(); } string text = array[0].ToLower(); switch (text) { case "enablescript": if (array.Length >= 3) { EnableScript enableScript = new EnableScript(); enableScript.Id = int.Parse(array[1]); enableScript.Enable = bool.Parse(array[2]); result = enableScript; } break; case "showdialog": if (array.Length >= 2) { ShowDialog showDialog = new ShowDialog(); showDialog.Speaker = int.Parse(array[1]); showDialog.Dialog = ((array.Length < 3) ? string.Empty : array[2]); result = showDialog; } break; case "playsound": if (array.Length >= 2) { PlaySound playSound = new PlaySound(); playSound.Index = int.Parse(array[1]); result = playSound; } break; case "sleep": if (array.Length >= 2) { Sleep sleep = new Sleep(); sleep.Howlong = float.Parse(array[1]); result = sleep; } break; case "exit": { Exit exit = new Exit(); result = exit; break; } case "showscript": if (array.Length >= 3) { ShowScript showScript = new ShowScript(); showScript.Id = int.Parse(array[1]); showScript.Visible = bool.Parse(array[2]); result = showScript; } break; case "giveweapon": { GiveWeapon giveWeapon = new GiveWeapon(); giveWeapon.WeaponCode = ((array.Length < 2) ? string.Empty : array[1]); result = giveWeapon; break; } case "takeawayall": { TakeAwayAll takeAwayAll = new TakeAwayAll(); result = takeAwayAll; break; } case "setmission": { SetMission setMission = new SetMission(); if (array.Length >= 2) { setMission.Progress = array[1]; setMission.Title = array[2]; setMission.SubTitle = array[3]; if (array.Length > 4 && array[4].Length > 0) { setMission.Tag = array[4]; } } else { setMission.Progress = string.Empty; setMission.Title = string.Empty; setMission.SubTitle = string.Empty; setMission.Tag = string.Empty; } result = setMission; break; } } } return(result); }