Play() public method

Play the active clip. Will restart the clip if called again. Will restart the clip at clipStartTime if called while the clip is playing.
public Play ( ) : void
return void
Example #1
0
    void FixedUpdate()
    {
        if (previousFingerState != currentFingerState)
        {
            if (currentFingerState != FingerState.None)
            {
                touchAnim.Play(touchAnimations[0]);                     //play the begin animation
            }
            else if (currentFingerState == FingerState.None)
            {
                touchAnim.Play(touchAnimations[2]);                     //play end animation
            }
        }

        float centerx = 0.5f;
        float centery = 0.5f;

        float xdiffCur = centerx - prevTouchPos.x;
        float ydiffCur = centery - prevTouchPos.y;
        float xdiffOld = centerx - transform.position.x;
        float ydiffOld = centery - transform.position.y;

        float angleOld = ToDegrees(Mathf.Atan2(ydiffOld, xdiffOld));
        float angleCur = ToDegrees(Mathf.Atan2(ydiffCur, xdiffCur));

        touchAnim.transform.Rotate(touchAnim.transform.forward, (angleOld - angleCur));
        prevTouchPos.x = transform.position.x;
        prevTouchPos.y = transform.position.y;

        previousFingerState = currentFingerState;

        UpdatePlayerMovementsAndFeelings();
        UpdatePlayerGestures();
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        CharacterController controller = GetComponent <CharacterController>();

        // Player move
        if (controller.isGrounded)
        {
            moveDirection  = new Vector3(direction, 0, 0);
            moveDirection  = transform.TransformDirection(moveDirection);
            moveDirection *= speed;

            //if (Input.GetButton("Jump")) {
            //	moveDirection.y = jumpSpeed;
            //}
        }

        moveDirection.y -= gravity * Time.deltaTime;
        // Move the controller
        controller.Move(moveDirection * Time.deltaTime);

        //Debug.Log(isLeft.ToString() + ',' + (transform.position.x < leftStop).ToString() + ',' + (transform.position.x > rightStop).ToString() + ',' + transform.position.x);
        if (transform.position.x < leftStop && isLeft == true)
        {
            direction = -direction;
            isLeft    = false;
            anim.Play("rightwalk");
        }
        if (transform.position.x > rightStop && isLeft == false)
        {
            direction = -direction;
            isLeft    = true;
            anim.Play("leftwalk");
        }
    }
Example #3
0
 public void Jump()
 {
     //rigidbody.velocity = Vector3.up * 7.0f;
     rigidbody.AddForce(Vector3.up * 7000, ForceMode.Impulse);
     state = PlayerStatus.JUMPING;
     animation.Play("Jump");
 }
Example #4
0
    void UpdateDirection()
    {
        lastDirection = transform.position - lastPosition;
        lastPosition  = transform.position;

        float angle = Mathf.Atan2(lastDirection.x, lastDirection.z);

        if (angle < 0)
        {
            angle += Mathf.PI * 2;
        }
        int index = Mathf.RoundToInt(angle / (Mathf.PI * 2) * 8);

        if (index == 8)
        {
            index = 0;
        }
        //Debug.Log("Angle : " + angle + " | Index = " + index);

        var animName = PerAngleAnimationMap[index];
        var lastName = sprite.CurrentClip == null ? "" : sprite.CurrentClip.name;

        if (lastName != animName)
        {
            sprite.Play(animName);

            if (animName == "walk_rs" || lastName == "walk_rs")
            {
                //Debug.Log("name = " + animName);
                sprite.FlipX();
            }
        }
    }
