// Update is called once per frame void Update() { if (GameState.CurrentGameState != GameState.EGameState.GameState_Active) { return; } if (armed) { armedTimer -= Time.deltaTime; if (armedTimer <= 0.0f) { // TODO : WE EXPLODE GameObject[] divers = GameObject.FindGameObjectsWithTag("diver"); for (int i = 0; i < divers.Length; ++i) { GameObject diver = divers[i]; float distance = (diver.transform.position - transform.position).magnitude; if (distance <= bombRadius) { diver.gameObject.SendMessage("OnDie", SendMessageOptions.DontRequireReceiver); } } armed = false; sprite.SetSizeXY(3.0f, 3.0f); sprite.PlayAnim("Explode"); sprite.SetAnimCompleteDelegate(delegate() { Destroy(transform.parent.gameObject); }); Messenger <string> .Invoke("OnPlaySFX", "Explosion_4"); } } }
// Update is called once per frame void Update() { // if (Input.GetKeyDown("y")) // weaponSprite.PlayAnim("idle"); // if (Input.GetKeyDown("u")) // weaponSprite.PlayAnim("shoot"); if (weaponSprite.isPlaying != "shoot") { weaponSprite.PlayAnim("idle"); } if (attackSpeed > 0) { attackSpeed -= Time.deltaTime * 100; } if (animateAttackTime > 0) { animateAttackTime -= Time.deltaTime * 100; transform.localPosition = localAniPos; if (animateAttackTime < 0) { transform.localPosition = localPos; } } }
// Use this for initialization void Start() { sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 15); anim.name = "Idle"; anim.loopCycles = -1; sprite.AddAnimation(anim); anim = new UVAnimation(); firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127)); cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 30); anim.name = "Arm"; anim.loopCycles = -1; sprite.AddAnimation(anim); anim = new UVAnimation(); firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(256, 383)); cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 8, 30); anim.name = "Explode"; anim.loopCycles = 1; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); }
// Use this for initialization void Start() { agent = gameObject.GetComponent <Seeker>(); controller = gameObject.GetComponent <CharacterController>(); spriteManager = gameObject.GetComponent <SpriteManager>() as SpriteManager; evilSprite = spriteManager.AddSprite(gameObject, 2.0f, 2.0f, spriteManager.PixelSpaceToUVSpace(256, 256), spriteManager.PixelSpaceToUVSpace(50, 50), false); evilSprite.SetAnimCompleteDelegate(OnAnimateComplete); Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace(50, 50); //Idle animation UVAnimation idleAnimation = new UVAnimation(); Vector2 idleStartPosUV = spriteManager.PixelCoordToUVCoord(0, 50); idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, 3, 2, 6, 15); idleAnimation.loopCycles = -1; idleAnimation.name = "idle"; evilSprite.AddAnimation(idleAnimation); evilSprite.PlayAnim("idle"); gameObject.transform.position = startPos; }
// Use this for initialization public override void Start() { base.Start(); GetComponent <SimpleFollow>().enabled = false; sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15); anim.name = "Idle"; anim.loopCycles = -1; sprite.AddAnimation(anim); anim = new UVAnimation(); firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383)); cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15); anim.name = "Die"; anim.loopCycles = 0; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); }
// Use this for initialization void Start() { sprite = spriteManager.AddSprite(gameObject, width, height, 0, 511, 512, 512, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 511)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15); anim.name = "Idle"; anim.loopCycles = -1; sprite.AddAnimation(anim); anim = new UVAnimation(); firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 1535)); cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 19, 15); anim.name = "Surprise"; anim.loopCycles = 0; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); }
// Use this for initialization public override void Start() { base.Start(); GetComponent<SimpleFollow>().enabled = false; sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15); anim.name = "Idle"; anim.loopCycles = -1; sprite.AddAnimation(anim); anim = new UVAnimation(); firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383)); cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15); anim.name = "Die"; anim.loopCycles = 0; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); }
public void StartFireball(Vector3 pos, int direction) { this.pos = pos; this.direction = direction; active = true; sprite.PlayAnim(FireballAnimSet.MOVE); }
// Use this for initialization void Start() { sprite = spriteManager.AddSprite(gameObject, width, height, 0, 511, 512, 512, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 511)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15); anim.name = "Idle"; anim.loopCycles = -1; sprite.AddAnimation(anim); anim = new UVAnimation(); firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 1023)); cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 19, 15); anim.name = "Surprise"; anim.loopCycles = 0; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); }
public override void Start() { base.Start(); sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15); anim.name = "Idle"; anim.loopCycles = -1; sprite.AddAnimation(anim); anim = new UVAnimation(); firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383)); cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15); anim.name = "Die"; anim.loopCycles = 0; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); dolphin = GameObject.Find("DolphinSprite"); Util.Assert(dolphin != null); }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { GetComponent <SplineController>().enabled = false; GetComponent <SplineInterpolator>().enabled = false; if (!hasBlownUp) { Messenger <string> .Invoke("OnPlaySFX", "Puffer"); sprite.PlayAnim("Explode"); hasBlownUp = true; } else { Messenger <string> .Invoke("OnPlaySFX", "Puffer_Collision"); } var dir = (transform.position - other.collider.bounds.center); dir.Normalize(); rigidbody.AddForce(dir * launchSpeed); rigidbody.AddTorque(0, 0, launchTorque); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player" && !isOpen) { isOpen = true; sprite.PlayAnim("Surprise"); Messenger <string> .Invoke("OnPlaySFX", "Surprise"); other.gameObject.SendMessage("TakeDamage", points); } }
// Use this for initialization void Start() { sprite = spriteManager.AddSprite(this.gameObject,2,2,new Vector2(.5f,.5f), new Vector2(.25f, .5f), new Vector3(0,0,0), true); stabbing = new UVAnimation(); stabbing.name="stabbing"; stabbing.SetAnim(stabbing.BuildUVAnim(new Vector2(.5f,.5f),new Vector2(.25f,.5f),2,2,3,2)); stabbing.loopCycles=-1; // makes animation loop infinitely stabbing.loopReverse = true; // makes animation go in reverse after it's completed sprite.AddAnimation(stabbing); sprite.PlayAnim("stabbing"); }
void OnDie() { pathPoints.Clear(); isUpdatingFromPath = false; sprite.PlayAnim("Die"); sprite.SetAnimCompleteDelegate(delegate() { ShowMenu(); }); Messenger <string> .Invoke("OnPlaySFX", "Dolphin_Scream"); }
public void OnDie() { if (!isDying) { isDying = true; sprite.PlayAnim("Die"); sprite.SetAnimCompleteDelegate(delegate() { Destroy(transform.parent.gameObject); }); } }
// Use this for initialization void Start() { sm = GameObject.Find("_SpriteManager").GetComponent <LinkedSpriteManager>(); sprite = sm.AddSprite(this.gameObject, 1f, 1f, sm.PixelCoordToUVCoord(0, 9 * 96), sm.PixelSpaceToUVSpace(192, 192), Vector3.zero, false); sprite.SetDrawLayer(100); UVAnimation anim = new UVAnimation(); anim.BuildUVAnim(sm.PixelCoordToUVCoord(0, 9 * 96), sm.PixelSpaceToUVSpace(192, 192), 5, 1, 5, 56f); anim.loopCycles = 0; sprite.AddAnimation(anim); sprite.PlayAnim(anim); Invoke("destroySelf", .125f); }
public void OnDie() { if (!isDying) { isDying = true; sprite.PlayAnim("Die"); sprite.SetAnimCompleteDelegate(delegate() { Destroy(transform.parent.gameObject); }); Messenger <string> .Invoke("OnPlaySFX", "Diver_3"); } }
// Use this for initialization void Start() { width = collider.bounds.size.x * 2 + 0.15f; height = collider.bounds.size.y * 2 + 0.15f; sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 11, 15); anim.name = "Idle"; anim.loopCycles = -1; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); }
// Use this for initialization void Start() { sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false); // Create and setup anims UVAnimation anim = new UVAnimation(); var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127)); var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128)); anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 10, 15); anim.name = "Idle"; anim.loopCycles = 0; sprite.AddAnimation(anim); sprite.PlayAnim("Idle"); sprite.SetAnimCompleteDelegate(delegate() { Destroy(transform.parent.gameObject); }); }
// Use this for initialization void Start() { spriteManager = gameObject.GetComponent <SpriteManager>() as SpriteManager; particleSprite = spriteManager.AddSprite(gameObject, 1.0f, 1.0f, spriteManager.PixelSpaceToUVSpace(128, 128), spriteManager.PixelSpaceToUVSpace(30, 30), false); particleSprite.SetAnimCompleteDelegate(OnAnimateComplete); Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace(30, 30); //Idle animation UVAnimation idleAnimation = new UVAnimation(); Vector2 idleStartPosUV = spriteManager.PixelCoordToUVCoord(0, 30); idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, 3, 2, 5, 15); idleAnimation.loopCycles = 0; idleAnimation.name = "idle"; particleSprite.AddAnimation(idleAnimation); particleSprite.PlayAnim("idle"); transform.position = new Vector3(startPos.x, startPos.y, startPos.z); }
public void animateAttack(MonoBehaviour other) { if (transform.position.x >= other.transform.position.x) { sprite.PlayAnim(attackLeft); animState = (int)AnimState.ATTACK_LEFT; standState = (int)AnimState.STAND_LEFT; } else { sprite.PlayAnim(attackRight); animState = (int)AnimState.ATTACK_RIGHT; standState = (int)AnimState.STAND_RIGHT; } Invoke("endAttackAnimation", .25f); }
void Start() { var transTest = new GameObject("MaterialTransform_"+ this.name); transTest.transform.position = transform.TransformPoint(transTest.transform.position); transTest.transform.position += new Vector3(0, 0, _depthLayer) * _depthScaleFactor; transTest.transform.localScale = new Vector3(_scaleX, _scaleY, 0.5f); _sprite = _spriteManager.AddSprite(transTest, _width, _height, 0, (int)_cellSize.x-1, (int)_cellSize.x, (int)_cellSize.x, false); for (var i = 0; i < _anims.Length; i++) { var anim = new UVAnimation(); var firstFrameCoords = new Vector2( //_anims[i].firstFrame.x * _cellSize.x, 0, _anims[i].firstFrame.y * _cellSize.y); var firstFrame = _spriteManager.PixelCoordToUVCoord(firstFrameCoords); var cellSize = _spriteManager.PixelSpaceToUVSpace(_cellSize); anim.BuildUVAnim(firstFrame, cellSize, _anims[i].columns, _anims[i].rows, _anims[i].totalCells, _anims[i].fps, (int)(_anims[i].firstFrame.x)); anim.name = _anims[i].name; anim.loopCycles = _anims[i].loopCycles; _sprite.AddAnimation(anim); } _currentAnimation = _defaultAnimation; _sprite.PlayAnim(_defaultAnimation); }
public void PlayAnim(string name) { sprite.PlayAnim(name); currAnim = name; }
// Update is called once per frame void Update() { // // if (Input.GetKeyDown("1")) { // enemySprite.PlayAnim("idle"); // } // if (Input.GetKeyDown("2")) { // enemySprite.PlayAnim("walk"); // } // if (Input.GetKeyDown("3")) { // enemySprite.PlayAnim("die"); // } // enemySprite.PlayAnim("idle"); // return; LookAtPlayer(); if (health <= 0) { if (enemySprite.isPlaying != "die") { Die(); } return; } if (enemySprite.isPlaying == "shoot") { if (enemySprite.framesPlayed >= shootFrame) { RaycastHit hit; Vector3 pos = new Vector3(transform.position.x + baseBeam.x, transform.position.y + baseBeam.y, transform.position.z + baseBeam.z); Vector3 dir = transform.forward; if (Physics.Raycast(pos, dir, out hit, range)) { Debug.DrawLine(pos, hit.point); if (hit.transform.gameObject.tag == "player" && !shot) { shot = true; int roll = Random.Range(0, 100); if (roll < accuracy) { hit.transform.gameObject.GetComponent <Player>().gotHit(damage); // HITS PLAYER!! } if (sndShoot) { audioSource.clip = sndShoot; audioSource.Play(); } } } } } if (health > 0) { RaycastHit hit; Vector3 pos = new Vector3(transform.position.x + baseBeam.x, transform.position.y + baseBeam.y, transform.position.z + baseBeam.z); Vector3 dir = transform.forward; if (!awareOfPlayer) { if (Physics.Raycast(pos, dir, out hit, sightRange)) { Debug.DrawLine(pos, hit.point); if (hit.transform.gameObject.tag == "player") { awareOfPlayer = true; } } enemySprite.PlayAnim("idle"); } // Continue below here if (awareOfPlayer) { bool canShoot = false; if (attackSpeed > 0) { attackSpeed -= Time.deltaTime * 100; } if (Physics.Raycast(pos, dir, out hit, range)) { Debug.DrawLine(pos, hit.point); if (hit.transform.gameObject.tag == "player") { canShoot = true; if (attackSpeed <= 0 && shot) // SHOOT! { enemySprite.PlayAnim("shoot"); attackSpeed = attackSpeedMax; shot = false; } } } if (!canShoot) { lookForPath(); } // if(newPathTime >= 0) { // newPathTime -= Time.deltaTime * 100; // }else { // lookForPath(); // } } } }
void InitSM() { S = LSM.AddSprite(this.gameObject, 5, 5, LSM.PixelCoordToUVCoord(0, 0), LSM.PixelSpaceToUVSpace(512, 512), -transform.forward * .4f, false); anim_run = new UVAnimation(); anim_run.SetAnim( new Vector2[]{ LSM.PixelCoordToUVCoord(3072, 0), LSM.PixelCoordToUVCoord(3072+512, 0), LSM.PixelCoordToUVCoord(0, 512), LSM.PixelCoordToUVCoord(512, 512), LSM.PixelCoordToUVCoord(1024, 512), LSM.PixelCoordToUVCoord(1024+512, 512), LSM.PixelCoordToUVCoord(2048, 512), LSM.PixelCoordToUVCoord(2048+512, 512) }); //anim_run.BuildUVAnim(LSM.PixelCoordToUVCoord(3072, 512), LSM.PixelSpaceToUVSpace(512, 512), 16, 2, 16, 2f); anim_run.loopCycles = -1; //anim_run.PlayInReverse(); anim_run.name = "Run"; S.AddAnimation(anim_run); anim_idle = new UVAnimation(); anim_idle.BuildUVAnim(LSM.PixelCoordToUVCoord(0, 512), LSM.PixelCoordToUVCoord(512, 512), 8, 2, 1, 12f); anim_idle.loopCycles = -1; S.AddAnimation(anim_idle); anim_idle.name = "Idle"; anim_runstart = new UVAnimation(); anim_runstart.BuildUVAnim(LSM.PixelCoordToUVCoord(0, 512), LSM.PixelCoordToUVCoord(512, 512), 8, 2, 1, 12f); anim_runstart.loopCycles = -1; S.AddAnimation(anim_runstart); anim_runstart.name = "RunStart"; anim_current = "Run"; S.PlayAnim(anim_run); LSM.ScheduleBoundsUpdate(0.5f); }