void TweenUp(OTTween tween) { new OTTween(OT.Sprite("sprite-background"), 15, OTEasing.SineInOut). TweenAdd("position",new Vector2(0,4000)). onTweenFinish = TweenDown; }
/* // Use this for initialization void Start () { } */ /* // Update is called once per frame void Update () { } */ public void Smash(Vector2 dir) { dir.Normalize(); dir *= 100f; for(int i=0; i<5; ++i) { GameObject temp = OT.CreateObject("particle"); OTSprite particle = temp.GetComponent<OTSprite>(); particle.transform.parent = ParticlesContainer.transform; particle.position = GetComponent<OTSprite>().position; Vector2 dirTemp = CreatureManager.RotateDeg(dir, Random.Range(-30f, 30f)); particle.rigidbody.AddForce(dirTemp.x, dirTemp.y, 0, ForceMode.Impulse); OTTween tween = new OTTween(particle, 2f, OTEasing.Linear); tween.TweenAdd("rotation", Random.Range(100f, 1000f)); OT.Destroy(particle, 2f); } OTSprite destructible = GetComponent<OTSprite>(); OTTween tween2 = new OTTween(destructible, 0.5f, OTEasing.Linear); tween2.TweenAdd("alpha", -1f); destructible.collidable = false; OT.Destroy(destructible, 0.5f); }
public void AddEffects(List<Effect> effects) { foreach(Effect ef in effects) { // prevent effects stack? if(! _effects.Contains(ef)) { _effects.Add(ef); // visual effects? switch(ef.EfType) { case EffectType.Stun: GameObject newVisualEffect = OT.CreateObject("visualEffect"); newVisualEffect.GetComponent<OTSprite>().frameName = "stars"; newVisualEffect.transform.parent = GetComponent<OTSprite>().transform; newVisualEffect.GetComponent<OTSprite>().depth = -3; newVisualEffect.GetComponent<OTSprite>().position = new Vector2(0f,0f); OTTween tween = new OTTween(newVisualEffect.GetComponent<OTSprite>(), ef.EfDuration, OTEasing.Linear); tween.TweenAdd("rotation", 360f); OT.Destroy(newVisualEffect, ef.EfDuration); break; } } } }
void StartTween(OTTween tween) { sprite.size = new Vector2(0.4f, 0.4f); sprite.alpha = 0.75f; new OTTween(sprite, 1.5f, OTEasing.SineOut). Tween("size", Vector2.one). Tween("alpha", 0).onTweenFinish = StartTween; }
void StartTween(OTTween tween) { sprite.size = new Vector2(0.4f,0.4f); sprite.alpha = 0.75f; new OTTween(sprite,1.5f,OTEasing.SineOut). Tween("size",Vector2.one). Tween("alpha",0).onTweenFinish = StartTween; }
void OnMouseEnter() { if (tween!=null && tween.isRunning) tween.Stop(); tween = new OTTween(GetComponent<OTSprite>(), 1f, OTEasing.ElasticOut). Tween("size", new Vector2(80, 80)). Tween("tintColor", new Color(0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f), OTEasing.StrongOut); }
void OnMouseExit() { if (tween!=null && tween.isRunning) tween.Stop(); tween = new OTTween(GetComponent<OTSprite>(), 1.5f, OTEasing.ElasticOut). Tween("size", new Vector2(50, 50)). Tween("tintColor", new Color(0.5f,0.5f,0.5f), OTEasing.StrongIn); }
public void Parry() { if(!_tween.isRunning) { _state = HandheldItemState.Parry; _tween = new OTTween(GetComponent<OTSprite>(), CONSTANTS.BaseAttackAnimDuration, OTEasing.Linear); _tween.TweenAdd("rotation", -90f); _tween.onTweenFinish = OnTweenFinish; } }
private void animateItem() { if (spr != null) { float randRange = Random.Range(0.1f,0.5f); OTTween _tween = new OTTween(spr,2.5f) .Tween("size", new Vector2(spr.size.x - randRange, spr.size.y - randRange) ) .PingPong(); } }
void OnMouseEnter() { if (tween != null && tween.isRunning) { tween.Stop(); } tween = new OTTween(GetComponent <OTSprite>(), 1f, OTEasing.ElasticOut). Tween("size", new Vector2(80, 80)). Tween("tintColor", new Color(0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f), OTEasing.StrongOut); }
void OnMouseExit() { if (tween != null && tween.isRunning) { tween.Stop(); } tween = new OTTween(GetComponent <OTSprite>(), 1.5f, OTEasing.ElasticOut). Tween("size", new Vector2(50, 50)). Tween("tintColor", new Color(0.5f, 0.5f, 0.5f), OTEasing.StrongIn); }
public void Block() { if(!_tween.isRunning) { _state = HandheldItemState.Block; _tween = new OTTween(GetComponent<OTSprite>(), CONSTANTS.BaseAttackAnimDuration); _tween.TweenAdd("position", new Vector2(0, 0.5f), OTEasing.ExpoOut); _tween.onTweenFinish = OnTweenFinish; } }
public void Recoil(float duration) { if(!_tween.isRunning) { _timer = duration; _state = HandheldItemState.Recoil; _tween = new OTTween(GetComponent<OTSprite>(), duration/2f); _tween.TweenAdd("position", new Vector2(0,-0.2f), OTEasing.ExpoOut); _tween.onTweenFinish = OnTweenFinish; } }
void OnMouseEnter() { if ((tween!=null && tween.isRunning) || runningTween != null) return; tween = new OTTween(GetComponent<OTSprite>(), 2f, OTEasing.Linear). Tween("size", new Vector2(250, 250)). Tween("alpha", 1 , 0 , OTEasing.Linear); tween.onTweenFinish = TweenFinish; new OTTween(GetComponent<OTSprite>(), 1f, OTEasing.Linear). Tween("tintColor", new Color(0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f), OTEasing.StrongOut); }
void TweenFinish(OTTween tween) { if (tween != runningTween) { runningTween = new OTTween(GetComponent<OTSprite>(), .5f, OTEasing.Linear). Tween("size", new Vector2(1, 1), new Vector2(50, 50)). Tween("alpha", 0, 1, OTEasing.Linear); new OTTween(GetComponent<OTSprite>(), .1f, OTEasing.Linear). Tween("tintColor", new Color(0.3f, 0.3f, 0.3f), OTEasing.StrongOut); runningTween.onTweenFinish = TweenFinish; } else runningTween = null; }
void OnMouseEnter() { if ((tween != null && tween.isRunning) || runningTween != null) { return; } tween = new OTTween(GetComponent <OTSprite>(), 2f, OTEasing.Linear). Tween("size", new Vector2(250, 250)). Tween("alpha", 1, 0, OTEasing.Linear); tween.onTweenFinish = TweenFinish; new OTTween(GetComponent <OTSprite>(), 1f, OTEasing.Linear). Tween("tintColor", new Color(0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f, 0.5f + Random.value * 0.5f), OTEasing.StrongOut); }
private void fadeOutObjects(List<GameObject> _objects) { foreach (GameObject _obj in _objects) { if (_obj != null) { OTSprite objectSprite = _obj.GetComponentInChildren<OTSprite>(); _obj.collider.enabled = false; OTTween _tween = new OTTween(objectSprite,1f).Tween("alpha",0f); if (objectSprite.alpha == 0) { _obj.SetActive(false); } } } }
public void Slash(float duration) { if(!_tween.isRunning) { _timer = duration; _state = HandheldItemState.Slash; _tween = new OTTween(GetComponent<OTSprite>(), duration/2f); _tween.TweenAdd("position", new Vector2(-0.6f,0.3f), OTEasing.ElasticIn); GetComponent<OTSprite>().rotation = GetComponent<OTSprite>().transform.parent.GetComponent<OTObject>().rotation-90f; _tween.TweenAdd("rotation", 120f, OTEasing.Linear); _tween.onTweenFinish = OnTweenFinish; } }
void TweenFinish(OTTween tween) { if (tween != runningTween) { runningTween = new OTTween(GetComponent <OTSprite>(), .5f, OTEasing.Linear). Tween("size", new Vector2(1, 1), new Vector2(50, 50)). Tween("alpha", 0, 1, OTEasing.Linear); new OTTween(GetComponent <OTSprite>(), .1f, OTEasing.Linear). Tween("tintColor", new Color(0.3f, 0.3f, 0.3f), OTEasing.StrongOut); runningTween.onTweenFinish = TweenFinish; } else { runningTween = null; } }
private void OnTweenFinish(OTTween tween) { OTSprite tmp = gameObject.transform.parent.gameObject.GetComponent<OTSprite>(); if(tmp != null) { if(tmp.baseName == "monster") { if(tmp.GetComponent<MonsterStatManager>().HP< 0) { // DO NOTHING! return; } } } if(_moving) { float mp = (_footForward)? 1f : -1f; _tween = new OTTween(GetComponent<OTSprite>(), CONSTANTS.BaseFootStepAplitude, OTEasing.Linear); _tween.Tween("position", new Vector2(0, mp*CONSTANTS.BaseFootStep)); _tween.onTweenFinish = OnTweenFinish; _footForward = !_footForward; } }
public void Add(OTTween tween) { tweens.Add(tween); }
private void LevelUP() { // effects GameObject temp = OT.CreateObject("visualEffect"); _levelUpEffect = temp.GetComponent<OTSprite>(); _levelUpEffect.frameName = "circle"; _levelUpEffect.size *= 100; _levelUpEffect.transform.parent = self.transform; _levelUpEffect.depth = -10; _levelUpEffect.tintColor = Color.yellow; _levelUpEffect.alpha = 0f; OTTween tween = new OTTween(_levelUpEffect, 2f, OTEasing.Linear); tween.TweenAdd("alpha", 0.5f); tween.onTweenFinish = LevelUpTweenOnFinish; // stats _xp -= CONSTANTS.BaseXPPerLevel*_level; ++_level; switch(_heroClass) { case 0: ++_strength; break; case 1: ++_agility; break; case 2: ++_magic; break; } RecalcStats(); _currentHP = _maxHP; }
private void LevelUpTweenOnFinish(OTTween tween) { OT.Destroy(_levelUpEffect, 0.5f); }
void PageFlip(int pageNumber, bool isVertical = true) { if (Constants.stageLocked) { return; } // Block Page Flip on upper position if (currentPage % 2 == 0 && !isVertical) { return; } isCameraMoving = true; OT.Print(pageNumber.ToString()); // Handle page change int previousPage = currentPage; currentPage += pageNumber; // Limit max page if (currentPage < 1) { currentPage = 1; return; } else if (currentPage > maxPage) { currentPage = maxPage; return; } // Page sound trigger new OTSound("flip"); // Find target position if (isVertical) { float destPos_y = 0; //Debug.Log(pageNumber.ToString()); if (pageNumber > 0) { destPos_y = pageHeight; pbScript.ButtonState = 1; } else { pbScript.ButtonState = 0; } OT.view.camera.orthographicSize = 0; Vector3 updatePosition = cameraGroup.transform.position; //updatePosition.x = backObject.transform.position.x; updatePosition.y = destPos_y; cameraGroup.transform.position = updatePosition; OTTween tween = new OTTween(OT.view.camera, 1); tween.Tween("orthographicSize", orthographicSize); tween.onTweenFinish = OnCameraVertMoveDone; } else { Hashtable arguments = new Hashtable(); float destPos_x = cameraGroup.transform.position.x + ((pageNumber > 0) ? pageWidth : (-pageWidth)); arguments.Add("x", destPos_x); arguments.Add("time", 1.0f); arguments.Add("oncompletetarget", gameObject); arguments.Add("oncomplete", "OnCameraMovementDone"); iTween.MoveTo(cameraGroup, arguments); } PageChange(previousPage, currentPage); }
private void TweenLeapOnFinish(OTTween tween) { _usingSkill = false; }
void TweenDown(OTTween tween) { new OTTween(OT.Sprite("sprite-background"), 15, OTEasing.SineInOut). TweenAdd("position", new Vector2(0, -4000)). onTweenFinish = TweenUp; }
public void StrikeTarget(OTObject target, float duration) { if(!_tween.isRunning) { _state = HandheldItemState.StrikeTarget; _tween = new OTTween(GetComponent<OTSprite>(), duration); _tween.TweenAdd("position", target.position - GetComponent<OTSprite>().position, OTEasing.BounceIn); _tween.onTweenFinish = OnTweenFinish; } }
private void translateCamera(float posX) { Transform _cam = GameObject.Find("UI/Main Camera").transform.transform; OTTween _tween = new OTTween(_cam,2f).Tween("position", new Vector3(posX, _cam.position.y, _cam.position.z), OTEasing.StrongOut ); }
public void Twirl(float duration) { if(!_tween.isRunning) { _timer = duration; _state = HandheldItemState.Twirl; _tween = new OTTween(GetComponent<OTSprite>(), duration, OTEasing.Linear); _tween.TweenAdd("rotation", 360f); _tween.onTweenFinish = OnTweenFinish; } }
// Use this for initialization void Start() { _tween = new OTTween(GetComponent<OTSprite>(), CONSTANTS.BaseFootStepAplitude, OTEasing.Linear); _tween.Tween("position", new Vector2(0, CONSTANTS.BaseFootStep)); _tween.onTweenFinish = OnTweenFinish; }
private void OnTweenFinish(OTTween tween) { switch(_state) { case HandheldItemState.Twirl: GetComponent<OTSprite>().rotation = GetComponent<OTSprite>().transform.parent.GetComponent<OTObject>().rotation; break; case HandheldItemState.Stab: _tween = new OTTween(GetComponent<OTSprite>(), _timer/2f); _tween.TweenAdd("position", new Vector2(0,-0.3f), OTEasing.ExpoOut); break; case HandheldItemState.Slash: GetComponent<OTSprite>().rotation = GetComponent<OTSprite>().transform.parent.GetComponent<OTObject>().rotation; _tween = new OTTween(GetComponent<OTSprite>(), _timer/2f); _tween.TweenAdd("position", new Vector2(0.6f,-0.3f), OTEasing.ExpoOut); break; case HandheldItemState.Recoil: _tween = new OTTween(GetComponent<OTSprite>(), _timer/2f); _tween.TweenAdd("position", new Vector2(0,0.2f), OTEasing.ExpoIn); break; case HandheldItemState.Block: _tween = new OTTween(GetComponent<OTSprite>(), CONSTANTS.BaseAttackAnimDuration); _tween.TweenAdd("position", new Vector2(0, -0.5f), OTEasing.ExpoIn); break; case HandheldItemState.Parry: GetComponent<OTSprite>().rotation = GetComponent<OTSprite>().transform.parent.GetComponent<OTObject>().rotation; break; case HandheldItemState.StrikeTarget: GetComponent<OTSprite>().position = new Vector2(0.3f, 0.3f); // do a reset at hero break; } _state = HandheldItemState.Idle; }
private void TweenFlurryOnFinish(OTTween tween) { _usingSkill = false; //Handheld1.position += new Vector2(0, -0.2f); HandheldItemsReset(); }
private void TweenTeleport1OnFinish(OTTween tween) { Effects.visible = false; Effects.alpha = 1f; _usingSkill = false; }
public void Stab(float duration) { if(!_tween.isRunning) { _timer = duration; _state = HandheldItemState.Stab; _tween = new OTTween(GetComponent<OTSprite>(), duration/2f); _tween.TweenAdd("position", new Vector2(0,0.3f), OTEasing.BounceIn); _tween.onTweenFinish = OnTweenFinish; } }
private void TweenSlinkOnFinish(OTTween tween) { self.alpha = 1.0f; _usingSkill = false; }
private void goToAnchor(GameObject _Anchor) { Transform _cam = GameObject.Find("UI/Main Camera").transform.transform; if (_cam == null) {Debug.Log("Camera hasn't been found");} OTTween _tween = new OTTween(_cam,2f).Tween("position", new Vector3(_Anchor.transform.position.x, _Anchor.transform.position.y, _cam.position.z), OTEasing.StrongOut ); }
// Use this for initialization void Start() { GameObject world = this.transform.parent.gameObject; var level = JSON.Parse(levelFile.text); int levelHeight = level["height"].AsInt; int levelWidth = level["width"].AsInt; collisionDetector = new CollisionDetector(levelWidth, levelHeight); Tileset[] tilesets = new Tileset[level["tilesets"].AsArray.Count]; for (int i = 0; i < level["tilesets"].AsArray.Count; ++i) { JSONNode tileset = level["tilesets"].AsArray[i]; string name = tileset["name"]; if (name == "terrain") { tilesets[i] = new Tileset(terrainSheet, tileset["firstgid"].AsUInt, "terrain"); } else if (name == "objects") { tilesets[i] = new Tileset(objectsSheet, tileset["firstgid"].AsUInt, "objects"); } else if (name == "collision") { tilesets[i] = new Tileset(null, tileset["firstgid"].AsUInt, "collision"); } else { Debug.Log("tileset name: '" + tileset["name"] + "'"); tilesets[i] = new Tileset(null, tileset["firstgid"].AsUInt, "NO SHEET"); } } Array.Reverse(tilesets); int depth = -1; foreach (JSONNode layer in level["layers"].AsArray) { for (int i = 0; i < layer["data"].AsArray.Count; ++i) { uint tileIndex = layer["data"].AsArray[i].AsUInt; if (tileIndex == 0) { continue; } int x = i % levelWidth; int y = i / levelWidth; y = levelHeight - y - 1; uint flipped = tileIndex & FLIP_MASK; tileIndex = tileIndex & ~FLIP_MASK; OTContainer spriteContainer = null; foreach (Tileset t in tilesets) { if (tileIndex >= t.firstgid) { tileIndex -= t.firstgid; if (t.name == "collision") { collisionDetector.SetCollidable(x, y); } spriteContainer = t.spritesheet; break; } } if (!layer["visible"].AsBool) { continue; } if (tileIndex == 4 && spriteContainer == objectsSheet) { // firefly, add to fireflies manager instead fireflies.SpawnAt(x * 32, y * 32); continue; } bool flip_x = (flipped & FLIPPED_HORIZONTAL) > 0; bool flip_y = (flipped & FLIPPED_VERTICAL) > 0; float rotation = 0f; if ((flipped & FLIPPED_DIAGONAL) > 0) { if ((flipped & FLIPPED_HORIZONTAL) > 0 && (flipped & FLIPPED_VERTICAL) == 0) { rotation = 90f; flip_x = true; } else if ((flipped & FLIPPED_HORIZONTAL) == 0 && (flipped & FLIPPED_VERTICAL) > 0) { rotation = -90f; flip_y = true; } else if ((flipped & FLIPPED_HORIZONTAL) == 0 && (flipped & FLIPPED_VERTICAL) == 0) { rotation = -90f; flip_x = true; } else { rotation = 90f; //flip_y = false; flip_x = true; } } OTSprite tile = createSprite(x, y, world); // random offsets that puts terrain where I want it tile.spriteContainer = spriteContainer; tile.depth = depth; tile.rotation = rotation; tile.flipHorizontal = flip_x; tile.flipVertical = flip_y; tile.frameIndex = (int)tileIndex; } depth -= 1; } // make the world bob Vector3 bobPos = world.transform.position + new Vector3(0f, 8f, 0f); OTTween tweener = new OTTween(world.transform, 3.5f, OTEasing.SineInOut) .Tween("position", bobPos); tweener.pingPong = true; tweener.playCount = -1; }
void OnCameraVertMoveDone(OTTween tween) { OnCameraMovementDone(); }
// Use this for initialization void Start() { _tween = new OTTween(GetComponent<OTSprite>(), CONSTANTS.BaseAttackAnimDuration, OTEasing.Linear); //_tween.onTweenFinish = OnTweenFinish; }