private void MovePlayer() { m_Player = PlayerManager.Instance.GetPlayerInstance(); if (m_Player == null) { Debuger.LogWarning("No Exist Player !"); return; } List <CharMovement> movePath = new List <CharMovement>(); foreach (var point in m_Config.LstSpeedMove) { //Vector3 point = target.Target.GetVector3(); //movePath.Add(point); CharMovement move = new CharMovement(); move.Target = point.Target.GetVector3(); move.Speed = (float)point.Speed; movePath.Add(move); } CharTransformData charData = (CharTransformData)(m_Player.GetTransformData()); GameObject charObject = charData.GetGameObject(); Rigidbody body = charObject.GetComponent <Rigidbody>(); if (body) { m_bIsKinematic = body.isKinematic; body.isKinematic = true; } m_Player.MovePath(movePath); }
public override void Destory() { if (m_Config.CharType == ECharType.Npc) { if (m_lstTargetObjects == null || m_lstTargetObjects.Count <= 0) { Debuger.LogWarning("No Exist Npc !"); return; } foreach (GameObject charObject in m_lstTargetObjects) { Rigidbody body = charObject.GetComponent <Rigidbody>(); if (body) { body.isKinematic = m_bIsKinematic; } } } else if (m_Config.CharType == ECharType.Player) { if (m_Player == null) { return; } CharTransformData charData = (CharTransformData)(m_Player.GetTransformData()); GameObject charObject = charData.GetGameObject(); Rigidbody body = charObject.GetComponent <Rigidbody>(); if (body) { body.isKinematic = m_bIsKinematic; } } }
private void AddNpc(int id, Vector3 position, Vector3 rotation, Vector3 scale) { //NpcConfig tmpConfig = ConfigManager.Instance.GetNpcConfig(id); //if (null == tmpConfig) //{ // Debuger.LogWarning("id 错误 ,错误 id= " + id); // return; //} //GameObject sourceObj = ResourceManager.Instance.LoadBuildInResource<GameObject>(tmpConfig.ModelResource, // AssetType.Char); //if (null == sourceObj) //{ // Debuger.LogWarning("模型 id 错误 ,错误 id= " + id); // return; //} //GameObject instance = GameObject.Instantiate(sourceObj); //ComponentTool.Attach(m_ObjNpcRoot.transform, instance.transform); m_Npc = new Npc(); m_Npc.Initialize(id); m_Npc.GetTransformData().SetPosition(position); m_Npc.GetTransformData().SetRotation(rotation); m_Npc.GetTransformData().SetScale(scale); CharTransformData chardata = (CharTransformData)m_Npc.GetTransformData(); m_CreatedNpcObject = chardata.GetGameObject(); m_CreatedNpcObject.transform.position = position; m_CreatedNpcObject.transform.eulerAngles = rotation; m_CreatedNpcObject.transform.localScale = scale; }
protected override void Execute() { bool isImmediate = m_Config.IsImmediate; switch (m_Config.MoveType) { case EMoveCameraType.UnLock: GlobalScripts.Instance.mGameCamera.LockCam = false; GlobalScripts.Instance.mGameCamera.SetCameraPos(m_Config.EndPos.GetVector3(), isImmediate); GlobalScripts.Instance.mGameCamera.SetCameraRot(m_Config.EndRot.GetVector3(), isImmediate); break; case EMoveCameraType.Lock: if (m_Config.FollowType == ECameraFollowType.Player) { PlayerCharacter player = PlayerManager.Instance.GetPlayerInstance(); if (player == null) { return; } CharTransformData charData = (CharTransformData)player.GetTransformData(); if (charData.GetGameObject() != null) { GlobalScripts.Instance.mGameCamera.SetTarget(charData.GetGameObject().transform, isImmediate); } } else if (m_Config.FollowType == ECameraFollowType.Npc) { if (m_lstTargetObjects == null || m_lstTargetObjects.Count <= 0) { return; } GameObject target = m_lstTargetObjects[0]; GlobalScripts.Instance.mGameCamera.SetTarget(target.transform, isImmediate); } GlobalScripts.Instance.mGameCamera.LockCam = true; GlobalScripts.Instance.mGameCamera.Distance = (float)m_Config.Distance; GlobalScripts.Instance.mGameCamera.Height = (float)m_Config.Height; GlobalScripts.Instance.mGameCamera.OffsetHeight = (float)m_Config.OffseHeight; if (!GlobalScripts.Instance.mGameCamera.CheckRoating()) { GlobalScripts.Instance.mGameCamera.Rotation = (float)m_Config.Rotation; } break; } GlobalScripts.Instance.mGameCamera.PositonDamping = (float)m_Config.PosDamping; GlobalScripts.Instance.mGameCamera.RotationDamping = (float)m_Config.RotDamping; GlobalScripts.Instance.mGameCamera.IsOverObstacle = m_Config.IsOverObstacle; }
public AbstractActionFrame(ActionPlayer action, ActionFrameData data) { m_ActionPlayer = action; m_FrameData = data; m_lstTargetObjects = new List <GameObject>(); if (data.TargetIDs == null) { Debuger.LogWarning("No Target ID in ActionFrameData at time: " + data.Time.ToString()); return; } Dictionary <int, GameObject> allObjects = m_ActionPlayer.GetTargetObjects(); foreach (int index in data.TargetIDs) { if (allObjects.ContainsKey(index)) { m_lstTargetObjects.Add(allObjects[index]); } else if (index > 10000010) { Debuger.LogWarning(("<color=orange>" + (EActionFrameType)data.Type).ToString() + "</color> Affected GameObject Not Found, ID: " + index.ToString()); } else if (index > 10000000 && index <= 10000010) { if (!allObjects.ContainsKey(10000001) && !allObjects.ContainsKey(10000002)) { PlayerCharacter player = PlayerManager.Instance.GetPlayerInstance(); if (player != null) { CharTransformData charData = (CharTransformData)(player.GetTransformData()); GameObject charObject = charData.GetGameObject(); m_lstTargetObjects.Add(charObject); } } } else { Debuger.Log("Need Generated Object, ID: : " + index.ToString()); } } }
private void MoveNpc(Npc npc) { Vector3 hitpoint = new Vector3(); if (GetMouseHitTerrainPos(out hitpoint)) { if (m_Player == null) { return; } if (m_lstDictatePoint.Count <= 0) { // no dictate point npc.MoveTo(hitpoint); npc.IsPlayerControlled = true; npc.IsInGroup = false; return; } foreach (DictatePositionScript point in m_lstDictatePoint) { bool isOutOfCamera = !point.IsInCamera(); bool isRightDirection = IsRightDirection(hitpoint, point.transform.position); if (isOutOfCamera && isRightDirection) { // success npc.MoveTo(point.transform.position, false, () => { CharTransformData npcobj = (CharTransformData)(npc.GetTransformData()); //npcobj.GetGameObject().SetActive(false); }); npc.IsPlayerControlled = true; npc.IsInGroup = false; return; } } //fail } }
private void OnSelectNpc(Gesture gesture) { if (!(gesture is LongPressGesture)) { return; } if (!m_bIsDictate) { return; } LongPressGesture longGest = (LongPressGesture)gesture; // Set npc selected GameObject selection = gesture.Selection; if (null == selection) { return; } CharTransformContainer container = selection.GetComponent <CharTransformContainer>(); if (container == null) { //Debug.LogWarning("container not found"); return; } var data = container.GetData(); if (data is Npc) { Npc npc = (Npc)data; if (npc.IsInGroup) { CharTransformData charData = (CharTransformData)(npc.GetTransformData()); charData.SetSelectedStatus(true); } } }
public void Initialize(int id) { m_iId = id; m_NpcBaseInfo = ConfigManager.Instance.GetNpcConfig(id); if (null == m_NpcBaseInfo) { Debuger.LogWarning("can't load target npc: " + id); return; } m_bInitGroup = m_NpcBaseInfo.IsInGroup; m_StateMachine = new StateMachine(0, 0, this); m_CharTransformData = new CharTransformData(); m_CharTransformData.Initialize(this, m_NpcBaseInfo.ModelResource, AssetType.Char); //m_CharTransformData.AddNavmeshObs(); m_AIAgent = new AIAgent(m_NpcBaseInfo.AiId); LifeTickTask.Instance.RegisterToUpdateList(Update); MessageDispatcher.Instance.RegistMessage(ClientCustomMessageDefine.C_HIT_TERRAIN, OnHitTerrain); MessageDispatcher.Instance.RegistMessage(ClientCustomMessageDefine.C_HIT_LIFE, OnHitLife); LifeManager.RegisterLife(m_iId, this); }
public void Initialize(int id) { m_iId = id; m_NpcBaseInfo = ConfigManager.Instance.GetNpcConfig(id); if (null == m_NpcBaseInfo) { Debuger.LogWarning("can't load target npc: " + id); return; } m_bInitGroup = m_NpcBaseInfo.IsInGroup; m_StateMachine = new StateMachine(0, 0, this); m_CharTransformData = new CharTransformData(); m_CharTransformData.Initialize(this, m_NpcBaseInfo.ModelResource, AssetType.Char); //m_CharTransformData.AddNavmeshObs(); m_AIAgent = new AIAgent(m_NpcBaseInfo.AiId); LifeTickTask.Instance.RegisterToUpdateList(Update); MessageDispatcher.Instance.RegistMessage(ClientCustomMessageDefine.C_HIT_TERRAIN, OnHitTerrain); MessageDispatcher.Instance.RegistMessage(ClientCustomMessageDefine.C_HIT_LIFE, OnHitLife); LifeManager.RegisterLife(m_iId, this); }
public void SetRespawn(CharTransformData transformData) { respawnData = transformData; }
public void Reposition(CharTransformData transformData) { rigBod.MovePosition(respawnData.position); rigBod.MoveRotation(respawnData.rotation); }
private void OnCharMove(Gesture gesture) { // check gesture if (!(gesture is DragGesture)) { return; } DragGesture dragGest = (DragGesture)gesture; // Start if (dragGest.Phase == ContinuousGesturePhase.Started) { m_CurrentSelection = gesture.Selection; if (null == gesture.Selection) { return; } Transform transform = null; if (GetMouseHitPlayer(out transform)) { gesture.Selection = transform.gameObject; m_CurrentSelection = gesture.Selection; } // get char CharTransformContainer container = m_CurrentSelection.GetComponent <CharTransformContainer>(); if (container == null) { //Debug.LogWarning("container not found"); return; } var data = container.GetData(); // player if (data is PlayerCharacter) { m_Player = (PlayerCharacter)data; CharTransformData charData = (CharTransformData)(m_Player.GetTransformData()); m_DraggingFinger = gesture.Fingers[0]; CreateLineRender(); } // npc else if (data is Npc) { Npc npc = (Npc)data; CharTransformData charData = (CharTransformData)(npc.GetTransformData()); // check npc selected if (charData.GetSelectedStatus()) { m_DraggingFinger = gesture.Fingers[0]; CreateLineRender(); } } } // Update else if (dragGest.Phase == ContinuousGesturePhase.Updated) { // make sure this is the finger we started dragging with if (gesture.Fingers[0] != m_DraggingFinger) { return; } if (!m_CurrentSelection) { return; } if (m_LineRenderInstances.ContainsKey(m_CurrentSelection)) { GameObject lineRenderer = m_LineRenderInstances[m_CurrentSelection]; LineRenderer renderer = lineRenderer.GetComponent <LineRenderer>(); if (renderer) { renderer.SetPosition(0, m_CurrentSelection.transform.position); Vector3 hitpoint = new Vector3(); if (GetMouseHitTerrainPos(out hitpoint)) { renderer.SetPosition(1, hitpoint); if (GestureManager.CheckNavmeshPoint(hitpoint)) { renderer.SetColors(new Color(0, 1, 0), new Color(0, 1, 0)); } else { renderer.SetColors(new Color(1, 0, 0), new Color(1, 0, 0)); } } } } } // End else if (dragGest.Phase == ContinuousGesturePhase.Ended) { if (!m_CurrentSelection) { return; } ClearLineRender(); // get char CharTransformContainer container = m_CurrentSelection.GetComponent <CharTransformContainer>(); if (container == null) { //Debug.LogWarning("container not found"); return; } var data = container.GetData(); // player if (data is PlayerCharacter) { m_Player = (PlayerCharacter)data; MovePlayer(); } // npc else if (data is Npc) { Npc npc = (Npc)data; CharTransformData charData = (CharTransformData)(npc.GetTransformData()); if (charData.GetSelectedStatus()) { MoveNpc(npc); } } } }
public override void DoExit() { CharTransformData data = (((ITransformBehaviour)(unit)).GetTransformData()) as CharTransformData; data.StopMove(); }
public override void DoEnter(object param) { CharTransformData data = (((ITransformBehaviour)(unit)).GetTransformData()) as CharTransformData; //data.DirectPlayAnimation("Walk"); }