Example #5
0
 public void Jump()
 {
     if (isJumping)
     {
         if (isDoubleJump)
         {
             return;
         }
         else
         {
             isDoubleJump       = true;
             fallSpeed          = 0;
             jumpStartHeight    = transform.position.y;
             animatedJumpHeight = 0f;
             animation.Stop("Jump");
             animation.Play("Jump");
             AudioController.Play("Jump");
             sprite.Play("LlamaJump");
         }
     }
     else
     {
         isJumping          = true;
         fallSpeed          = 0;
         jumpStartHeight    = transform.position.y;
         animatedJumpHeight = 0f;
         animation.Stop("Jump");
         animation.Play("Jump");
         AudioController.Play("Jump");
         sprite.Play("LlamaJump");
     }
 }
 public void setAnimation(MoveDirection dir)
 {
     if (!_animations.ContainsKey(dir))
     {
         Logger.message(LogLevel.LOG_ERROR, "Animation for MoveDirection " + dir.ToString() + " is not assigned!");
     }
     else
     {
         _sprite.Play(_animations[dir]);
     }
 }
Example #7
0
 // This is called once the hit animation has compelted playing
 // It returns to playing whatever animation was active before hit
 // was playing.
 void HitCompleteDelegate(tk2dAnimatedSprite sprite, int clipId)
 {
     if (walking)
     {
         anim.Play("walk");
     }
     else
     {
         anim.Play("idle");
     }
 }
Example #8
0
    IEnumerator startToExplode(float timeToBegin, float timeToExplode)
    {
        yield return(new WaitForSeconds(timeToBegin));

        sprite.Play("loop");
        yield return(new WaitForSeconds(timeToExplode));

        sprite.Play("explode");
        if (meshC)
        {
            meshC.isTrigger = true;
        }
        yield return(0);
    }
Example #9
0
    public void setState(CustomerStateDeprecated state)
    {
        if (state == _currentState)
        {
            return;
        }

        switch (state)
        {
        case CustomerStateDeprecated.WAITING_STAND:
            _moodDownSpeedCoeff = 1f;
            lastMoodChangeTime  = Time.time;
            break;

        case CustomerStateDeprecated.WAITING_SIT:
            placement.isFree    = true;
            _moodDownSpeedCoeff = 0.5f;
            lastMoodChangeTime  = Time.time;
            break;

        case CustomerStateDeprecated.MAKE_ORDER:
            collider.enabled = false;
            _sprite.Play("sit_happy");
            startOrderTime = Time.time;
            break;

        case CustomerStateDeprecated.EAT:
            _orderTable.hide();
            startEat = Time.time;
            _sprite.Play("sit_eat_drink");
            break;

        case CustomerStateDeprecated.WAITING_ORDER:

            // HACK
            _orderTable.gameObject.transform.position = gameObject.transform.position;
            _orderTable.gameObject.transform.Translate(0, 0, -2);

            Order ord = (Order)orders[0];
            _orderTable.show(ord.productID);

            _moodDownSpeedCoeff = 0.5f;
            lastMoodChangeTime  = Time.time;
            break;

        case CustomerStateDeprecated.HAPPY_OUT:
            _sprite.Play("hello");

            seatPosition.isFree = true;
            Destroy(gameObject, 2);
            break;

        default:
            Logger.message(LogLevel.LOG_ERROR, "Unknown customer state - " + state);
            break;
        }

        _currentState = state;
    }
