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;
      } 
     }
    }

  • 相关阅读:
    《Qt学习系列笔记》--章节索引
    Qt-绘制图表
    Qt-可视化数据库操作
    Qt-数据库操作SQLite
    古人说的最好,临渊羡鱼,不如退而结网, 这是个勇气问题.
    阿里云产品之数据中台架构
    使用HSDB查看类变量的内存布局(5)
    文件流
    类文件介绍
    类的连接之重写(1)
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2161959.html
Copyright © 2011-2022 走看看