private void StartTimerScream() { timerScream.StartCoolDown(ExtRandom.GetRandomNumber(iaScream.x, iaScream.y)); }
public void Subdivide(LeModule.axis axis) { subdivisionAxis = axis; if (children == null) { children = new List <LeModule>(); } // Create modules if this is the first time we've been divided while (children.Count < 2) { var go = new GameObject(); go.transform.SetParent(this.transform); go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; var node = go.AddComponent <LeModule>(); children.Add(node); node.parent = this; var prefab = Resources.Load <GameObject>("Prefabs/Cube"); node.go = GameObject.Instantiate(prefab); node.go.transform.SetParent(node.transform); node.go.transform.localPosition = Vector3.zero; node.go.transform.localRotation = Quaternion.identity; Debug.Log(uid + " Added child"); } if (children != null) { if (children.Count < 2) { Debug.LogError(uid + " childNodes.Count < 2"); return; } } else { Debug.LogError(uid + " childNodes list == null"); return; } // Get a list containing two modulor values List <float> ms = new List <float>(); foreach (LeModule child in children) { switch (subdivisionAxis) { case axis.x: ms = Modulor.GetList(size.x, 2); break; case axis.y: ms = Modulor.GetList(size.y, 2); break; case axis.z: ms = Modulor.GetList(size.z, 2); break; } } // Check sizes to see if they are out of bounds foreach (var value in ms) { } // Revese the list randomly if (ExtRandom <bool> .Chance(1, 2)) { ms.Reverse(); } for (int i = 0; i < children.Count; i++) { switch (subdivisionAxis) { case axis.x: children[i].size.x = ms[i]; break; case axis.y: children[i].size.y = ms[i]; break; case axis.z: children[i].size.z = ms[i]; break; } } foreach (LeModule child in children) { var scale = child.go.transform.localScale; switch (subdivisionAxis) { case axis.x: scale.x = child.size.x; scale.y = size.y; scale.z = size.z; break; case axis.y: scale.x = size.x; scale.y = child.size.y; scale.z = size.z; break; case axis.z: scale.x = size.x; scale.y = size.y; scale.z = child.size.z; break; } child.go.transform.localScale = scale; } // Effect position // index 0 pos = index 1 scale / 2 // index 1 should be moved the scale of index 0 / 2 foreach (LeModule child in children) { var pos = child.transform.localPosition; int childIndex = children.IndexOf(child); if (childIndex == 0) { switch (subdivisionAxis) { case axis.x: pos.x = children[1].size.x / 2 * -1; pos.y = 0; pos.z = 0; break; case axis.y: pos.x = 0; pos.y = children[1].size.y / 2 * -1; pos.z = 0; break; case axis.z: pos.x = 0; pos.y = 0; pos.z = children[1].size.z / 2 * -1; break; } } else if (childIndex == 1) { switch (subdivisionAxis) { case axis.x: pos.x = children[0].size.x / 2; pos.y = 0; pos.z = 0; break; case axis.y: pos.x = 0; pos.y = children[0].size.y / 2; pos.z = 0; break; case axis.z: pos.x = 0; pos.y = 0; pos.z = children[0].size.z / 2; break; } } else { Debug.LogError(uid + "Index should not be greater than 1"); } child.transform.localPosition = pos; } // Set the size of the un effected axises to the values in the parent foreach (LeModule child in children) { switch (subdivisionAxis) { case axis.x: child.size.y = size.y; child.size.z = size.z; break; case axis.y: child.size.x = size.x; child.size.z = size.z; break; case axis.z: child.size.x = size.x; child.size.y = size.y; break; } } // Hide self foreach (LeModule item in children) { item.go.SetActive(true); } go.SetActive(false); }
private void Start() { timeSpawn.StartCoolDown(timeToSpawn + ExtRandom.GetRandomNumber(0.0f, timeToAddRandom)); }
private void Spawn() { ObjectsPooler.Instance.SpawnFromPool(GameData.PoolTag.IA, posSpawn.position, posSpawn.rotation, transform); timeSpawn.StartCoolDown(timeToSpawn + ExtRandom.GetRandomNumber(0.0f, timeToAddRandom)); }
public void SetRandomJump() { //all button Jump = ExtRandom.GetRandomBool(); JumpUp = false; }
private void Start() { SetRotation(ExtRandom.GetRandomVectorNormalized()); }
/// <summary> /// tout les input du jeu, à chaque update /// </summary> public void SetRandomInput() { //all axis moveInput = new Vector2(ExtRandom.GetRandomNumber(-1f, 1f), ExtRandom.GetRandomNumber(-1f, 1f)); }
/// <summary> /// STATE MACHINE FOR CUCA AI /// </summary> public void Machine() { Vector3 vectDir; Vector2 stopVect; TestToSetAttacking(); TestToAttack(); IsCloseToPlayer(); float x, y; int randInt = 0; if (cuca.IsDying) { return; } switch (state) { // IDLE //===--- case 0: //Don't move { stopVect = new Vector2(cuca.rb.transform.forward.x, cuca.rb.transform.forward.z); cuca.ChangeDirectionIA(new Vector2(stopVect.x * 0.0001f, stopVect.y * 0.0001f)); if (cuca.GetAttacking()) { state = 2; break; } else { randInt = Random.Range(0, 5); if (randInt == 1) { state = 1; break; } } break; } case 1: //Crawl { stopVect = new Vector2(cuca.rb.transform.forward.x, cuca.rb.transform.forward.z); x = ExtRandom.GenerateNormalRandom(0.0f, 0.5f); y = ExtRandom.GenerateNormalRandom(0.0f, 0.5f); if (Random.Range(0, 100) == 1) { cuca.ChangeDirectionIA(new Vector2(stopVect.x + x + 5.0f, stopVect.y + y + 5.0f)); } else { cuca.ChangeDirectionIA(new Vector2(stopVect.x + x, stopVect.y + y)); } if (cuca.GetAttacking()) { state = 2; break; } state = 0; break; } case 2: // Forward food { GameObject target = cuca.refToFollow; if (!target) { state = 0; break; } vectDir = -(cuca.rb.transform.position - target.transform.position); // Create vector for direction vectDir.Normalize(); cuca.ChangeDirectionIA(new Vector2(vectDir.x * 1, vectDir.z * 1)); // change dir if (!cuca.GetAttacking()) { state = 0; break; } else { randInt = Random.Range(0, 2); if (randInt == 1) { state = 3; break; } } break; } case 3: // Forward food with variations in direction { GameObject target = cuca.refToFollow; if (!target) { state = 0; break; } vectDir = -(cuca.rb.transform.position - target.transform.position); vectDir.Normalize(); x = ExtRandom.GenerateNormalRandom(0.0f, 0.3f); y = ExtRandom.GenerateNormalRandom(0.0f, 0.3f); cuca.ChangeDirectionIA(new Vector2((vectDir.x + x) * 1, (vectDir.y + y) * 1)); if (!cuca.GetAttacking()) { state = 0; break; } else { state = 2; break; } } } }
/// <summary> /// called for getting a player position /// </summary> /// <returns></returns> private Vector3 GetPosSpawn() { Pointf point = new Pointf(0.0f, 0.0f); bool isInside = false; int randomList = UnityEngine.Random.Range(0, 100); float actualPertentage = 0; for (int i = 0; i < spawnPoint.Count; i++) { if (randomList >= actualPertentage && randomList <= actualPertentage + spawnPoint[i].percentage) { //ici ok point.x = spawnPoint[i].spawn.position.x + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); point.y = spawnPoint[i].spawn.position.z + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); isInside = true; break; } actualPertentage += spawnPoint[i].percentage; } if (!isInside) { point.x = spawnPoint[0].spawn.position.x + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); point.y = spawnPoint[0].spawn.position.z + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); } return(new Vector3(point.x, 0, point.y)); }
/// <summary> /// get a random color, with alpha 1 /// </summary> /// <returns></returns> public static Color GetRandomColorSeed(System.Random randomSeed) { return(ExtRandom.GetRandomColorSeed(randomSeed)); }
/// <summary> /// get a random color /// </summary> /// <returns></returns> public static Color GetRandomColor() { return(ExtRandom.GetRandomColor()); }