void Start() { maraptorP = this.GetComponent <maraptorBase> (); currentState = CharacterState.IDLE; // Starting state GSM = GameObject.Find("GameManager").GetComponent <GameStateMachine>(); // Comunicate with the GameStateMachine maraptorController = GetComponent <maraptorController> (); // Comunicate with the Atached Controller maraptorP.currentPosition = transform.position; // Current position initialisation }
// Use this for initialization void Start() { maraptorRB = GetComponent <Rigidbody2D> (); maraptorAnimator = GetComponent <Animator> (); maraptorP = this.GetComponent <maraptorBase> (); facingRight = true; fallDamage = 0; }
// Initialization void Start() { // Set the turnLenght turnLenght = 18; // Set the first turn to true firstTurn = true; // Populate the game objects for cosmonauts and maraptors Cosmonauts.AddRange(GameObject.FindGameObjectsWithTag("Cosmonaut")); Maraptors.AddRange(GameObject.FindGameObjectsWithTag("Maraptor")); // Populate the State Machines for cosmonauts and maraptors, editing their names and startup properites foreach (GameObject Cosmonaut in Cosmonauts) { cosmonautP = Cosmonaut.GetComponent <cosmonautBase> (); cosmonautP.name = Cosmonaut.transform.gameObject.name; cosmonautP.baseHP = 100; cosmonautP.currentHP = 100; cosmonautP.baseShield = 50; CosmonautStateMachines.Add(Cosmonaut.GetComponent <cosmonautStateMachine> ()); } foreach (GameObject Maraptor in Maraptors) { maraptorP = Maraptor.GetComponent <maraptorBase> (); maraptorP.name = Maraptor.transform.gameObject.name; maraptorP.baseHP = 100; maraptorP.currentHP = 100; maraptorP.baseShield = 50; MaraptorStateMachines.Add(Maraptor.GetComponent <maraptorStateMachine> ()); } // Get the numberOfCosmonauts and numberOfMaraptors numberOfCosmonauts = Cosmonauts.Count; numberOfMaraptors = Maraptors.Count; // Set the number of player characters and the number of played on characters numberOfPlayerCharacters = numberOfCosmonauts + numberOfMaraptors; numberOfPlayedOnCharacters = 0; // Get the MainCameraPlayer MainCameraPlayer = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <cameraFollowPlayer> ();; // Get the Action Menu AM = GameObject.Find("ActionMenu").GetComponent <actionMenuScript>(); // Start Game GameState = GameStateEnum.INTRO; turnTimer = 0; StartCoroutine("TurnTimerIncrementor"); }
// Use this for initialization void Start() { newLocalScale = transform.localScale; newLocalPosition = transform.localPosition; parentObject = this.transform.parent.gameObject; parentObjectTag = parentObject.tag; JumpBoostDuration = 6; JumpBoostTimer = 0; if (parentObject.tag == "Cosmonaut") { cosmonautP = parentObject.GetComponent <cosmonautBase> (); } else if (parentObject.tag == "Maraptor") { maraptorP = parentObject.GetComponent <maraptorBase> (); } }
// Update is called once per frame void Update() { // Update the Timer if (GSM.GameState == GameStateMachine.GameStateEnum.COSMONAUT_TURN || GSM.GameState == GameStateMachine.GameStateEnum.MARAPTOR_TURN) { TimerImage.fillAmount = ((GSM.turnTimer + 1 > GSM.turnLenght - 2) ? 1 : ((float)(GSM.turnTimer) / (GSM.turnLenght - 2))); Seconds.GetComponent <Text> ().text = (((GSM.turnLenght - 2 - GSM.turnTimer) > 0) ? (GSM.turnLenght - 2 - GSM.turnTimer) : 0).ToString(); } else { TimerImage.fillAmount = 0; Seconds.GetComponent <Text> ().text = string.Empty; } // Show/hide the attack button if (GSM.GameState == GameStateMachine.GameStateEnum.COSMONAUT_TURN) { if (!AttackButtonWrapper.activeSelf && (cosmonautP.rocketLauncher || cosmonautP.flameThrower)) { AttackButtonWrapper.SetActive(true); } else if (AttackButtonWrapper.activeSelf && !(cosmonautP.rocketLauncher || cosmonautP.flameThrower)) { AttackButtonWrapper.SetActive(false); } } else if (GSM.GameState == GameStateMachine.GameStateEnum.MARAPTOR_TURN) { if (!AttackButtonWrapper.activeSelf && (maraptorP.fireball || maraptorP.flameBreath)) { AttackButtonWrapper.SetActive(true); } else if (AttackButtonWrapper.activeSelf && !(maraptorP.fireball || maraptorP.flameBreath)) { AttackButtonWrapper.SetActive(false); } } else { AttackButtonWrapper.SetActive(false); } // disarming after waiting if (isWaiting && (wasWaitingDuringTheLastFrame == false)) { wasWaitingDuringTheLastFrame = true; } else if (!isWaiting && (wasWaitingDuringTheLastFrame == true)) { wasWaitingDuringTheLastFrame = false; if (CharacterToBeDisarmed.tag == "Cosmonaut") { cosmonautBase auxCosmonautP = CharacterToBeDisarmed.GetComponent <cosmonautBase> (); Animator auxCosmonautAnimator = CharacterToBeDisarmed.GetComponent <Animator> (); if (auxCosmonautP.rocketLauncher == true) { auxCosmonautP.rocketLauncher = false; // consumes the rocketlauncher auxCosmonautAnimator.SetBool("cosmonautRocketOn", auxCosmonautP.rocketLauncher); } else if (auxCosmonautP.flameThrower == true) { auxCosmonautP.flameThrower = false; // consumes the flamethrower auxCosmonautAnimator.SetBool("cosmonautFlameOn", auxCosmonautP.flameThrower); auxCosmonautP.transform.GetChild(0).gameObject.SetActive(auxCosmonautP.flameThrower); // turns off the range indicator } } else if (CharacterToBeDisarmed.tag == "Maraptor") { maraptorBase auxMaraptorP = CharacterToBeDisarmed.GetComponent <maraptorBase> (); Animator auxMaraptorAnimator = CharacterToBeDisarmed.GetComponent <Animator> (); if (auxMaraptorP.fireball == true) { auxMaraptorP.fireball = false; // consumes the fireball auxMaraptorAnimator.SetBool("maraptorBallOn", auxMaraptorP.fireball); } else if (auxMaraptorP.flameBreath == true) { auxMaraptorP.flameBreath = false; // consumes the flamebreath auxMaraptorAnimator.SetBool("maraptorFlameOn", auxMaraptorP.flameBreath); auxMaraptorP.transform.GetChild(0).gameObject.SetActive(auxMaraptorP.flameBreath); } } CharacterToBeDisarmed = null; AttackButton.GetComponent <Button> ().interactable = true; } }