Example #10
0
 // Update is called once per frame
 void Update()
 {
     if (cheer)
     {
         sprite.Play("Cheering");
     }
     else if (jump.NBAJAMZ2013)
     {
         sprite.Play("Jumping");
     }
     else
     {
         sprite.Play("Standing");
     }
 }
    IEnumerator PlayAnim()
    {
        if (Game.game.currentState != Game.GameStates.InGame)
        {
            yield return(0);
        }

        playingAnimation = true;

        float time = Random.Range(min_time, max_time);

        yield return(new WaitForSeconds(time));

        tk2dAnimatedSprite sprite = GetComponent <tk2dAnimatedSprite>();

        sprite.animationCompleteDelegate = onAnimationComplete;
        sprite.Play();

        if (sound != null && sound.Length > 0)
        {
            int   index      = Random.Range(0, sound.Length);
            float sound_time = Random.Range(min_sound_offset, max_sound_offset);

            yield return(new WaitForSeconds(sound_time));

            stateSound = Game.game.playSound(sound[index]);
        }
    }
 void Start()
 {
     mAnimSprite = GetComponent<tk2dAnimatedSprite>();
     if(mAnimSprite != null && !mAnimSprite.playAutomatically) {
         mAnimSprite.Play();
     }
 }
    IEnumerator fireCannons()
    {
        for (int i = 0; i < cannonIsFiring.Length; i++)
        {
            cannonIsFiring[i] = false;
        }

        for (int i = 0; i < numCannonBalls; i++)
        {
            int cannonIndex = 0;
            do
            {
                cannonIndex = Random.Range(0, cannonIsFiring.Length);
            }while(cannonIsFiring[cannonIndex]);

            cannonIsFiring[cannonIndex] = true;
            tk2dAnimatedSprite sprite = cannonSprites[cannonIndex];
            sprite.animationCompleteDelegate = delegate(tk2dAnimatedSprite s, int clipId)
            {
                s.animationCompleteDelegate = null;
                s.Play("idle");
            };
            sprite.Play("explode");
            Game.game.playSoundFromList(cannonSounds);
            yield return(new WaitForSeconds(Random.Range(0.01f, 0.3f)));
        }
        yield return(0);
    }
Example #14
0
    protected override void OnTouchDown()
    {
        if (soup_instance == null && soup == null)
        {
            soup_instance = Instantiate(Resources.Load(PATH_OF_SOUP_INSTANCE, typeof(GameObject))) as GameObject;
            soup_instance.transform.position = instancePosition;
            soup_instance.gameObject.name = GoodDataStore.FoodMenuList.Miso_soup.ToString();

            animatedInstance = soup_instance.GetComponent<tk2dAnimatedSprite>();
            animatedInstance.Play();

            soup = soup_instance.GetComponent<GoodsBeh>();
            soup.costs = stageManager.goodDataStore.FoodDatabase_list[(int)GoodDataStore.FoodMenuList.Miso_soup].costs;
            soup.offsetPos = Vector3.up * 4.5f;
            soup.GoodsBeh_putObjectOnTray_Event = Handle_putObjectOnTray_Event;
            soup.ObjectsBeh_destroyObj_Event = Handle_destroyObj_Event;

            animatedInstance.animationCompleteDelegate = delegate(tk2dAnimatedSprite sprite, int clipId)
            {
                soup._canDragaable = true;
            };
            // Play sound effect.
            baseScene.audioEffect.PlayOnecWithOutStop(baseScene.soundEffect_clips[4]);
        }

        base.OnTouchDown();
    }
Example #15
0
 public void Activate(Type type, EntityBase ent)
 {
     animSprite.Play(mTypeClips[(int)type]);
     mEnt      = ent;
     mState    = State.Activate;
     mCurDelay = 0;
 }
Example #16
0
 // Use this for initialization
 void Start()
 {
     _aniSp = GetComponent<tk2dAnimatedSprite>();
     if (_aniSp == null) return;
     _aniSp.Play(0);
     StartCoroutine(accelerate());
 }
Example #17
0
    // Use this for initialization

    void OnEnable()
    {
        manager = FindObjectOfType(typeof(GameManager)) as GameManager;
        life    = maxLife;
        player  = GetComponent <tk2dAnimatedSprite>();
        player.animationEventDelegate = PlayerAnim;
        if (isPlayer)
        {
            lifeBar        = GameObject.Find("PlayerLifeFill").GetComponent <tk2dSlicedSprite>();
            actorName      = GameObject.Find("PlayerName").GetComponent <tk2dTextMesh>();
            actorName.text = characterName;
            actorName.Commit();
        }
        else if (isBoss)
        {
            playerPos       = GameObject.FindWithTag("Player").transform;
            carefulVelocity = velocity * 0.3f;
            GameObject.Find("BossLifeBar").renderer.enabled  = true;
            GameObject.Find("BossLifeFill").renderer.enabled = true;
            GameObject.Find("BossPortrait").renderer.enabled = true;
            GameObject.Find("BossName").renderer.enabled     = true;
        }
        else
        {
            playerPos       = GameObject.FindWithTag("Player").transform;
            carefulVelocity = velocity * 0.3f;
        }
        player.color = new Color(player.color.r, player.color.g, player.color.b, 1f);
        states       = PlayerStates.idle;
        player.Play("Idle");
        StartCoroutine("CharacterBehaviour");
    }
