Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        m_photonView = GetComponent <PhotonView>();
        if (PhotonManager.Instance.IsConnect)
        {
            gameManager = GameObject.FindObjectOfType <GameManager>();
            photonView  = this.GetComponent <PhotonView>();
            if (photonView.isMine)
            {
                playerId = PhotonManager.Instance.PlayerId;
                initCatController();
            }

            gameManager.ObserveEveryValueChanged(x => x.IsCatWin)
            .Where(x => x)
            .Subscribe(_ => EndGame());
        }
        else
        {
            initCatController();
        }

        catAnimation = GetComponent <CatAnimation>();
        rigidbody    = GetComponent <Rigidbody>();
        putFootPrints();
    }
    public void ChangeAnimation(CatAnimation animNumber)
    {
        //switch (animNumber)
        /*
        {
        case CatAnimation.FLY_STRAIGHT:
        case CatAnimation.FLY_TORIGHT:
        case CatAnimation.FLY_TOLEFT:
        case CatAnimation.FLY_UP:
            changeHandPart (QueryChanHandType.PAPER);
            this.GetComponent<QueryEmotionalController>().ChangeEmotion(QueryEmotionalController.QueryChanEmotionalType.NORMAL_EYEOPEN_MOUTHCLOSE);
            break;

        case CatAnimation.FLY_ITEMGET:
        case CatAnimation.FLY_ITEMGET_LOOP:
            changeHandPart (QueryChanHandType.STONE);
            this.GetComponent<QueryEmotionalController>().ChangeEmotion(QueryEmotionalController.QueryChanEmotionalType.FUN_EYECLOSE_MOUTHOPEN);
            break;

        case QueryChanAnimationType.FLY_DAMAGE:
            changeHandPart (QueryChanHandType.NORMAL);
            this.GetComponent<QueryEmotionalController>().ChangeEmotion(QueryEmotionalController.QueryChanEmotionalType.SURPRISED_EYEOPEN_MOUTHOPEN_MID);
            break;

        case QueryChanAnimationType.FLY_DISAPPOINTMENT:
        case QueryChanAnimationType.FLY_DISAPPOINTMENT_LOOP:
            changeHandPart (QueryChanHandType.STONE);
            this.GetComponent<QueryEmotionalController>().ChangeEmotion(QueryEmotionalController.QueryChanEmotionalType.SAD_EYECLOSE_MOUTHOPEN);
            break;

        default:
            changeHandPart (QueryChanHandType.NORMAL);
            this.GetComponent<QueryEmotionalController>().ChangeEmotion(QueryEmotionalController.QueryChanEmotionalType.NORMAL_EYEOPEN_MOUTHCLOSE);
            break;
        }
        */

        List<string> targetAnimations = new List<string>();
        foreach (AnimationState targetState in Cat.GetComponent<Animation>())
        {
            targetAnimations.Add(targetState.name);
        }
        targetAnimations.Sort();

        Cat.GetComponent<Animation>().CrossFade(targetAnimations[(int)animNumber]);
    }