示例#1
0
        /// <summary>
        /// 尝试获取其他传送点位置
        /// </summary>
        /// <param name="teleporter">当前传送点</param>
        /// <param name="otherTeleporter">其他传送点位置</param>
        public bool TryGetOtherTeleporter(TerrainBrickA5 teleporter, out Vector3 otherTeleporter)
        {
            otherTeleporter = teleporter.CachedTransform.position;
            List <TerrainBrickA5> others = new List <TerrainBrickA5>();

            foreach (var brick in m_Teleporters)
            {
                if (brick != teleporter)
                {
                    others.Add(brick);
                }
            }
            if (others.Count == 0)
            {
                return(false);
            }
            if (others.Count == 1)
            {
                otherTeleporter = others[0].CachedTransform.position;
                return(true);
            }

            otherTeleporter = others[UnityEngine.Random.Range(0, others.Count)].CachedTransform.position;

            return(true);
        }
示例#2
0
        void TeleportCharactorEventHandler(object sender, GameEventArgs e)
        {
            TeleportCharactorEventArgs args = e as TeleportCharactorEventArgs;

            if (args == null)
            {
                return;
            }

            Charactor charactor = GameEntry.Entity.GetEntity(args.CharactorId).Logic as Charactor;

            if (charactor == null)
            {
                return;
            }

            TerrainBrickA5 a5 = GameEntry.Entity.GetEntity(args.FromTerrainBrickId).Logic as TerrainBrickA5;

            if (a5 == null)
            {
                return;
            }

            Vector3 to;

            if (m_TerrainManager.TryGetOtherTeleporter(a5, out to))
            {
                charactor.Teleport(to);
            }
        }
示例#3
0
        bool FindTeleporters(ShowEntitySuccessEventArgs args)
        {
            EntityLogic entityLogic = args.Entity.Logic;

            TerrainBrickA5 a5 = entityLogic as TerrainBrickA5;

            if (a5 != null)
            {
                m_Teleporters.Add(a5);
                return(true);
            }
            return(false);
        }