public override void Build()
        {
            if (m_SerialId == 0)
            {
                if (Application.isPlaying)
                {
                    TransformParam param = new TransformParam();
                    param.Position    = transform.position;
                    param.EulerAngles = transform.rotation.eulerAngles;
                    param.Scale       = transform.localScale;

                    m_SerialId = GameEntry.Level.CreateLevelObject(Constant.Define.Portal, param);
                }
                else
                {
#if UNITY_EDITOR
                    GameObject portal = LevelComponent.CreateLevelEditorObject(MapHolderType.Portal);
                    portal.transform.parent           = transform;
                    portal.transform.localPosition    = Vector3.zero;
                    portal.transform.localEulerAngles = Vector3.zero;
                    portal.transform.localScale       = Vector3.one;
#endif
                }
            }
        }
Exemple #2
0
 public void InitBornParam()
 {
     BornParam = new TransformParam
     {
         Position    = CachedTransform.position,
         EulerAngles = CachedTransform.eulerAngles,
         Scale       = CachedTransform.localScale
     };
 }
Exemple #3
0
        public override void Build()
        {
            if (Width < m_DefaultWidth)
            {
                Width = m_DefaultWidth;
            }
            int count = Mathf.CeilToInt(Width / m_DefaultWidth);

            m_Size.x = count * m_DefaultWidth;
            m_Size.y = 4;
            m_Size.z = 1.5f;

            m_Body = transform.Find("Body");
            if (m_Body == null)
            {
                m_Body        = new GameObject("Body").transform;
                m_Body.parent = transform;
                m_Body.transform.localPosition = Vector3.zero;
                m_Body.localEulerAngles        = Vector3.zero;
            }
            else
            {
                m_Body.DestroyChildren();
            }
            float halfCount = count * 0.5f;

            for (int i = 0; i < count; i++)
            {
                if (Application.isPlaying)
                {
                    TransformParam param = new TransformParam();
                    param.Position    = transform.position;
                    param.EulerAngles = transform.rotation.eulerAngles;
                    param.Scale       = transform.localScale;

                    m_SerialId = GameEntry.Level.CreateLevelObject(Constant.Define.Barrier, param);
                }
                else
                {
#if UNITY_EDITOR
                    GameObject barrier = LevelComponent.CreateLevelEditorObject(MapHolderType.Barrier);
                    barrier.transform.parent = transform;
                    Vector3 localPosition = Vector3.right * (i - halfCount + 0.5f) * m_DefaultWidth;
                    localPosition.z = m_Size.z * 0.5f;
                    barrier.transform.localPosition    = localPosition;
                    barrier.transform.localEulerAngles = Vector3.zero;
                    barrier.transform.localScale       = Vector3.one;
#endif
                }
            }

            m_Collider        = gameObject.GetOrAddComponent <BoxCollider>();
            m_Collider.size   = m_Size;
            m_Collider.center = new Vector3(0, m_Size.y * 0.5f, m_Size.z * 0.5f);
            GlobalTools.SetLayer(gameObject, Constant.Layer.BarrerId);
        }
Exemple #4
0
        private void CreateMonster(MapMonsterCall data)
        {
            Vector3        bornEulerAngles = data.EulerAngles;
            Vector3        bornPosition    = GlobalTools.NavSamplePosition(data.Position);
            TransformParam param           = TransformParam.Create(bornPosition, bornEulerAngles);

            int serialId = GameEntry.Level.CreateEnemy(data.Id, param);

            mMonsterGUIDSet.Add(serialId);
        }
Exemple #5
0
        public static TransformParam Create(Vector3 pos, Vector3 angle, Vector3 scale)
        {
            TransformParam data = new TransformParam
            {
                Position    = pos,
                EulerAngles = angle,
                Scale       = scale
            };

            return(data);
        }
        private void CreateMonster()
        {
            if (Region == null)
            {
                Debug.LogError("找不到区域" + Region.Id);
                return;
            }
            Vector3        pos      = GlobalTools.RandomOnCircle(5) + Region.Position;
            Vector3        angle    = new Vector3(0, UnityEngine.Random.Range(0, 360), 0);
            TransformParam param    = TransformParam.Create(pos, angle);
            int            serialId = GameEntry.Level.CreateEnemy(MonsterID, param);

            m_Monsters.Add(serialId);
        }
        private void LoadMount()
        {
            int mountId = UnityEngine.Random.Range(100001, 100003);

            TransformParam param = TransformParam.Create(CachedTransform.position, CachedTransform.eulerAngles);

            int             entityId = GameEntry.Entity.GenerateSerialId();
            MountEntityData data     = new MountEntityData(entityId, mountId, ActorType.Mount, BattleCampType.Ally, this)
            {
                Position = param.Position,
                Rotation = Quaternion.Euler(param.EulerAngles),
                Scale    = param.Scale
            };

            GameEntry.Level.AddRole <MountRole>(data);
            this.Mount = entityId;
        }
        public int CreateLevelObject(int id, TransformParam param)
        {
            if (param == null)
            {
                return(0);
            }

            int             entityId        = GameEntry.Entity.GenerateSerialId();
            LevelObjectData levelObjectData = new LevelObjectData(entityId, id);

            levelObjectData.Position = param.Position;
            levelObjectData.Rotation = Quaternion.Euler(param.EulerAngles);
            levelObjectData.Scale    = param.Scale;

            GameEntry.Entity.ShowEntity(typeof(LevelObject), levelObjectData);
            return(entityId);
        }
        public int CreateEnemy(int typeId, TransformParam param)
        {
            if (typeId <= 0 || param == null)
            {
                return(0);
            }

            int            entityId = GameEntry.Entity.GenerateSerialId();
            RoleEntityData data     = new RoleEntityData(entityId, typeId, ActorType.Monster, BattleCampType.Enemy)
            {
                Position = param.Position,
                Rotation = Quaternion.Euler(param.EulerAngles),
                Scale    = param.Scale
            };

            AddRole <EnemyRole>(data);
            return(entityId);
        }
Exemple #10
0
        public override void Build()
        {
            transform.DestroyChildren();
            if (Application.isPlaying)
            {
                TransformParam param = new TransformParam();
                param.Position    = transform.position;
                param.EulerAngles = transform.rotation.eulerAngles;
                param.Scale       = transform.localScale;

                m_SerialId = GameEntry.Level.CreateLevelObject(Id, param);
            }
            else
            {
#if UNITY_EDITOR
                GameObject mine = LevelComponent.CreateLevelEditorObject(MapHolderType.MineGroup);
                mine.transform.SetParent(transform, false);
                mine.transform.localPosition = Vector3.zero;
                mine.transform.localScale    = Vector3.one;
                mine.transform.localRotation = Quaternion.identity;
#endif
            }
        }
Exemple #11
0
 public void UpdateTransform(TransformParam param)
 {
     CachedTransform.position    = param.Position;
     CachedTransform.eulerAngles = param.EulerAngles;
     CachedTransform.localScale  = param.Scale;
 }