private void Setup() { moveDirection = Vector3.zero; controlRotation = MovementLR.None; controlFB = MovementFB.None; controlLR = MovementLR.None; movementJump = isRunning = InCombat = false; // crc.IsFalling = crc.IsDecending = crc.IsGrounded = InCombat = false; }
/** * MoveTo(Sector targetSector): * This method move the unit into the target sector, capturing it and levelling up if necessary. * It also detects if the targetSector contains a PVC and calls the PVC minigame if the targetSector * is not owned by the unit's owner and the owner is human. */ public void MoveTo(Sector targetSector) { if (this.sector != null) // clear the unit's current sector { this.sector.ClearUnit(); } this.sector = targetSector; //set the unit's sector to the target sector. targetSector.SetUnit(this); //set the target sector's unit to the unit Transform targetTransform = targetSector.transform.Find("Units").transform; transform.SetParent(targetTransform); //set the unit's transform to be a child of the target sector's transform transform.position = targetTransform.position; // align the transform to the sector if (targetSector.GetOwner() != this.owner) // if the target sector belonged to a different player than the unit, capture it and level up { //ADDITION: 13/02/18 this will allow the beer/knowledge scores of the previous owner to decrease. if (targetSector.GetPVC() == true && targetSector.GetOwner() != null) { GameObject Catcher = GameObject.Find("Catcher"); MovementLR CatcherMovement = Catcher.GetComponent <MovementLR>(); int currentBeer = targetSector.GetOwner().GetBeer(); int currentBook = targetSector.GetOwner().GetKnowledge(); targetSector.GetOwner().SetBeer(currentBeer - CatcherMovement.GetlastBeer()); targetSector.GetOwner().SetKnowledge(currentBook - CatcherMovement.GetlastBook()); } LevelUp(); owner.Capture(targetSector); // capture the target sector for the owner of this unit //ADDITION: 13/02/18 This detects if the target sector contains a PVC, and if so runs the minigame. if (targetSector.GetPVC() == true) { GameObject Catcher = GameObject.Find("Catcher"); MovementLR CatcherMovement = Catcher.GetComponent <MovementLR>(); if (this.owner.GetType() == typeof(NonHumanPlayer)) //ADDITION: 14/02/18 added a check if the AI captures a PVC { CatcherMovement.lastpersonBeerScore = 4; //Give the AI 2 beer & 2 books for catching the PVC. CatcherMovement.lastpersonBookScore = 4; owner.SetBeer(owner.GetBeer() + 2); owner.SetKnowledge(owner.GetKnowledge() + 2); } else { CatcherMovement.StartDropperGame(this); //Start the minigame if player is human. } } } }
/** * Update(): * Called once per frame and is used to control the rotation of the item. * It also checks to see if the item has been caught by the catcher or if it has been missed. * ADDITION: 12/02/18 */ void Update() { GameObject catcher = GameObject.Find("Catcher"); MovementLR Store = catcher.GetComponent <MovementLR>(); transform.Rotate(Vector3.forward * rotateSpeed * Time.deltaTime); if (transform.position.y < 35 && transform.position.y > 25 && transform.position.x > catcher.transform.position.x - 25 && transform.position.x < catcher.transform.position.x + 25) { Store.BeerScore = Store.BeerScore + BeerScore; Store.BookScore = Store.BookScore + BookScore; Destroy(gameObject); } if (transform.position.y < 0) { Destroy(gameObject); } }
/* * CHANGED: 01/02/18 * Removed duplication. Calls UpdateAccessible instead. */ void Update() { // if test mode is not enabled and the dropper game is not playing. if (!testMode) { //ADDITION: 14/02/18 added a restriction so that the game does not progress when the minigame is playing. MovementLR dropperGame = GameObject.Find("Catcher").GetComponent <MovementLR>(); if (dropperGame.stopped) { /* * ADDITION: 11/02/2018 * Checks if the ESCAPE key has been pressed */ if (Input.GetKeyDown(KeyCode.Escape)) { menu.SetActive(true); } this.UpdateAccessible(); } } }