// Use this for initialization public virtual void Start() { _anim = GetComponent <Animator> (); levelComplete = false; GameObject[] list = GameObject.FindGameObjectsWithTag("Player"); for (var i = list.Length - 1; i >= 0; i--) { PlayerControl p = list[i].GetComponent <PlayerControl>(); if (p != null) { player = p; break; } } chargeBar = GetComponentInChildren <ChargeBarScript> (); // TODO: Get references to all the SpawnZombie objects currently in the level. // Set the level boundaries. These form a trapezoid, which can be used to keep the enemies within. LevelBoundary.topWidth = rectTopWidth; // Use the enemies positions during game play to get these coordinates. LevelBoundary.bottomWidth = rectBottomWidth; // Widths are right-corner minus left corner. LevelBoundary.left = rectLeft; // Left is the left corner of the larger width (in this case, bottom) LevelBoundary.bottom = rectBottom; // Bottom is the lowest point in the boundary. LevelBoundary.height = rectHeight; // Height is top minus bottom. enemiesPacing = new ArrayList(); enemiesAttacking = new ArrayList(); }
new void Start() { _controller = GetComponent <MovementController2D> (); box = GetComponent <BoxCollider2D>(); dc = GetComponentInChildren <PlayerDamageCollider> (true); _chargeBar = GameObject.Find("InGameUI").GetComponentInChildren <ChargeBarScript>(); Debug.Log("******** NEW PLAYER - HAVE INSTANCE? " + GlobalControl.instance); if (GlobalControl.instance) { Debug.Log("******** YES! " + GlobalControl.instance.playerCP); _chargeBar.chargePercentage = GlobalControl.instance.playerCP; if (GlobalControl.instance.playerHP > 0) { playerHealth = GlobalControl.instance.playerHP; } else { playerHealth = 100; } GlobalControl.instance.resetPlayerStats(); } else { _chargeBar.chargePercentage = 0; playerHealth = 100; } _anim = GetComponent <Animator> (); PlayerAbstractBehaviour[] pabs = _anim.GetBehaviours <PlayerAbstractBehaviour> (); for (var i = pabs.Length - 1; i >= 0; i--) { pabs [i].player = this; } facingLeft = false; facingRight = true; dc.gameObject.SetActive(false); if (stunIcon != null) { stunIcon.SetActive(false); } setState(PlayerStates.mobile); }
void setState(TutorialState newState, float waitTime = -1) { Time.timeScale = 0.0f; player.setPlayerState(PlayerControl.PlayerStates.immobile); targetButton = ""; switch (newState) { case TutorialState.Normal: // Game plays normally. Time.timeScale = 1.0f; player.setPlayerState(PlayerControl.PlayerStates.mobile); player.PlayerAction(); _anim.SetTrigger("Tutorial0"); break; case TutorialState.TutorialDodge: _anim.SetTrigger("Tutorial1"); player.playerHealth = 1000; targetButton = "Dodge"; nextState = TutorialState.TutorialLight; break; case TutorialState.TutorialLight: _anim.SetTrigger("Tutorial2"); targetButton = "InputA"; nextState = TutorialState.TutorialMedium; break; case TutorialState.TutorialMedium: _anim.SetTrigger("Tutorial3"); targetButton = "InputB"; nextState = TutorialState.TutorialHeavy; break; case TutorialState.TutorialHeavy: _anim.SetTrigger("Tutorial4"); targetButton = "InputC"; nextState = TutorialState.TutorialRangedAttack; break; case TutorialState.TutorialRangedAttack: _anim.SetTrigger("Tutorial5"); targetButton = "InputD"; nextState = TutorialState.TutorialLightCombo; break; case TutorialState.TutorialLightCombo: _anim.SetTrigger("Tutorial6"); targetButton = "InputA"; nextState = TutorialState.TutorialChargedAttack; break; case TutorialState.TutorialChargedAttack: _anim.SetTrigger("Tutorial9"); targetButton = "InputD"; ChargeBarScript cb = GetComponentInChildren <ChargeBarScript>(); cb.chargePercentage = 100; nextState = TutorialState.TutorialFinale; break; case TutorialState.TutorialFinale: _anim.SetTrigger("Tutorial10"); nextState = TutorialState.Normal; Time.timeScale = 1.0f; player.setPlayerState(PlayerControl.PlayerStates.mobile); player.playerHealth = 100; for (int i = bullies.Length - 1; i >= 0; i--) { // Last part of tutorial. Make bullies invincible. bullies[i].invincible = true; bullies[i].setEnemyState(AbstractEnemyControl.EnemyStates.move); bullies[i].setEnemyDamage(25); } break; } if (waitTime > 0) { // Setup a wait timer to tick down and automatically call the next state. waitTimer = waitTime; } state = newState; }