Ejemplo n.º 1
0
 public void Awake()
 {
     currCommands = new Dictionary <Type, Command>();
     unit         = GetParent <Unit>();
     if (unit == null)
     {
         Log.Debug("获取不到Unit");
     }
     simulaterComponent = Game.Scene.GetComponent <CommandSimulaterComponent>();
     unitState          = unit.GetComponent <UnitStateComponent>();
 }
Ejemplo n.º 2
0
        public void Update()
        {
            ClientPredictionComponent clientPredictionComponent = Game.Scene.GetComponent <ClientPredictionComponent>();
            UnitStateComponent        unitStateComponent        = this.Entity.GetComponent <UnitStateComponent>();
            UnitState serverState;

            if (this.isLocal)
            {
                serverState = clientPredictionComponent.VerifyState;
            }
            else
            {
                //serverState = unitStateComponent.GetServerState();
                serverState = unitStateComponent.State;
            }

            if (this.Instance == null && serverState.Frame > 0)
            {
                ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
                GameObject         bundleGameObject   = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit");
                GameObject         prefab             = bundleGameObject.Get <GameObject>("Skeleton");
                GameObject         instance           = UnityEngine.Object.Instantiate(prefab);
                GameObject         parent             = GameObject.Find($"/Global/Unit");

                instance.transform.SetParent(parent.transform, false);

                this.Instance = instance;
                this.anim     = instance.GetComponent <Animator>();

                if (this.isLocal)
                {
                    ETModel.Game.Scene.AddComponent <CameraComponent>().Unit = this.Instance;
                }
            }
            else if (this.Instance != null)
            {
                if (this.isLocal)
                {
                    this.State = clientPredictionComponent.PredictedState;
                }
                else
                {
                    this.State = unitStateComponent.State;
                }

                UpdateInstance();
            }
        }
Ejemplo n.º 3
0
 public void Remove(UnitStateComponent unitStateComponent)
 {
     unitStateComponents.Remove(unitStateComponent);
 }
Ejemplo n.º 4
0
 public void Add(UnitStateComponent unitStateComponent)
 {
     unitStateComponents.Add(unitStateComponent);
 }