void AnimateOnce() { Debug.Log("animating"); GameObject animateObj = OT.CreateObject("fireball"); animateMe = animateObj.GetComponent("OTAnimatingSprite") as OTAnimatingSprite; animateMe.PlayOnce("fire"); }
void OnTriggerEnter(Collider other) { if (other.name.Equals("Player")) { // Explode when the player touches it OTAnimatingSprite explode = Instantiate(animExplosion) as OTAnimatingSprite; explode.transform.position = transform.position + Vector3.up * 1f; explode.PlayOnce("explode"); // Cast a damage to the player Player.UpdateHP(damage * -1); // Hide the sprite sprite.visible = false; } }
void Update() { if (currentHP <= 0) { if (!dying) { GameState.AvailableMoney += Money; dying = true; collider.enabled = false; Sprite.PlayOnce("Dying"); Sprite.onAnimationFinish = delegate { Destroy(gameObject); }; } } }
// Update is called once per frame void Update() { // Reload if (this.missile == null) { // Cooldown if (this.timeBeforeNextFire <= 0.0f) { this.collider.enabled = true; Sprite.PlayOnce("Idle"); } else { this.timeBeforeNextFire -= Time.deltaTime; } } }
// Update is called once per frame void Update() { // only go one if Orthello is initialized if (!OT.isValid) { return; } // We call the application initialization function from Update() once // because we want to be sure that all Orthello objects have been started. if (!initialized) { Initialize(); return; } // Rotate the gun animation sprite towards the mouse on screen gun.RotateTowards(OT.view.mouseWorldPosition); // Rotate our bullet prototype as well so we will instantiate a // 'already rotated' bullet when we shoot // check if the left mouse button was clicked if (Input.GetMouseButtonDown(0)) { // Create a new bullet OTSprite nBullet = OT.CreateSprite("bullet"); // Set bullet's position at approximately the gun's shooting barrel nBullet.position = gun.position + (gun.yVector * (gun.size.y / 2)); nBullet.rotation = gun.rotation; // Play the gun's shooting animation frameset once gun.PlayOnce("shoot"); } //If we have less than 15 objects within Orthello we will create a random asteroid if (OT.objectCount <= 15) { RandomBlock(OT.view.worldRect, 0.6f, 1.2f, null); } }
// Update is called once per frame void Update () { Vector3 moveRequest = new Vector3(); moveRequest = new Vector3(Input.GetAxisRaw("Horizontal"), 0.0f, 0.0f); WalkDirection direction = currentWalkDirection; if (moveRequest.sqrMagnitude > 0.0) { moveRequest.Normalize(); if (moveRequest.x > 0) { direction = WalkDirection.RIGHT; } else { direction = WalkDirection.LEFT; } } if(Input.GetKeyDown(KeyCode.Z) && !isCurrentlySwinging) { isCurrentlySwinging = true; OTAnimatingSprite sprite = GetComponent<OTAnimatingSprite>(); if(direction == WalkDirection.LEFT) { sprite.PlayOnce("catchLeft"); } else { sprite.PlayOnce("catchRight"); } sprite.Play(); sprite.onAnimationFinish = OnSwingDone; } if(isCurrentlySwinging) { float netXCoord; if(direction == WalkDirection.LEFT) { netXCoord = -64.0f; } else { netXCoord = 24.0f; } Rect net = new Rect(this.transform.position.x + netXCoord, this.transform.position.y - 30f, 40f, 60f); bool captured = fireflies.Captures(net); if(captured) { Debug.Log ("Got one!"); pickupSound.Play(); OTAnimatingSprite firefly = (OTAnimatingSprite) OT.CreateSprite("Firefly"); firefly.GetComponent<Firefly>().enabled = false; firefly.depth = -100; firefly.size = new Vector2(64f, 64f); firefly.pivot = OTObject.Pivot.BottomLeft; firefly.PlayLoop("right"); uiFireflies.Add (firefly); OnSwingDone(null); } } moveRequest *= Time.deltaTime * moveSpeed; bool wasFalling = falling; falling = terrain.CanMoveTo(this.transform.localPosition.x, this.transform.localPosition.y - 1.2f, collidingBox); if(!falling && !terrain.CanMoveTo(this.transform.localPosition.x + moveRequest.x * 10f, this.transform.localPosition.y - 1.2f, collidingBox)) { lastJumpPos = this.transform.localPosition; lastJumpCount = uiFireflies.Count; } moveRequest = terrain.Move(this.transform.localPosition, collidingBox, moveRequest); this.transform.Translate(moveRequest); if(wasFalling && !falling) { landSound.Play(); } if(!falling && verticalSpeed < 0f) { verticalSpeed = 0f; if(Input.GetKeyDown(KeyCode.Space)) { jumpSound.Play(); verticalSpeed = jumpSpeed; } } Fall(); UpdateAnimation(moveRequest.sqrMagnitude > 0.0, direction); currentWalkDirection = direction; UpdateDialog(); UpdateEvents(); UpdateUISprites(); if(this.transform.localPosition.y < 100) { this.transform.localPosition = lastJumpPos; while(uiFireflies.Count > lastJumpCount) { uiFireflies.RemoveAt(0); } } }