zoukankan      html  css  js  c++  java
  • NETWORK_动画同步

    using UnityEngine;
    using System.Collections;
    using System;

    public class NetworkSyncAnimation : MonoBehaviour {
     
     public enum AniStates
     {
      walk = 0,
      run,
      kick,
      punch,
      jump,
      jumpfall,
      idle,
      gotbit,
      gothit,
      walljump,
      deathfall,
      jetpackjump,
      ledgefall,
      buttstomp,
      jumpland
     }
     
     public AniStates currentAnimation = AniStates.idle;
     public AniStates lastAnimation = AniStates.idle;
     
     public void SyncAnimation(String animationValue)
     {
      currentAnimation = (AniStates)Enum.Parse(typeof(AniStates), animationValue);
     }
     
     // Update is called once per frame
     void Update () {
      
      if (lastAnimation != currentAnimation)
      {
       lastAnimation = currentAnimation;
       animation.CrossFade(Enum.GetName(typeof(AniStates), currentAnimation));
       animation["run"].normalizedSpeed = 1.0F;
       animation["walk"].normalizedSpeed = 1.0F;
      }
     }
     
     void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
     {
      if (stream.isWriting)
      {
       char ani = (char)currentAnimation;
       stream.Serialize(ref ani);
      }
      else
      {
       char ani = (char)0;
       stream.Serialize(ref ani);
       
       currentAnimation = (AniStates)ani;
      } 
     }
    }

  • 相关阅读:
    B1005 继续(3n+1)猜想 (25分)
    B1091 N-自守数 (15分)
    B1086 就不告诉你 (15分)
    B1081 检查密码 (15分)
    个人博客作业Week1
    2015个人项目(修改除法要求)
    2014个人博客列表
    最佳个人博客、团队博客评分
    最终评审时间确定
    最终复审要求
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2161959.html
Copyright © 2011-2022 走看看