protected override void OnInit(object userData) { base.OnInit(userData); m_PlayerEntityData = userData as PlayerEntityData; if (m_PlayerEntityData == null) { Log.Error("playerEntityData is null"); return; } m_Animator = gameObject.GetComponent <Animator>(); m_CharacterController = gameObject.GetOrAddComponent <CharacterController>(); PlayerActor = new ActorPlayer(m_PlayerEntityData.Id, m_PlayerEntityData.TypeId, gameObject, ActorType.Player, ActorBattleCampType.Ally, m_CharacterController, m_Animator); PlayerActor.Init(); //设置自身,与跟随相机到场景出身点 Vector3 spawnPos = GameEntry.Scene.GetCurSceneSpawnPos(); CachedTransform.position = spawnPos; GameEntry.Camera.SetCameraRigPos(spawnPos); AddEventListener(); }
protected override void OnShow(object userData) { base.OnShow(userData); CachedTransform.rotation = Quaternion.identity; m_EntityData = userData as MountEntityData; if (m_EntityData == null) { Log.Error("playerEntityData is null"); return; } ActorType actorType = m_EntityData.ActorType; BattleCampType campType = m_EntityData.CampType; Actor = new ActorMount(this, actorType, campType, m_CharacterController, m_Animator); Actor.Init(); if (m_EntityData.Host != null) { m_Host = m_EntityData.Host; Actor.SetHost(m_Host); m_Host.Vehicle = Actor; Transform ridePoint = ((ActorMount)Actor).GetRidePoint(); if (ridePoint != null) { m_Host.CachedTransform.parent = ridePoint; m_Host.CachedTransform.localPosition = Vector3.zero; m_Host.CachedTransform.localRotation = Quaternion.identity; } } }
public int AddPartner(ActorPlayer host, PartnerSortType sortPos, int typeId) { if (typeId <= 0) { return(0); } if (host == null) { return(0); } int entityId = GameEntry.Entity.GenerateSerialId(); PartnerEntityData data = new PartnerEntityData(entityId, typeId, ActorType.Partner, BattleCampType.Ally, host, sortPos); Vector3 pPos = host.GetPartnerPosBySort(sortPos); data.Position = pPos; data.Rotation = host.CachedTransform.rotation; data.Scale = Vector3.one * 1.5f; AddRole <PartnerRole>(data); return(entityId); }
protected override void OnHide(object userData) { base.OnHide(userData); RemoveEventListener(); PlayerActor.Destory(); PlayerActor = null; }
public void CreatePlayerActor(ActorPlayer player) { if (player == null) { throw new GameFrameworkException("Create Player Fail!"); } this.PlayerActor = player; }
private void OnPlayerDead(object sender, GameEventArgs e) { List <RoleEntityBase> pList = GetRolesByActorType(ActorType.Monster); for (int i = 0; i < pList.Count; i++) { pList[i].Actor.SetTarget(null); } PlayerActor.CachedTransform.localPosition = Vector3.zero; this.PlayerActor = null; this.m_Victory = false; this.LeaveCurrentLevel(); }
protected override void OnUpdate(IFsm <ActorBase> fsm, float elapseSeconds, float realElapseSeconds) { base.OnUpdate(fsm, elapseSeconds, realElapseSeconds); ActorPlayer host = m_Owner.Host as ActorPlayer; if (host == null) { return; } Vector3 pos = host.GetPartnerPosBySort(m_Owner.Sort); m_Owner.ExecuteCommand(new AutoMoveCommand(pos, OnFollowFinished)); }
protected override void OnShow(object userData) { base.OnShow(userData); m_EntityData = userData as PlayerEntityData; if (m_EntityData == null) { Log.Error("playerEntityData is null"); return; } //创建Actor ActorType actorType = m_EntityData.ActorType; BattleCampType campType = m_EntityData.CampType; Actor = new ActorPlayer(this, actorType, campType, m_CharacterController, m_Animator); Actor.Init(); ((ActorPlayer)Actor).BattleState = m_EntityData.BattleState; GameEntry.Camera.SwitchCameraBehaviour(CameraBehaviourType.LockLook); AddEventListener(); }