void Standing() { //Orientation = (int)Mathf.Sign(TargePosition.x - thisTransform.position.x); Orientation = (int)Mathf.Sign(PlayerTransform.position.x - thisTransform.position.x); if (Attack == AttackState.AttackRay) { Anime.PlayFrames(0 + HoldStaff, 3, 1, Orientation); } else { Anime.PlayFrames(0 + HoldStaff, 0, 1, Orientation); } }
void StandBy() { Chain.MoveStyle = SpriteChain.TranslationMode.Smooth; Head.PlayFrames(1, 1, 1, Orientation); NewPosition = new Vector3(NewPosition.x + (Time.deltaTime * 3 * Orientation), horizon + (Mathf.Sin(Time.time * 2) * (BossArea.height * .5f)), -1); // Max Height taken if (NewPosition.x > BossArea.xMax - 4 && Orientation == +1) { AttackRange++; Orientation = -1; } if (NewPosition.x < BossArea.xMin + 4 && Orientation == -1) { AttackRange++; Orientation = +1; } if ((thisTransform.position.x - Managers.Game.PlayerPrefab.transform.position.x) < 2 && Mathf.Abs(thisTransform.position.y - Managers.Game.PlayerPrefab.transform.position.y) < 2) { PlayerHeight = Managers.Game.PlayerPrefab.transform.position.y; MboiTuiState = BossState.Talking; Talking = true; } }
// Use this for initialization void Start() { Anime = GetComponentInChildren <AnimSprite>(); thisTransform = transform; playerTransform = Managers.Game.PlayerPrefab.transform; if (Managers.Register.MagicBlockEnabled) { Anime.PlayFrames(6, 0, 1, 1); } else { Anime.PlayFrames(6, 1, 1, 1); } }
void Roam() { if (TreeTransform == null) // The obj Instantiation is slow so AoAO keeps looking for The tree transform { GameObject Tree = GameObject.FindGameObjectWithTag("Platform"); if (Tree) { TreeTransform = Tree.transform; TreeScript = TreeTransform.GetComponentInChildren <AoAoThing>(); } } AoAnim.PlayFrames(1, 0, 4, Orientation); NewPosition = new Vector3(NewPosition.x + (Time.deltaTime * Orientation), NewPosition.y, .15f); if (NewPosition.x > LevelArea.xMax) { Orientation = -1; } if (NewPosition.x < LevelArea.xMin) { Orientation = +1; } if (PlayerTransform == null && Managers.Game.PlayerPrefab) { PlayerTransform = Managers.Game.PlayerPrefab.transform; BossArea.center = new Vector2(PlayerTransform.position.x, PlayerTransform.position.y + 0.5f); TargetTransform = PlayerTransform; NewPosition = new Vector3(BossArea.xMax, PlayerTransform.position.y + 2, PlayerTransform.position.z); LevelArea = Managers.Display.cameraScroll.levelBounds; ThisTransform.GetComponent <Rigidbody>().useGravity = true; AoAoState = BossState.Roaming; } else if (PlayerTransform && Mathf.Abs(PlayerTransform.position.x - NewPosition.x) < 3) { Talking = true; AoAoState = BossState.Talking; } }
void OnTriggerStay(Collider hit) { if (hit.tag == "Player") { if (playerTransform.position.x > thisTransform.position.x && !Managers.Register.MagicBlockEnabled) { Managers.Audio.Play(SwitchFx, thisTransform); Managers.Register.MagicBlockEnabled = true; Anime.PlayFrames(6, 0, 1, 1); } else if (playerTransform.position.x < thisTransform.position.x && Managers.Register.MagicBlockEnabled) { Managers.Audio.Play(SwitchFx, thisTransform); Managers.Register.MagicBlockEnabled = false; Anime.PlayFrames(6, 1, 1, 1); } } }
void Update() { switch (currentType) { case AnimationType.Default: simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); break; } }
IEnumerator Sleeping() { if (AnimFlag) { velocity = Vector3.zero; animPlay.PlayFrames(0, 0, 4, orientation, 2); // Do zzZZZ Animation if (distanceToTarget <= AlertRangeX2) { AnimFlag = false; float groundPosition = thisTransform.position.y; float timertrigger = Time.time + 0.55f; while (timertrigger > Time.time) { thisTransform.position = new Vector3(thisTransform.position.x, groundPosition + Mathf.Sin((timertrigger - Time.time) * 5) * .5f, thisTransform.position.z); animPlay.PlayFramesFixed(1, 0, 2, orientation); // Do Wake up Animation if (enemyState != ShooterState.Sleeping) { thisTransform.position = new Vector3(thisTransform.position.x, groundPosition, thisTransform.position.z); AnimFlag = true; yield break; } yield return(0); } thisTransform.position = new Vector3(thisTransform.position.x, groundPosition, thisTransform.position.z); AnimFlag = true; enemyState = ShooterState.Alert; yield break; } } }
void AttackRay() { //Debug.Log("Using Ray Attack"); if (timeLapse == 0) { Orientation = (int)Mathf.Sign(PlayerTransform.position.x - thisTransform.position.x); Managers.Audio.Play(Laser, thisTransform); } timeLapse += Time.deltaTime; if (timeLapse < 1.5f) { lightHead.SetActive(true); lightHead.transform.position = thisTransform.position + (Vector3.right * Orientation) + Vector3.back; lightHeadAnim.PlayFrames(5, 6, 2, Orientation); lightStart.SetActive(false); lightTrace.SetActive(false); } if (timeLapse > 1.5f && timeLapse < 2) { lightHead.SetActive(false); lightStart.SetActive(true); lightStart.transform.position = thisTransform.position + (Vector3.right * Orientation) + Vector3.down * .1f; lightStartAnim.PlayFrames(5, 0, 3, Orientation); lightTrace.SetActive(true); lightTrace.transform.position = thisTransform.position + (Vector3.right * 11.5f * Orientation) + Vector3.down * .1f; } if (timeLapse > 2) { timeLapse = 0; lightStart.SetActive(false); lightTrace.SetActive(false); lightHead.SetActive(false); //CheckAttack(); timeState += 2; Attack = AttackState.NoAttack; } }
void Starting() { Orientation = (int)Mathf.Sign(PlayerTransform.position.x - ThisTransform.position.x); if (TimeLapse == 0) { TimeLapse = Time.time + 4; } if (TimeLapse > Time.time) { AoAnim.PlayFrames(0, 2, 2, Orientation); } else { TimeLapse = 0; CurrentState = SceneState.Collapse; } }
void Start() // BallScript ballScript = target.GetComponent<BallScript>() as BallScript; { thisTransform = transform; controller = GetComponent <CharacterController>(); properties = GetComponent <PlayerProperties>(); animPlay = GetComponent <AnimSprite>(); animPlay.PlayFrames(2, 0, 1, orientation); Physics.IgnoreCollision(controller.collider, transform.GetComponentInChildren <BoxCollider>()); Collider = transform.GetComponentInChildren <BoxCollider>(); if (Managers.Register.PlayerAutoRunning) { UpdateInput = new InputDelegate(ControlAuto); } else { UpdateInput = new InputDelegate(ControlClassic); } }
//void SinAttack() //{ // Chain.MoveStyle = SpriteChain.TranslationMode.Retro; // Head.PlayFrames(0, 1, 1, Orientation); // NewPosition = new Vector3(NewPosition.x + (TimeLapse.deltaTime * 3 * Orientation), // horizon + (Mathf.Sin(TimeLapse.time * 3) * 1.5f), -1); // if (NewPosition.x > BossArea.xMax && Orientation == +1) // { // AttackRange++; // Orientation = -1; // } // if (NewPosition.x < BossArea.xMin && Orientation == -1) // { // AttackRange++; // Orientation = +1; // } // if (AttackRange > 3) // { // AttackRange = 0; // MboiTuiState = BossState.Roaming; // } //} void StandBy() { if (!Managers.Game.PlayerPrefab) { return; } else if (!PlayerTransform) { PlayerTransform = Managers.Game.PlayerPrefab.transform; PlayerHeight = PlayerTransform.position.y; } Chain.MoveStyle = SpriteChain.TranslationMode.Smooth; Head.PlayFrames(0, 1, 1, Orientation); NewPosition = new Vector3(NewPosition.x + (Time.deltaTime * 3 * Orientation), horizon + (Mathf.Sin(Time.time * 2) * (BossArea.height * .5f)), -1); // Max Height taken if (NewPosition.x > BossArea.xMax - 4 && Orientation == +1) { AttackRange++; Orientation = -1; } if (NewPosition.x < BossArea.xMin + 4 && Orientation == -1) { AttackRange++; Orientation = +1; } if ((thisTransform.position.x - Managers.Game.PlayerPrefab.transform.position.x) < 2) { Managers.Audio.PlayMusic(BossMusic, 0.75f, 1); MonaiState = BossState.Talking; Talking = true; } }
public override void OnUpdate() { if (timeLapse > Time.time) { Target.GetComponent <CameraTargetAttributes>().distanceModifier = 0.05f; } else { Target.GetComponent <CameraTargetAttributes>().distanceModifier = 2; } if (Target != null) // Pombe Animation { Target.transform.position = Vector3.Lerp(Target.transform.position, OptionsList[(int)ChooseOption].Position, Time.deltaTime * 5); if (Mathf.Abs(Target.transform.position.x - OptionsList[(int)ChooseOption].Position.x) < 0.01f) { MiniAnim.PlayFrames(4, 4, 1, (int)Mathf.Sign(OptionsList[(int)ChooseOption].Position.x - Target.transform.position.x)); } else { MiniAnim.PlayFrames(4, 4, 3, (int)Mathf.Sign(OptionsList[(int)ChooseOption].Position.x - Target.transform.position.x)); } } if (Input.GetButtonDown("Fire1") || Input.GetKeyDown("return") || Input.GetButtonDown("Start")) { timeLapse = Time.time + 0.75f; Managers.Audio.Play(Play, Managers.Display.camTransform); MapSelected = true; } if (MapSelected) { if (timeLapse > Time.time) { return; } Managers.Display.ShowFlash(1); MapSelected = false; switch (ChooseOption) { case 0: Managers.Game.PushState(typeof(WorldState0)); // Pampero World break; case 1: Managers.Game.PushState(typeof(WorldState1)); // Monte World break; case 2: Managers.Game.PushState(typeof(WorldState2)); // Home World break; case 3: Managers.Game.PushState(typeof(DemoAdvise)); // Iguazu World // Managers.Game.PushState(typeof(WorldState3)); // Iguazu World break; case 4: Managers.Game.PushState(typeof(DemoAdvise)); // Iguazu World // Managers.Game.PushState(typeof(WorldState4)); // SkyField World break; case 5: Managers.Game.PushState(typeof(DemoAdvise)); // Iguazu World // Managers.Game.PushState(typeof(WorldState5)); // Impenetrable World break; } } else { #region Player Input Navigation if (Input.GetKeyDown("escape") || Input.GetButtonDown("Fire3") || Input.GetButtonDown("Select")) { Managers.Game.ChangeState(typeof(MainMenuState)); } //if (Input.GetKeyDown("up")) if (Managers.Game.InputUp) { if (ChooseOption == TotalOptions - 1) { ChooseOption = 0; } else if (OptionsList[(int)ChooseOption].Up > TotalOptions - 1) { ChooseOption = TotalOptions - 1; } else { ChooseOption = OptionsList[(int)ChooseOption].Up; } Managers.Audio.Play(Select, Managers.Display.camTransform); } if (Managers.Game.InputDown) { if (ChooseOption == 0 || (OptionsList[(int)ChooseOption].Down > TotalOptions - 1)) { ChooseOption = TotalOptions - 1; } else { ChooseOption = OptionsList[(int)ChooseOption].Down; } Managers.Audio.Play(Select, Managers.Display.camTransform); } if (Managers.Game.InputLeft) { if (OptionsList[(int)ChooseOption].Left > TotalOptions - 1) { ChooseOption = 0; } else { ChooseOption = OptionsList[(int)ChooseOption].Left; } Managers.Audio.Play(Select, Managers.Display.camTransform); } if (Managers.Game.InputRight) { if (OptionsList[(int)ChooseOption].Right > TotalOptions - 1) { ChooseOption = 1; } else { ChooseOption = OptionsList[(int)ChooseOption].Right; } Managers.Audio.Play(Select, Managers.Display.camTransform); } #endregion } }
void UpdatePlayerState() { // dead = ((playerState == 0) || ( playerState == PlayerState.WildFire )); // Yep, when pombero's on fire it's dead, bad id normal = ((playerState != 0) && ((playerState & PlayerState.WildFire) != PlayerState.WildFire)); inmune = !normal || ((playerState & PlayerState.Flickering) == PlayerState.Flickering); switch (playerState) { case PlayerState.Asleep: { animPlay.PlayFrames(4, 3, 1, playerControls.orientation); if (changeState) { renderer.enabled = true; renderer.material.color = Color.white; playerControls.enabled = false; changeState = false; animPlay.PlayFrames(4, 3, 1, playerControls.orientation); StartCoroutine(Sleeping()); } if ((Input.GetButtonUp("Fire1") || Input.GetButtonUp("Jump")) && (Managers.Register.Lifes > 0)) { playerControls.enabled = true; SetPlayerState(PlayerState.Flickering); } break; } case PlayerState.WildFire: { Debug.Log("U are on Fire!"); playerState |= PlayerState.Normal; StartCoroutine(Burning()); break; } default: { playerState |= PlayerState.Normal; // This its needed in case of direct switch from Unity GUI drag & drop if ((playerState & PlayerState.Flickering) == PlayerState.Flickering) { if (changeState) { changeState = false; StartCoroutine(Flickering()); } } //if ((playerState & PlayerState.Invisible) == PlayerState.Invisible) // if (changeState) { changeState = false; StartCoroutine(Invisible()); } if (Input.GetButton("Fire1") && !HoldingKey) { StartCoroutine(PlayerThrows()); } else if (!_pickedObject && Input.GetButtonDown("Fire2")) { UseInventory(); } break; } } if ((playerState & PlayerState.Flickering) != PlayerState.Flickering || Managers.Register.Health == 0) { renderer.enabled = true; } }
//void Update() //{ // switch (currentType) // { // case AnimationType.Default: // simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); // break; // case AnimationType.Bird: // simpleAnim.PlayFramesFixed(RowStart, ColumnStart, TotalFrames, Orientation); // thisTransform.position += Vector3.up * Mathf.Sin(Time.time *3) * Time.deltaTime; // break; // case AnimationType.Fire: // simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); // counter += Time.deltaTime * 2; // renderer.material.SetFloat("_KeyY", counter); // counter %= 1; // //counter = Mathf.Repeat(counter, 1); // break; // case AnimationType.Water: // simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); // break; // } //} IEnumerator CoUpdate() { while (true) { switch (currentType) { case AnimationType.Default: simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); break; case AnimationType.Bird: simpleAnim.PlayFramesFixed(RowStart, ColumnStart, TotalFrames, Orientation); thisTransform.position += Vector3.up * Mathf.Sin(Time.time * 3) * Time.deltaTime; break; case AnimationType.Fire: //simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); //counter += Time.deltaTime * 2; //renderer.material.SetFloat("_KeyY", counter); ////counter %= 1; //counter = Mathf.Repeat(counter, 1); simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); renderer.material.SetFloat("_KeyY", Managers.Display.PaletteSwap); break; case AnimationType.RaveLight: simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation, 30); thisTransform.RotateAround(InitPos + Vector3.up, Vector3.forward, Mathf.Sin(Time.time)); break; case AnimationType.RaveGaucho1: thisTransform.position += Vector3.right * Mathf.Sin(Time.time * 3) * 2 * Time.deltaTime; simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, (int)-Mathf.Sign(Mathf.Sin(Time.time * 3))); break; case AnimationType.RaveGaucho2: if (Mathf.Sin(Time.time) > 0) { simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, (int)Mathf.Sign(Mathf.Sin(Time.time * 3)), 9); } else { simpleAnim.PlayFrames(1, 0, 2, (int)Mathf.Sign(Mathf.Sin(Time.time * 5)), 9); } break; case AnimationType.MateGaucho: if (Managers.Register.Treasure2) { GameObject Gaucho = null; if (Random.Range(0, 100) > 50) { Gaucho = (GameObject)Instantiate(Resources.Load("Prefabs/Gaucho", typeof(GameObject)), transform.position, transform.rotation); } else { Gaucho = (GameObject)Instantiate(Resources.Load("Prefabs/GauchoFacon", typeof(GameObject)), transform.position, transform.rotation); } Gaucho.transform.parent = Managers.Tiled.MapTransform; Destroy(gameObject); } else { simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); } break; case AnimationType.Kurupi: if (Managers.Game.PlayerPrefab != null) { if (Managers.Game.PlayerPrefab.transform.position.x > thisTransform.position.x) { Orientation = -1; } else { Orientation = 1; } } if (Mathf.Sin(Time.time) > 0) { simpleAnim.PlayFrames(RowStart, ColumnStart, TotalFrames, Orientation); } else { simpleAnim.PlayFrames(RowStart, ColumnStart + 1, TotalFrames, Orientation); } if (Managers.Register.MboiTuiDefeated) { Destroy(thisTransform.gameObject); } break; case AnimationType.Water: renderer.material.mainTextureOffset = Managers.Display.WaterFlow; // texture offset renderer.material.mainTextureScale = new Vector3(.125f, .125f); // texture scale break; case AnimationType.WaterAlpha: renderer.material.mainTextureOffset = Managers.Display.WaterFlowAlpha; // texture offset renderer.material.mainTextureScale = new Vector3(.125f, .125f); // texture scale break; } yield return(0); } }
void ControlAuto() { isHoldingObj = System.Convert.ToByte(properties._pickedObject != null); bool Stand = Physics.Linecast(thisTransform.position, thisTransform.TransformPoint(-Vector3.up), layerMask); Collider.center = Vector3.zero; if (controller.isGrounded) { runJumpEnable = false; velocity = new Vector3(Input.GetAxis("Horizontal"), 0, 0); if (Input.GetAxis("Horizontal") == 0) // IDLE -> keep stand quiet { animPlay.PlayFramesFixed(2 + isHoldingObj, 0, 1, orientation); } if (Input.GetAxis("Horizontal") != 0) // WALK { orientation = (int)(Mathf.Sign(velocity.x)); // If move direction changes -> flip sprite velocity.x *= walkSpeed; // If player is moving -> Animate Walking.. animPlay.PlayFramesFixed((0 + isHoldingObj), 0, 8, orientation); } if ((Mathf.Abs(Input.GetAxis("Horizontal")) >= 1) && !Input.GetButton("Fire1") && !Managers.Dialog.IsInConversation()) // RUN { velocity *= runSpeed; animPlay.PlayFramesFixed(2, 1, 2, orientation, 1.005f); } if (velocity.x == 0 && Input.GetAxisRaw("Vertical") < 0 && !Managers.Dialog.IsInConversation()) // Crouch { animPlay.PlayFrames(3, 3, 1, orientation); Collider.center = Vector3.down * 0.25f; } if (Input.GetButtonDown("Jump")) // Always running jump { velocity.y = runJump; //Instantiate ( particleJump, particlePlacement, transform.rotation ); Managers.Audio.Play(JumpSound, thisTransform, 1.0f, 0.75f); runJumpEnable = true; } } if (Input.GetButtonDown("Jump") && Stand) // slope jump { velocity.y = walkJump; Managers.Audio.Play(JumpSound, thisTransform, 1.0f, 1.25f); runJumpEnable = true; } if (!controller.isGrounded && !Stand) // && !Stand // Do Slide { velocity.x = Input.GetAxis("Horizontal"); //animPlay.PlayFrames ( 2, 5, 1, orientation ); if (Input.GetButtonUp("Jump")) // check if the player keep pressing jump button.. { velocity.y *= fallSpeed; // if not then brake the jump } if (velocity.x != 0) { orientation = (int)Mathf.Sign(velocity.x); // If move direction changes -> update & flip sprite } if (runJumpEnable) { velocity.x *= runSpeed; animPlay.PlayFrames(2 + isHoldingObj, 4, 1, orientation); } if (velocity.y < 0 && !Stand) // check when player stops elevation & becomes down.. { animPlay.PlayFrames(2 + isHoldingObj, 5, 1, orientation); if (Input.GetButton("Jump") && isHoldingObj == 0) // check if the player keep pressing jump button.. { velocity.y += 18 * Time.deltaTime; animPlay.PlayFrames(2, 6, 2, orientation); } } } if (controller.collisionFlags == CollisionFlags.Above) { velocity.y = 0; // set velocity on Y to 0, stop upward motion velocity.y -= afterHitForceDown; // apply force downward so player doesn't have in the air } if (properties.BurnOut) { BurnOut(); } velocity.y -= gravity * Time.deltaTime; controller.Move(velocity * Time.deltaTime); var Pos = thisTransform.position; Pos.z = Depth; thisTransform.position = Pos; thisTransform.rotation = Quaternion.Euler(0, 0, 0); }
void Update() { NewPosition = thisTransform.position; HoldingButton = Input.GetButtonDown("Fire1"); switch (YaguaState) { case BossState.Standby: Anime.PlayFrames(1, 0, 3, Orientation); if (!PlayerTransform) { if (Managers.Game.PlayerPrefab) { PlayerTransform = Managers.Game.PlayerPrefab.transform; } else { return; } } if (Mathf.Abs(PlayerTransform.position.x - thisTransform.position.x) < 4) { Managers.Audio.PlayMusic(BossMusic, 0.75f, 1); Talking = true; YaguaState = BossState.Talking; } break; case BossState.Talking: TalkingState(); break; case BossState.Standing: Stand(); break; case BossState.Running: Run(); break; case BossState.Firing: Fire(); break; case BossState.Hurting: Hurt(); break; case BossState.HeadLess: HeadLess(); break; case BossState.FriendShip: FriendShip(); GiveThanks(); break; case BossState.Escaping: Escape(); break; } thisTransform.position = NewPosition; //if (DisplayArea) //{ // Debug.DrawLine(new Vector2(BossArea.xMin, BossArea.yMin), new Vector2(BossArea.xMax, BossArea.yMin), Color.red); // Debug.DrawLine(new Vector2(BossArea.xMin, BossArea.yMax), new Vector2(BossArea.xMax, BossArea.yMax), Color.red); // Debug.DrawLine(new Vector2(BossArea.xMin, BossArea.yMin), new Vector2(BossArea.xMin, BossArea.yMax), Color.red); // Debug.DrawLine(new Vector2(BossArea.xMax, BossArea.yMin), new Vector2(BossArea.xMax, BossArea.yMax), Color.red); //} }