private void OnHp() { float hp = (float)Enity.GetProperty("hp"); float maxHp = (float)Enity.GetProperty("maxHp"); _uilifeBar.SetBarLength(hp, maxHp); }
public void Init() { _myEnity = new Enity(); _myEnity.AddProperty("name", "hero"); _myEnity.Go = LoadModel(); _animator = _myEnity.Go.GetComponentInChildren <Animator>(); _myEnity.AddComponent("display", new DisplayComponent()); _myEnity.AddComponent("actionComponent", new ActionComponent()); _myEnity.AddComponent("transformComponent", new TransformComponent()); _myEnity.AddComponent("titleComponent", new TitleComponent()); //_myEnity.AddComponent("mouseInteractiveComponent", new MouseInteractiveComponent()); _myEnity.AddComponent("lifeBarComponent", new LifeBarComponent()); /*PatrolComponent patrolComponent = new PatrolComponent(); * _myEnity.AddComponent("patrolComponent", patrolComponent);*/ EnityData _enityData = new EnityData(); _myEnity.AddProperty("enityData", _enityData); _myEnity.Transform.gameObject.AddComponent <EnityBind>().Owner = _myEnity; //GameInput.Instance.OnUpdate += patrolComponent.Update; //test LifeBarComponent life = _myEnity.AddComponent <LifeBarComponent>(); life.key = "test add"; GetCamera(); }
private void OnTitle() { Transform _t = Enity.GetProperty("title") as Transform; SpriteRenderer sr = _t.GetComponent <SpriteRenderer>(); string titleName = Enity.GetProperty("titleName").ToString(); sr.sprite = Resources.Load(titleName, typeof(Sprite)) as Sprite; }
private void OnActionStateEnd() { AnimatorStateInfo state = (AnimatorStateInfo)Enity.GetProperty("actinStateEnd"); if (state.shortNameHash == AnimatorManager.atk01Hash) { } }
private void LoadLifeBar() { GameObject _go = ResourceManager.Instance.LoadNewPrefab("UILifeBar2", UIMgr.Instance.GetLayer(UIMgr.Layer.layer2)); _go.name = "UILifeBar_" + Enity.GetProperty("name"); barTransfrom = _go.transform as RectTransform; _uilifeBar = barTransfrom.GetComponent <UILifeBar2>(); if (_uilifeBar == null) { _uilifeBar = barTransfrom.gameObject.AddComponent <UILifeBar2>(); } _uilifeBar._camera = Enity.GetProperty("camera") as Camera; _uilifeBar._actor = Enity.Transform; }
public override void Update() { if (_target != null && _isLock == false) { float distance = Vector3.Distance(Enity.Transform.position, _target.Transform.position); if (distance < 10) { Enity.SetProperty("actionName", "run01"); Enity.Transform.LookAt(_target.Transform); Enity.Transform.Translate(Vector3.forward * Time.deltaTime * 1); if (distance < 1.0f) { Enity.SetProperty("actionName", "attack01"); } } } }
private void Init() { _myEnity = new Enity(); _myEnity.SetProperty("name", "enemy"); _myEnity.Go = LoadModel(); _myEnity.AddComponent("display", new DisplayComponent()); _myEnity.AddComponent("actionComponent", new ActionComponent()); _myEnity.AddComponent("transformComponent", new TransformComponent()); _myEnity.AddComponent("lifeBarComponent", new LifeBarComponent()); PatrolComponent patrolComponent = new PatrolComponent(); _myEnity.AddComponent("patrolComponent", patrolComponent); EnityData _enityData = new EnityData(); _myEnity.AddProperty("enityData", _enityData); _myEnity.Transform.gameObject.AddComponent <EnityBind>().Owner = _myEnity; GameInput.Instance.OnUpdate += patrolComponent.Update; }
private void OnDoAction() { if (_isLock) { } else { string actionName = Enity.GetProperty("actionName").ToString(); _animator.Play(actionName); } //if (AnimatorManager.Instance.IsSameCurrentAction(actionName)) return; /*return; * if (actionName == "attack01") * { * Animator.SetBool("isAttack", true); * }else * { * Animator.Play(actionName); * }*/ }
private void OnActionNormalizedTime() { string actionTime = Enity.GetProperty("normalizedTime").ToString(); if (actionTime == "effectNode") { Enity target = (Enity)Enity.GetProperty("patrolTarget"); Animator animator = (Animator)target.GetProperty("animator"); animator.Play("hit01", 0, 0); } else if (actionTime == "beAtkNode") { /*List<Enity> _listEnemy = Enity.GetProperty("enemy") as List<Enity>; * if (_listEnemy != null) * { * for (int i = 0; i < _listEnemy.Count; i++) * { * _listEnemy[i].SetProperty("actionName", "beAtk"); * } * }*/ } }
public virtual void RemoveEvent() { _enity = null; }
bool isPlayBack = false;//是否重播 true: 重播 private void OnMoveSpeed() { float speed = (float)(Enity.GetProperty("moveSpeed")); Animator.SetFloat("MoveSpeed", speed); }
private void OnIsLock() { _isLock = (bool)Enity.GetProperty("isLock"); }
private void OnPatrol() { _target = Enity.GetProperty("patrolTarget") as Enity; }
private void OnActionStateEnd() { AnimatorStateInfo state = (AnimatorStateInfo)Enity.GetProperty("actinStateEnd"); Debug.Log("------2 action state end " + AnimatorManager.Instance.HashToString(state.shortNameHash)); }
private void OnDialog() { int dialogId = (int)Enity.GetProperty("dialogId"); }
private void OnRoration() { Vector3 _v3 = (Vector3)Enity.GetProperty("rotation"); Model.localRotation = Quaternion.LookRotation(_v3); }
private void OnPosition() { Vector3 _v3 = (Vector3)Enity.GetProperty("position"); Enity.Transform.Translate(_v3); }
private void OnScale() { Enity.Transform.localScale = (Vector3)Enity.GetProperty("scale"); }