private void DrawPowerUpsParameters() { EditorGUILayout.Space(); EditorGUILayout.LabelField("PowerUps", _secondaryStyle); EditorGUILayout.Space(); seePowerUpsPreview = EditorGUILayout.Toggle("Set Preview", seePowerUpsPreview); scriptable.previewPowerUp = seePowerUpsPreview; if (seePowerUpsPreview) { powerUpPreview = (GameObject)EditorGUILayout.ObjectField("Preview Object", powerUpPreview, typeof(GameObject), false); if (powerUpPreview != null) { EditorGUILayout.Space(); if (GUILayout.Button("Set Preview")) { foreach (GameObject obj in FindObjectsOfType(typeof(GameObject))) { if (obj.GetComponent <PowerUp>()) { var child = obj.GetComponent <GetChild>(); child.child.SetActive(true); child.child.hideFlags = HideFlags.None; var childRend = obj.GetComponentInChildren <Renderer>(); var childMesh = obj.GetComponentInChildren <MeshFilter>(); if (childRend != null) { child.child.transform.localScale = powerUpPreview.transform.localScale; childMesh.sharedMesh = powerUpPreview.GetComponent <MeshFilter>().sharedMesh; var mat = new Material(Shader.Find("TransparencyShader")); mat.SetColor("_Color", Color.cyan); mat.SetFloat("_Opacity", 0.71f); mat.SetFloat("_Emission", -0.17f); childRend.sharedMaterial = mat; child.child.hideFlags = HideFlags.HideInHierarchy; } } } } } } else { foreach (GameObject obj in FindObjectsOfType(typeof(GameObject))) { if (obj.GetComponent <PowerUp>()) { var child = obj.GetComponent <GetChild>(); child.child.hideFlags = HideFlags.None; var childRend = obj.GetComponentInChildren <Renderer>(); if (childRend != null) { childRend.gameObject.SetActive(false); child.child.hideFlags = HideFlags.HideInHierarchy; } } } } EditorGUILayout.Space(); powerupsIndex = EditorGUILayout.Popup("Power Ups Types", powerupsIndex, allPowerups); currentPowerup = allPowerups[powerupsIndex]; EditorGUILayout.Space(); _animEmpty.target = EditorGUILayout.Toggle("Use Empty Object", _animEmpty.target); if (EditorGUILayout.BeginFadeGroup(_animEmpty.faded)) { if (GUILayout.Button("SpawnPowerUp", GUILayout.Width(200))) { for (int i = 0; i < scriptable.gameObjectsPreview.Count; i++) { PowerUp c = scriptable.gameObjectsPreview[i].GetComponent <PowerUp>(); if (c) { GameObject a = scriptable.gameObjectsPreview[i]; a.name = ""; a.name = "PowerUp - " + currentPowerup; if (spawnedEmptyName.Contains(a.name)) { if (currentPowerup == "Damage") { copies[0]++; a.name = "PowerUp - " + currentPowerup + " (" + copies[0] + ")"; } else if (currentPowerup == "Health") { copies[1]++; a.name = "PowerUp - " + currentPowerup + " (" + copies[1] + ")"; } else { copies[2]++; a.name = "PowerUp - " + currentPowerup + " (" + copies[2] + ")"; } } PrefabUtility.InstantiatePrefab(a); spawnedEmptyName.Add(a.name); } } foreach (GameObject obj in FindObjectsOfType(typeof(GameObject))) { if (obj.GetComponent <PowerUp>()) { var childComponent = obj.GetComponent <GetChild>(); if (childComponent == null) { GetChild getChild = obj.AddComponent <GetChild>(); if (powerUpPreview != null) { getChild.spawn = powerUpPreview; } else { getChild.spawn = new GameObject("preview"); } } } } } } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); _animObject.target = EditorGUILayout.Toggle("Assign Object", _animObject.target); if (EditorGUILayout.BeginFadeGroup(_animObject.faded)) { var previousColor = GUI.backgroundColor; if (powerUp == null) { GUI.backgroundColor = new Color(255, 0, 0, 0.4f); } powerUp = (GameObject)EditorGUILayout.ObjectField("Power Up Asset", powerUp, typeof(GameObject), false, GUILayout.Width(400)); EditorGUILayout.Space(); GUI.backgroundColor = previousColor; if (powerUp != null) { allEmpty = spawnedEmptyName.ToArray(); if (allEmpty.Length > 0) { emptyIndex = EditorGUILayout.Popup("Select From Spawned", emptyIndex, allEmpty); currentEmpty = allEmpty[emptyIndex]; EditorGUILayout.Space(); if (powerUpName == null) { powerUpName = powerUp.name; } powerUpName = EditorGUILayout.TextField("Name", powerUpName); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Spawn Asset in: " + currentEmpty); EditorGUILayout.Space(); if (GUILayout.Button("Spawn")) { GameObject b = powerUp; b.name = powerUpName; b.transform.position = GameObject.Find(allEmpty[emptyIndex]).transform.position; PrefabUtility.InstantiatePrefab(b); } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("No empty objects created", MessageType.Warning); } } } EditorGUILayout.EndFadeGroup(); if (spawnedEmptyName.Count > 0) { scriptable.emptyCreated = spawnedEmptyName; } }
public void Update() { if (done) { return; } // skip it if they aren't even at tier 4 grimmchild yet. or if they're especially dumb and // banished grimm if (!PlayerData.instance.GetBoolInternal("killedNightmareGrimm")) { done = true; return; } grimmchild = GameObject.FindGameObjectWithTag("Grimmchild"); if (grimmchild == null) { return; } gcFSM = FSMUtility.LocateFSM(grimmchild, "Control"); if (baseFireInterval < 0.0) { Log("Set default values for speeds"); setDefaultGCValues(); } FsmState followState = gcFSM.GetState("Follow"); FloatCompare[] followCompare = followState.GetActionsOfType <FloatCompare>(); //followCompare[0].float2 = 1.0f; followCompare[1].float2 = .5f; followState.RemoveActionsOfType <Wait>(); FsmState anticAttack = gcFSM.GetState("Antic"); RandomFloat[] anticRand = anticAttack.GetActionsOfType <RandomFloat>(); anticRand[0].max = (float)(baseFireInterval / speedModifier); anticRand[0].min = (float)(baseFireInterval / speedModifier); FsmState noTarget = gcFSM.GetState("No Target"); SetFloatValue[] noTargetWait = noTarget.GetActionsOfType <SetFloatValue>(); noTargetWait[0].floatValue = (float)(baseFireInterval / (speedModifier * 2)); gcFSM.FsmVariables.GetFsmFloat("Flameball Speed").Value = (float)(baseFBSpeed * FBSpeedModifier); grimmchild.FindGameObjectInChildren("Enemy Range").GetComponent <CircleCollider2D>().radius = (float)(baseRange * rangeModifier); tk2dSprite grimmSprite = grimmchild.GetComponent <tk2dSprite>(); Color grimmColor = grimmSprite.color; grimmColor.a = filterAlpha; grimmColor.b = filterBlue; grimmColor.g = filterGreen; grimmColor.r = filterRed; grimmSprite.color = grimmColor; FsmState shootYouFool = gcFSM.GetState("Shoot"); GrimmballFireReal.grimmchild = grimmchild; GrimmballFireReal.shootState = shootYouFool; GrimmballFireReal.ballSize = ballSize; GrimmballFireReal.damage = maxDamage; GrimmballFireReal.ghostBalls = ghostBall; CallMethod[] currentMethods = shootYouFool.GetActionsOfType <CallMethod>(); if (currentMethods.Length == 0) { SpawnObjectFromGlobalPool[] spawnObjs = shootYouFool.GetActionsOfType <SpawnObjectFromGlobalPool>(); try { GrimmballFireReal.deadShootSpawner = spawnObjs[0]; shootYouFool.RemoveActionsOfType <SpawnObjectFromGlobalPool>(); } catch { Log("Not removing shoot spawner, probs because it's length is: " + spawnObjs.Length); } CallMethod newDankShootMethod = new CallMethod { }; try { newDankShootMethod.behaviour = GameManager.instance.gameObject.GetComponent <GrimmballFireReal>(); newDankShootMethod.methodName = "GrimmballUpdater"; newDankShootMethod.parameters = new FsmVar[0]; newDankShootMethod.everyFrame = false; } catch (Exception e) { Log("Unable to add method: error " + e); } Log("Made custom call method"); shootYouFool.AddAction(newDankShootMethod); FireAtTarget currentFAT = shootYouFool.GetActionsOfType <FireAtTarget>()[0]; shootYouFool.RemoveActionsOfType <FireAtTarget>(); GrimmballFireReal.oldAttack = currentFAT; currentFAT.spread = 0.0f; GetChild currentGetChild = shootYouFool.GetActionsOfType <GetChild>()[0]; shootYouFool.RemoveActionsOfType <GetChild>(); currentGetChild.childName = "Grimmball(Clone)"; SetFsmInt currentSetFSMInt = shootYouFool.GetActionsOfType <SetFsmInt>()[0]; shootYouFool.RemoveActionsOfType <SetFsmInt>(); // Reorder these things to make sense shootYouFool.AddAction(currentGetChild); shootYouFool.AddAction(currentSetFSMInt); shootYouFool.AddAction(currentFAT); GameObject gcRangeObj = grimmchild.FindGameObjectInChildren("Enemy Range"); //GrimmEnemyRange rangeDelete = gcRangeObj.GetComponent<GrimmEnemyRange>(); //Destroy(rangeDelete); gcRangeObj.AddComponent <GrimmballFireReal>(); FsmState targetScan = gcFSM.GetState("Check For Target"); CallMethodProper rangeDetect = targetScan.GetActionsOfType <CallMethodProper>()[0]; rangeDetect.methodName.Value = "GetTarget"; rangeDetect.behaviour.Value = "GrimmballFireReal"; setVolumeLevels(); } gcFSM.SetState("Init"); //grimmchild.PrintSceneHierarchyTree("modgrimmchild.txt"); done = true; }