Example #18
0
    protected override void OnTouchDown()
    {
        if (instance == null && food == null)
        {
            instance = Instantiate(Resources.Load(PATH_OF_INSTANCE_PREFAB, typeof(GameObject))) as GameObject;
            instance.transform.position = instancePosition;
            instance.gameObject.name = GoodDataStore.FoodMenuList.Iced_greenTea.ToString();

            baseScene.audioEffect.PlayOnecWithOutStop(baseScene.soundEffect_clips[2]);

            animatedInstance = instance.GetComponent<tk2dAnimatedSprite>();
            animatedInstance.Play();

            food = instance.GetComponent<GoodsBeh>();
            food.offsetPos = Vector3.up * 4;
            food.costs = stageManager.goodDataStore.FoodDatabase_list[(int)GoodDataStore.FoodMenuList.Iced_greenTea].costs;
            food.GoodsBeh_putObjectOnTray_Event = Handle_putObjectOnTray_Event;
            food.ObjectsBeh_destroyObj_Event = Handle_destroyObj_Event;

            animatedInstance.animationCompleteDelegate = delegate(tk2dAnimatedSprite sprite, int clipId)
            {
                food._canDragaable = true;
            };
        }

        base.OnTouchDown();
    }
Example #19
0
    public tk2dAnimatedSprite getEffect(string name, Vector3 pos, Transform parent, bool isLoop = true, tk2dAnimatedSprite.AnimationCompleteDelegate completeDelegate = null)
    {
        tk2dAnimatedSprite eff = getAnimatedSprite();

        eff.gameObject.SetActive(true);
        //eff.gameObject.name = name;
        eff.transform.parent   = parent;
        eff.transform.position = pos;

        eff.Play(name, 0.0f);

        if (isLoop)
        {
            eff.CurrentClip.wrapMode      = tk2dSpriteAnimationClip.WrapMode.Loop;
            eff.animationCompleteDelegate = null;            //completeGetPopEffect;
        }
        else
        {
            eff.CurrentClip.wrapMode      = tk2dSpriteAnimationClip.WrapMode.Once;
            eff.animationCompleteDelegate = completeDelegate;
        }


        return(eff);
    }
Example #20
0
    void move()
    {
        CharacterController controller = GetComponent <CharacterController>();

        roleSprite = GetComponent <tk2dSprite>();

        // Player move
        if (controller.isGrounded)
        {
            //Debug.Log(Input.GetAxis("Horizontal"));
            moveDirection  = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
            moveDirection  = transform.TransformDirection(moveDirection);
            moveDirection *= speed;

            if (Input.GetButton("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }
        }

        if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.H))
        {
            if (!anim.IsPlaying("leftwalk"))
            {
                anim.Play("leftwalk");
            }
        }
        else if (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.H))
        {
            anim.Play("leftstop");
        }
        if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.L))
        {
            if (!anim.IsPlaying("rightwalk"))
            {
                anim.Play("rightwalk");
            }
        }
        else if (Input.GetKeyUp(KeyCode.D) || Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.L))
        {
            anim.Play("rightstop");
        }

        moveDirection.y -= gravity * Time.deltaTime;
        // Move the controller
        controller.Move(moveDirection * Time.deltaTime);
    }
Example #21
0
 // plays the looping animation after the begin animation ends
 public void AnimationComplete(tk2dAnimatedSprite touchAnim, int clipId)
 {
     switch (clipId)
     {
     case 0:
         touchAnim.Play(touchAnimations[1]);     break;
     }
 }
Example #22
0
 // plays the looping animation after the begin animation ends
 public void AnimationComplete(tk2dAnimatedSprite touchAnim, int clipId)
 {
     switch (clipId)
     {
     case 0:
         touchAnim.Play(touchAnimations[1]);	break;
     }
 }
