//create effect public EffectController Create(GfxObject owner, ActionObject.Effect effect, HitData hitData, GfxObject target) { GameObject go = owner.gameObject; GameObject obj = GameObject.Instantiate(Resources.Load("Battle/Effect/" + effect.id)) as GameObject; EffectController effectController = obj.AddComponent <EffectController>(); effectController.time = effect.time; effectController.bullet = effect.bullet; effectController.target = target; effectController.owner = owner; effectController.hitData = hitData; Transform trans = go.gameObject.transform.Find(effect.parent); if (trans != null) { obj.transform.parent = trans; obj.transform.localPosition = effect.offset; obj.transform.localRotation = Quaternion.Euler(effect.rotate); obj.transform.localScale = effect.scale; } if (effect.parent == "null") { obj.transform.parent = go.transform.parent; obj.transform.localPosition = go.transform.localPosition + effect.offset; obj.transform.localRotation = Quaternion.Euler(go.transform.localRotation.eulerAngles + effect.rotate); obj.transform.localScale = effect.scale; } return(effectController); }
public GfxObject CreateGFX(string path) { GameObject obj = GameObject.Instantiate(Resources.Load(path)) as GameObject; GfxObject gfx = null; gfx = obj.AddComponent <GfxObject>(); Add(gfx); return(gfx); }
public void Draw() { GUILayout.BeginVertical(); { previewCharacterSource = (GameObject)EditorGUILayout.ObjectField(previewCharacterSource, typeof(GameObject), false); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create")) { if (this.player != null) { GameObject.Destroy(this.player.gameObject); this.player = null; } this.player = (GameObject.Instantiate(previewCharacterSource) as GameObject).AddComponent <GfxObject>(); GameObject cam = GameObject.Find("Main Camera"); if (cam == null) { cam = new GameObject("Main Camera"); } GameCamera game_c = cam.GetComponent <GameCamera>(); game_c.m_Target = this.player.transform; // GameObject ingameObj = GameObject.Instantiate(Resources.Load("Scene/InGame")) as GameObject; // InGameManager.I.GameCamera = game_c.GetComponent<Camera>(); } if (GUILayout.Button("Play")) { if (this.player != null) { // ActionExcute.Create(this , this.player); this.player.transform.localPosition = Vector3.zero; this.player.transform.localRotation = Quaternion.identity; this.player.SkillState(this); } } this.m_IsLookTarget = GUILayout.Toggle(this.m_IsLookTarget, "LookTarget"); if (GUILayout.Button("+ ActionObject")) { ActionObject ao = new ActionObject(); this.m_ActionObjects.Add(ao); } GUILayout.EndHorizontal(); } { GUILayout.BeginVertical(); if (m_ActionObjects != null) { for (int i = 0; i < this.m_ActionObjects.Count; i++) { ActionObject ao = this.m_ActionObjects[i]; ao.Draw(this); } } GUILayout.EndVertical(); } GUILayout.EndVertical(); }
public static ActionExcute Create(ActionTable table, GfxObject o, HitData hitdata = null) { GameObject obj = new GameObject("ActionExcute"); ActionExcute ac = obj.AddComponent <ActionExcute>(); ac.m_Table = table; ac.m_HitData = hitdata; ac.StartAction(o); return(ac); }
public DieState m_cDieState; //死亡状态 public StateWrap(GfxObject obj) { this.m_cIdleState = new IdleState(obj); this.m_cAttackState = new AttackState(obj); this.m_cMoveState = new MoveState(obj); this.m_cMoveBackState = new MoveBackState(obj); this.m_cHurtState = new HurtState(obj); this.m_cSkillState = new SkillState(obj); this.m_cDieState = new DieState(obj); }
/// <summary> /// 设置 /// </summary> /// <param name="target"></param> public void Set(GfxObject target, Vector3 pos, int target_index, int self_index, float[] hit_time1, float[] hit_time2, float[] hit_rate, System.Action <int, int, float, bool> callback, System.Action <int> over_callback, bool ismove) { this.m_delHitCallback = callback; this.m_delOverCallback = over_callback; this.m_cPos = pos; this.m_iTargetIndex = target_index; this.m_iSelfIndex = self_index; this.m_cTargetObj = target; this.m_vecHitTime1 = hit_time1; this.m_vecHitTime2 = hit_time2; this.m_vecHitRate = hit_rate; this.m_bIsMove = ismove; }
/// <summary> /// 进入状态 /// </summary> /// <returns></returns> public override bool OnEnter() { this.m_iMove = 0; //move type this.m_fMoveSpeed = 0; //move speed this.m_fMoveTime = 0; //move time this.m_fMoveStartTime = 0; //move start time // GfxObject target = this.m_cObj.SelectTarget(); GfxObject target = null; if (this.m_ActionTable.m_IsLookTarget) { if (target != null) { this.m_cObj.transform.LookAt(target.transform); } } this.m_cExcute.target = target; return(base.OnEnter()); }
private float m_StartTime = 0; //start time //create public static HitController Create(GfxObject gfx, ActionObject.Hit hit, HitData hitdata, EffectController effectController, GfxObject target) { GameObject obj = new GameObject("HitController"); HitController hitController = obj.AddComponent <HitController>(); BoxCollider col = obj.AddComponent <BoxCollider>(); hitController.m_Owner = gfx; hitController.m_Target = target; Transform trans = null; if (hit.bindEffect) { trans = effectController.gameObject.transform.Find(hit.parent); } else { trans = gfx.gameObject.transform.Find(hit.parent); } if (trans != null) { obj.transform.parent = trans; } obj.transform.localScale = hit.size; col.size = Vector3.one; col.center = Vector3.zero; col.isTrigger = true; obj.transform.localPosition = hit.offset; hitController.m_Time = hit.time; hitController.m_HitData = hitdata; obj.transform.localRotation = Quaternion.Euler(hit.rotate); hitController.m_StartTime = Time.time; return(hitController); }
public void StartAction(GfxObject obj) { this.owner = obj; this.m_StartTime = Time.time; }
public SkillState m_cSkillState; //技能状态 #endregion Fields #region Constructors public StateWrap(GfxObject obj) { this.m_cIdleState = new IdleState(obj); this.m_cAttackState = new AttackState(obj); this.m_cMoveState = new MoveState(obj); this.m_cMoveBackState = new MoveBackState(obj); this.m_cHurtState = new HurtState(obj); this.m_cSkillState = new SkillState(obj); this.m_cDieState = new DieState(obj); }
//remove public void Remove(GfxObject obj) { this.m_List.Remove(obj); }
public AttackState(GfxObject obj) : base(obj) { }
private float m_fMoveStartTime = 0; //move start time public SkillState(GfxObject obj) : base(obj) { // }
private Vector3 m_vecTargetPos; //目标点 #endregion Fields #region Constructors public MoveState(GfxObject obj) : base(obj) { }
private Vector3 SHAKE_DIS = new Vector3(0, 0.2f, 0); //抖动距离 #endregion Fields #region Constructors public HurtState(GfxObject obj) : base(obj) { }
protected GfxObject m_cObj; //物体 public StateBase(GfxObject obj) { this.m_cObj = obj; }
public MoveState(GfxObject obj) : base(obj) { }
public DieState(GfxObject obj) : base(obj) { // }
private StateWrap m_cStateWrap; //状态包对象 #endregion Fields #region Constructors public StateControl(GfxObject obj) { this.m_cStateWrap = new StateWrap(obj); this.m_cCurrentState = null; }
// public AIObject CreateAI( string path) // { // Debug.Log("create ai path " + path); // GameObject obj = GameObject.Instantiate(Resources.Load(path)) as GameObject; // AIObject ai = null; // ai = obj.AddComponent<AIObject>(); // Add(ai); // return ai; // } //add public void Add(GfxObject obj) { this.m_List.Add(obj); }
private Vector3 SHAKE_DIS = new Vector3(0.01f, 0.005f, 0); //抖动位置 #endregion Fields #region Constructors public DieState(GfxObject obj) : base(obj) { // }
public StateControl(GfxObject obj) { this.m_cStateWrap = new StateWrap(obj); this.m_cCurrentState = null; }
public HurtState(GfxObject obj) : base(obj) { // }
protected GfxObject m_cObj; //物体 #endregion Fields #region Constructors public StateBase(GfxObject obj) { this.m_cObj = obj; }
public SkillState(GfxObject obj) : base(obj) { // }
/// <summary> /// 设置 /// </summary> /// <param name="target"></param> public void Set(GfxObject target) { this.m_cTargetObj = target; }
//update void Update() { if (null == owner) { return; } if (m_Table == null) { GameObject.Destroy(this.gameObject); return; } float time = Time.time - this.m_StartTime; ActionObject actionOld = currentAction; ActionObject ac = null; time = GetCurrentAction(time, out ac); currentAction = ac; List <ActionObject.Event> events = new List <ActionObject.Event>(); if (ac == null) { //over GameObject.Destroy(this.gameObject); return; } if (ac != actionOld) //add old unexcute event { if (actionOld != null) { events.AddRange(GetEvents(actionOld, cur_old_time, cur_now_time)); } } UpdateTime(time); //update time UpdateAnime(ac); //update animation events.AddRange(GetEvents(ac, cur_old_time, cur_now_time)); //add current event if (events.Count > 0) { foreach (ActionObject.Event ev in events) { if (ev.messages.Count > 0) { for (int i = 0; i < ev.messages.Count; i++) { owner.SendMessage("SkillMessage", ev.messages[i].m_Function + ";" + ev.messages[i].m_Args); } } EffectController effectController = null; if (ev.effect.id != string.Empty) { if (ev.effect.onoff) { //create effect effectController = EffectManager.I.Create(owner, ev.effect, this.m_HitData, target); if (effectController != null) { //todo } } } if (ev.hit.onoff) { GfxObject tmpTarget = null; if (ev.hit.isTarget) { tmpTarget = target; } HitController hitController = HitController.Create(owner, ev.hit, this.m_HitData, effectController, tmpTarget); if (hitController != null) { //todo #if UNITY_EDITOR //action editor if (EditorSceneManager.GetActiveScene().name == "Assets/Scripts/Editor/CharacterEffectEditor.unity") { int damage_num = (int)(UnityEngine.Random.value * 1000f); // HitNumber.SetData(hitController.transform.position, damage_num, HitNumberType.HpDown); } #endif } } if (!string.IsNullOrEmpty(ev.sound)) { //play sound } } } return; }
public IdleState(GfxObject obj) : base(obj) { }