public override void Enter() { transition = m_EMFSM.emTransition; helper = m_EMFSM.emHelper; // Turn blink animation on EMAnimation.Instance().CanBlink = true; // Reset availability to command mini cell to Landmine state if (!helper.CanAddLandmine) { helper.CanAddLandmine = true; } // Enable expand animation if (!EMAnimation.Instance().IsExpanding) { EMAnimation.Instance().IsExpanding = true; } // Reset transition availability transition.CanTransit = true; // Pause the transition for randomized time float fPauseTime = Random.Range((m_EMFSM.CurrentAggressiveness / 1.5f) / EMDifficulty.Instance().CurrentDiff, (m_EMFSM.CurrentAggressiveness) / EMDifficulty.Instance().CurrentDiff); helper.StartPauseTransition(fPauseTime); }
// Enemy main nutrient getting absorbed and provide nutrient(child cell) to enemy main cell void Absorb() { Vector2 vectorToTarget = EMHelper.Instance().Position - (Vector2)transform.position; transform.position = Vector2.MoveTowards(transform.position, EMHelper.Instance().Position, (vectorToTarget.magnitude * fAbsorbTime + fAbsorbSpeed) * Time.deltaTime); transform.localScale = Vector3.one * (Vector2.Distance((Vector2)transform.position, EMHelper.Instance().Position)) / EMHelper.Instance().Radius * Random.Range(.5f, 1f); if (Vector2.Distance((Vector2)transform.position, EMHelper.Instance().Position) < .1f || transform.localScale.x < .1f) { if (Level_Manager.LevelID < 4) { EMController.Instance().AddFewNutrient((int)(Random.Range(2, 6) * EMDifficulty.Instance().CurrentDiff)); } else { EMController.Instance().AddFewChildCells((int)(Random.Range(2, 6) * EMDifficulty.Instance().CurrentDiff)); } if (!EMAnimation.Instance().IsExpanding) { EMAnimation.Instance().IsExpanding = true; } Destroy(this.gameObject); } }
// Update width of enemy main cell void WidthUpdate() { // Get the width without considering expand animation if (width != EMAnimation.Instance().InitialScale.x *Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(m_EMFSM.Health)))) { width = EMAnimation.Instance().InitialScale.x *Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(m_EMFSM.Health))); } }
public override void Exit() { transition = m_EMFSM.emTransition; // Reset animation status if (EMAnimation.Instance().CanBlink) { EMAnimation.Instance().CanBlink = false; } // Reset availability to command mini cell to Landmine state if (!helper.CanAddLandmine) { helper.CanAddLandmine = true; } // Reset transition availability transition.CanTransit = true; }
void Start() { if (instance == null) { instance = this; } // GetComponent thisRB = GetComponent <Rigidbody2D> (); thisRend = GetComponent <Renderer> (); // Initialization of state status fExpandScale = 1.25f; fLandmineExpandFactor = 3f; nDieAniPhase = 0; // Initialization of status bCanRotate = true; bCanBlink = false; bIsExpanding = false; bIsShrinking = false; fTargetSize = 0f; fBlinkElapsedTime = 0.0f; // Initialization of velocity fAngularVelocity = fAngularIniFactor * Random.Range(.75f, 1.25f); thisRB.angularVelocity = fAngularVelocity; if (fAngularVelocity >= 0f) { bIsRotatingLeft = false; } else { bIsRotatingLeft = true; } // Initialization of scale initialScale = gameObject.transform.localScale; currentScale = initialScale * Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(Mathf.Pow((float)EnemyMainFSM.Instance().Health, 1.5f)))); transform.localScale = (Vector3)currentScale; // Initialization of color defaultColor = thisRend.material.color; aggressiveColor = new Vector4(1f, 0.25f, 0.25f, 1f); cautiousColor = new Vector4(1f, 0.5f, 0.5f, 1f); landmineColor = new Vector4(1f, 0.5f, 0.5f, 1f); defendColor = Color.yellow; stunColor = new Vector4(0.6f, 0.6f, 0.6f, 1f); dieColor = new Vector4(0.6f, 0.6f, 0.6f, 1f); }
public override void Exit() { transition = m_EMFSM.emTransition; controller = m_EMFSM.emController; helper = m_EMFSM.emHelper; // Reset animation status if (EMAnimation.Instance().CanBlink) { EMAnimation.Instance().CanBlink = false; } // Reset availability to command mini cell to Defend state if (!helper.CanAddDefend) { helper.CanAddDefend = true; } // Set status to not defending controller.bIsDefend = false; // Reset transition availability transition.CanTransit = true; }
public override void Enter() { transition = m_EMFSM.emTransition; helper = m_EMFSM.emHelper; // Turn blink animation on EMAnimation.Instance().CanBlink = true; // Reset availability to command mini cell to Attack state if (!helper.CanAddAttack) { helper.CanAddAttack = true; } // Reset transition availability transition.CanTransit = true; // Pause the transition for randomized time float fPauseTime = Random.Range(Mathf.Sqrt(m_EMFSM.CurrentAggressiveness) * 1.5f / EMDifficulty.Instance().CurrentDiff, Mathf.Sqrt(m_EMFSM.CurrentAggressiveness) * 2.5f / EMDifficulty.Instance().CurrentDiff); helper.StartPauseTransition(fPauseTime); }
public override void Enter() { transition = m_EMFSM.emTransition; controller = m_EMFSM.emController; helper = m_EMFSM.emHelper; // Turn blink animation on EMAnimation.Instance().CanBlink = true; // Reset availability to command mini cell to Defend state if (!helper.CanAddDefend) { helper.CanAddDefend = true; } // Set status to defending controller.bIsDefend = true; // Reset transition availability transition.CanTransit = true; // Pause the transition for randomized time float fPauseTime = Random.Range(Mathf.Sqrt(Mathf.Sqrt((float)PlayerChildFSM.GetActiveChildCount() + 4f)) * 2f, Mathf.Sqrt((float)PlayerChildFSM.GetActiveChildCount() + 4f) * 2f); helper.StartPauseTransition(fPauseTime); }
void Start() { if (instance == null) instance = this; // GetComponent thisRB = GetComponent<Rigidbody2D> (); thisRend = GetComponent<Renderer> (); // Initialization of state status fExpandScale = 1.25f; fLandmineExpandFactor = 3f; nDieAniPhase = 0; // Initialization of status bCanRotate = true; bCanBlink = false; bIsExpanding = false; bIsShrinking = false; fTargetSize = 0f; fBlinkElapsedTime = 0.0f; // Initialization of velocity fAngularVelocity = fAngularIniFactor * Random.Range (.75f, 1.25f); thisRB.angularVelocity = fAngularVelocity; if (fAngularVelocity >= 0f) bIsRotatingLeft = false; else bIsRotatingLeft = true; // Initialization of scale initialScale = gameObject.transform.localScale; currentScale = initialScale * Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(Mathf.Pow((float)EnemyMainFSM.Instance().Health, 1.5f)))); transform.localScale = (Vector3)currentScale; // Initialization of color defaultColor = thisRend.material.color; aggressiveColor = new Vector4 (1f, 0.25f, 0.25f, 1f); cautiousColor = new Vector4 (1f, 0.5f, 0.5f, 1f); landmineColor = new Vector4 (1f, 0.5f, 0.5f, 1f); defendColor = Color.yellow; stunColor = new Vector4 (0.6f, 0.6f, 0.6f, 1f); dieColor = new Vector4 (0.6f, 0.6f, 0.6f, 1f); }