Example #23
0
    public override void onDoAction(string actionName)
    {
        if (actionName == "MAKE_ORANGE")
        {
            indicator.gameObject.SetActive(true);
            indicator.Play(timerGreenAnimation);

            Invoke("updateToFull", getAction("MAKE_ORANGE").actionTime);
        }
        else if (actionName == "MAKE_APPLE")
        {
            indicator.gameObject.SetActive(true);
            indicator.Play(timerGreenAnimation);

            Invoke("updateToFull", getAction("MAKE_APPLE").actionTime);
        }
    }
Example #24
0
    public void AnimationComplete(tk2dAnimatedSprite anim, int clipId)
    {
        switch (clipId)
        {
        case 0:         //appear
            anim.Play(buoyAnimations[2]);
            break;

        case 1:         //moving
            anim.Play(buoyAnimations[2]);
            break;

        case 2:         //drop
            anim.Play(buoyAnimations[2]);
            break;

        case 3:         //ringing
            anim.Play(buoyAnimations[2]);
            break;

        case 4:         //ding
            anim.Play(buoyAnimations[2]);
            break;

        case 5:         //sink
            anim.Play(buoyAnimations[6]);
            break;

        case 6:         //underwater
            anim.Play(buoyAnimations[6]);
            break;
        }
    }
 public void OnCollisionEnter(Collision collision)
 {
     Burst();
     BurstSprite.Play("burst");
     Destroy(SparkSprite);
     Destroy(Bomb);
     SoundController.Instance.PlayBombExplosion();
     collider.enabled = false;
 }
Example #26
0
    public void ShowWords()
    {
        wengzi.gameObject.SetActive(true);
        wengzi.animation.Play();

        wengziBg.gameObject.SetActive(true);
        wengziBg.animationCompleteDelegate += WengziBgAnimationCompleteHandler;
        wengziBg.Play();
    }
Example #27
0
    void Awake()
    {
        transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
        animation            = GetComponent <tk2dAnimatedSprite>();

        int bird = Random.value < 0.5f ? 1 : 2;

        animation.Play("Bird" + bird);
        gameObject.name = "Bird-" + bird;
    }
    IEnumerator Die()
    {
        _manager._swarm.Remove(this);
        _movingToTarget = true;
        _body.Play("dead");
        Vector3 target = _t.position;

        target.y = -200f;
        Vector3 speed     = Vector3.zero;
        float   totalTime = (_t.position.y + 200f) / 2000f;

        while (_t.position.y >= -100f)
        {
            _t.position = Vector3.SmoothDamp(_t.position, target, ref speed, totalTime);
            yield return(1);
        }
        Destroy(_go);
        _manager.MosquitoDied();
    }
Example #29
0
    IEnumerator PlayAnim()
    {
        float time = Random.Range(min_time, max_time);

        yield return(new WaitForSeconds(time));

        tk2dAnimatedSprite sprite = GetComponent <tk2dAnimatedSprite>();

        sprite.Play();
    }
Example #30
0
 // Use this for initialization
 void Start()
 {
     _aniSp = GetComponent <tk2dAnimatedSprite>();
     if (_aniSp == null)
     {
         return;
     }
     _aniSp.Play(0);
     StartCoroutine(accelerate());
 }
Example #31
0
    public virtual void changeAnimation(string animationName, tk2dAnimatedSprite.AnimationCompleteDelegate callback)
    {
        tk2dAnimatedSprite sprite = GetComponent <tk2dAnimatedSprite>();

        if (sprite)
        {
            if (sprite.anim.GetClipIdByName(animationName) != -1)
            {
                sprite.Play(animationName);
            }
        }
    }
    public IEnumerator BurstEvent()
    {
        BurstSprite = BurstSprite.GetComponent <tk2dAnimatedSprite>();
        SparkSprite = SparkSprite.GetComponent <tk2dAnimatedSprite>();
        SparkSprite.Play("spark");
        gameObject.rigidbody.velocity = new  Vector3(0, -18f, 0);
        yield return(new WaitForSeconds(1.6f));

//		BurstSprite.Play("burst");
//		yield return new WaitForSeconds(0.5f);
        Destroy(gameObject);
    }
Example #33
0
    // Use this for initialization
    void Start()
    {
        Screen.sleepTimeout = (int)SleepTimeout.NeverSleep;
        anim    = GetComponent <tk2dAnimatedSprite>();
        flipped = hasflipped = false;

        // set character skin
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.ANDY_GOOD.ItemId))
        {
            anim.Play("Andy");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.KELLY_GOOD.ItemId))
        {
            anim.Play("Kelly");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.NINJA_GOOD.ItemId))
        {
            anim.Play("Ninja");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.PIG_GOOD.ItemId))
        {
            anim.Play("Pig");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.PIRATE_GOOD.ItemId))
        {
            anim.Play("Pirate");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.WIZARD_GOOD.ItemId))
        {
            anim.Play("Wizard");
        }
    }
Example #34
0
    public override void changeAnimation(string animationName, tk2dAnimatedSprite.AnimationCompleteDelegate callback)
    {
        if (getSprite().clipId == -1 || getSprite().anim.clips[getSprite().clipId].name.ToLower() != animationName.ToLower() || !getSprite().isPlaying())
        {
            getSprite().Play(animationName);
            getSprite().animationCompleteDelegate = callback;

            if (attackAnimations.Contains(animationName.ToLower()) && characterSprite.anim.clips[characterSprite.clipId].name.ToLower() != animationName.ToLower())
            {
                characterSprite.Play(animationName);
                characterSprite.animationCompleteDelegate = backToIdleAfterAttack;
            }
            else if (animationName.ToLower() == "open")
            {
                characterSprite.Play(animationName);
                characterSprite.animationCompleteDelegate = backToIdleAfterAttack;
            }
            else if (animationName.ToLower() == "harmed")
            {
                characterSprite.Play(animationName);
                characterSprite.animationCompleteDelegate = null;
            }
            else if (animationName.ToLower() == "death")
            {
                characterSprite.Play(animationName);
                characterSprite.animationCompleteDelegate = null;
            }
            else if (animationName.ToLower() == "idle")
            {
                characterSprite.Play("idle");
                characterSprite.animationCompleteDelegate = null;
            }
        }
    }
Example #35
0
	// Use this for initialization
	void Start () {
		Screen.sleepTimeout = (int)SleepTimeout.NeverSleep;
		anim = GetComponent<tk2dAnimatedSprite>();
		flipped = hasflipped = false;

        // set character skin
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.ANDY_GOOD.ItemId))
        {
            anim.Play("Andy");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.KELLY_GOOD.ItemId))
        {
            anim.Play("Kelly");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.NINJA_GOOD.ItemId))
        {
            anim.Play("Ninja");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.PIG_GOOD.ItemId))
        {
            anim.Play("Pig");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.PIRATE_GOOD.ItemId))
        {
            anim.Play("Pirate");
        }
        if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.WIZARD_GOOD.ItemId))
        {
            anim.Play("Wizard");
        }
	}
Example #36
0
 // Update is called once per frame
 void Update()
 {
     if (!hasThrown)
     {
         anim.Play("Pretoss");
     }
     else
     {
         anim.Play("Aftertoss");
     }
     if (!hasThrown && ((Input.touchCount > 0) || (Input.GetMouseButtonDown(0))))
     {
         hasThrown = true;
         Vector3 point = new Vector3(
             (Input.mousePosition.x - (Screen.width / 2)) / Screen.width,
             (Input.mousePosition.y - (Screen.height / 2)) / Screen.height,
             0);
         ThrowAt(point);
         Debug.Log(point);
         (FindObjectOfType(typeof(UITimer)) as UITimer).running = true;
     }
 }
Example #37
0
 // Use this for initialization
 void OnEnable()
 {
     manager=FindObjectOfType(typeof(GameManager)) as GameManager;
     life = maxLife;
     player = GetComponent<tk2dAnimatedSprite>();
     player.animationEventDelegate = PlayerAnim;
     if(isPlayer){
         lifeBar = GameObject.Find("PlayerLifeFill").GetComponent<tk2dSlicedSprite>();
         actorName = GameObject.Find("PlayerName").GetComponent<tk2dTextMesh>();
         actorName.text = characterName;
         actorName.Commit();
     }
     else if(isBoss){
         playerPos = GameObject.FindWithTag("Player").transform;
         carefulVelocity = velocity*0.3f;
         GameObject.Find("BossLifeBar").renderer.enabled = true;
         GameObject.Find("BossLifeFill").renderer.enabled = true;
         GameObject.Find("BossPortrait").renderer.enabled = true;
         GameObject.Find("BossName").renderer.enabled=true;
     }
     else{
         playerPos = GameObject.FindWithTag("Player").transform;
         carefulVelocity = velocity*0.3f;
     }
     player.color = new Color(player.color.r,player.color.g,player.color.b,1f);
     states = PlayerStates.idle;
     player.Play("Idle");
     StartCoroutine("CharacterBehaviour");
 }
Example #38
0
 void Start()
 {
     startHeight = Screen.height;
     startWidth = Screen.width;
     orginalArea = orginalHeight * orginalWidth;
     startArea = startHeight * startWidth;
     textScale = (startArea * 100) / orginalArea;
     textScale = Math.Truncate(textScale);
     startprecentage = textScale;
     _stageDirectorGO = GameObject.FindWithTag("TagStageDirector");
     _weaveAppStarterGO = GameObject.FindWithTag("TagWeaveAppStarter");
     animatedSpriteGameObject = GameObject.Find("AnimatedSprite");
     animatedSprite = animatedSpriteGameObject.GetComponent<tk2dAnimatedSprite>();
     animatedSprite.Play("CardAnimation");
 }
Example #39
0
 public void AnimationComplete(tk2dAnimatedSprite anim, int clipId)
 {
     switch (clipId)
     {
     case 0:	//appear
         anim.Play(buoyAnimations[2]);
         break;
     case 1: //moving
         anim.Play(buoyAnimations[2]);
         break;
     case 2:	//drop
         anim.Play(buoyAnimations[2]);
         break;
     case 3:	//ringing
         anim.Play(buoyAnimations[2]);
         break;
     case 4:	//ding
         anim.Play(buoyAnimations[2]);
         break;
     case 5:	//sink
         anim.Play(buoyAnimations[6]);
         break;
     case 6:	//underwater
         anim.Play(buoyAnimations[6]);
         break;
     }
 }
Example #40
0
    private IEnumerator RandomCustomerFace()
    {
        if(customerSprite_Obj) {
            animatedSprite = customerSprite_Obj.GetComponent<tk2dAnimatedSprite>();

            int r = Random.Range(0, animationClip_name.Length);
            currentPlayAnimatedID = animatedSprite.GetClipIdByName(animationClip_name[r]);
            animatedSprite.Play(currentPlayAnimatedID);
        }

        yield return 0;
    }
    public void configure(CustomerDesc desc)
    {
        _desc = desc;

        _sprite = gameObject.AddComponent<tk2dAnimatedSprite>();
        ContentManager.instance.configureObject(_sprite, _desc.spriteAtlas, _desc.spriteName);
        Debug.Log("Old animation atlas - "+_desc.animationAtlas);
        ContentManager.instance.precacheAnimation(_sprite, _desc.animationAtlas);

        _currentMood = 100;
        _moodDownSpeed = 60f/desc.moodDownTime;

        GameObject tableGO = (GameObject)Instantiate((GameObject)Resources.Load("Prefabs/OrderTable"), Vector3.zero, Quaternion.identity);

        _orderTable = tableGO.GetComponent<OrderTable>();

        BoxCollider box = gameObject.AddComponent<BoxCollider>();
        box.size = new Vector3(_sprite.GetBounds().size.x, _sprite.GetBounds().size.y, 1);

        _sprite.Play("hello");

        setState(CustomerStateDeprecated.WAITING_STAND);
    }