Exemple #1
0
        private float GetAngle(PlayerEntity myEntity, PlayerEntity teamEntity)
        {
            //角度
            float yaw   = CommonMathUtil.TransComAngle(myEntity.orientation.Yaw);
            float angle = CommonMathUtil.GetAngle(new Vector2(teamEntity.position.Value.x, teamEntity.position.Value.z), new Vector2(myEntity.position.Value.x, myEntity.position.Value.z));

            return(CommonMathUtil.GetDiffAngle(angle, yaw));
        }
Exemple #2
0
        public bool Meet(IEventArgs args)
        {
            FreeData fd  = (FreeData)args.GetUnit(player);
            object   obj = ((FreeRuleEventArgs)args).GetEntity(entity);

            if (fd != null && obj != null)
            {
                PlayerEntity   playerEntity = fd.Player;
                FreeMoveEntity objEntity    = (FreeMoveEntity)obj;
                float          yaw          = CommonMathUtil.TransComAngle(playerEntity.orientation.Yaw);
                float          ang          = CommonMathUtil.GetAngle(new Vector2(objEntity.position.Value.x, objEntity.position.Value.z), new Vector2(playerEntity.position.Value.x, playerEntity.position.Value.z));
                return(CommonMathUtil.GetDiffAngle(ang, yaw) <= FreeUtil.ReplaceFloat(angle, args) && Vector3.Distance(playerEntity.position.Value, objEntity.position.Value) <= FreeUtil.ReplaceFloat(distance, args));
            }
            return(false);
        }
Exemple #3
0
        private void CheckFlash(ClientEffectEntity entity)
        {
            PlayerEntity player = AllContexts.player.flagSelfEntity;

            //闪光弹位置
            Vector3 pos = entity.position.Value;

            //水里1米
            if (SingletonManager.Get <MapConfigManager>().InWater(pos))
            {
                float wy = SingletonManager.Get <MapConfigManager>().WaterSurfaceHeight(pos);
                if (!float.IsNaN(wy) && wy - pos.y > 1)
                {
                    return;
                }
            }

            bool    isShow = false;
            float   alpha = 0, keepTime = 0, decayTime = 0;
            Vector3 playerPos = player.position.Value;

            //位置稍上抬
            pos.y += 0.1f;

            //玩家头部位置
            Transform tran;

            if (player.appearanceInterface.Appearance.IsFirstPerson)
            {
                var root = player.RootGo();
                tran = BoneMount.FindChildBoneFromCache(root, BoneName.CharacterHeadBoneName);
            }
            else
            {
                var root = player.RootGo();
                tran = BoneMount.FindChildBoneFromCache(root, BoneName.CharacterHeadBoneName);
            }
            if (null != tran)
            {
                playerPos = tran.position;
            }

            //距离
            float dis = Vector3.Distance(playerPos, pos);

            if (dis >= 40)
            {
                return;
            }

            float diffAngle = 0;

            //判断是否手上爆炸
            bool isHandBomb = entity.hasEffectRotation && entity.effectRotation.Yaw > 0;

            if (!(entity.ownerId.Value == player.entityKey.Value && isHandBomb))
            {
                //遮挡
                Vector3 hitPoint;
                bool    isHit = CommonMathUtil.Raycast(playerPos, pos, dis, _layerMask, out hitPoint);
                if (isHit)
                {
                    return;
                }

                //角度
                float yaw   = CommonMathUtil.TransComAngle(player.orientation.Yaw);
                float angle = CommonMathUtil.GetAngle(new Vector2(pos.x, pos.z), new Vector2(playerPos.x, playerPos.z));
                diffAngle = Mathf.Abs(angle - yaw);
                diffAngle = Mathf.Min(360 - diffAngle, diffAngle);
            }

            if (diffAngle <= 60)
            {
                if (dis < 20)
                {
                    isShow    = true;
                    alpha     = 1;
                    keepTime  = Mathf.Max(1.2f, 3 * Mathf.Pow(0.4f, dis / 30));
                    decayTime = alpha / 0.4f;
                }
                else if (dis < 40)
                {
                    isShow    = true;
                    alpha     = 1 - dis * 0.00025f;
                    keepTime  = 0;
                    decayTime = alpha / 0.4f;
                }
            }
            else if (diffAngle <= 90)
            {
                if (dis <= 20)
                {
                    isShow    = true;
                    alpha     = Mathf.Max(0, 1 - dis * 0.00025f);
                    keepTime  = 0;
                    decayTime = alpha / 0.4f;
                }
            }
            else if (diffAngle <= 180)
            {
                if (dis <= 10)
                {
                    isShow    = true;
                    alpha     = Mathf.Max(0, 0.8f - dis * 0.00025f);
                    keepTime  = 0;
                    decayTime = alpha / 0.5f;
                }
            }

            if (isShow)
            {
                ScreenFlashInfo screenFlashInfo = new ScreenFlashInfo();
                screenFlashInfo.IsShow            = true;
                screenFlashInfo.Alpha             = alpha;
                screenFlashInfo.KeepTime          = keepTime;
                screenFlashInfo.DecayTime         = decayTime;
                AllContexts.ui.uI.ScreenFlashInfo = screenFlashInfo;
                player.AudioController().PlayDizzyAudio(dis, 40);
                //      GameAudioMedia.PlayFlashDizzyAudio(pos,Math.Min(0,40-dis));
            }
        }
Exemple #4
0
        public void UIUpdate(int frameTime)
        {
            if (SingletonManager.Get <FreeUiManager>().Contexts1 == null ||
                SingletonManager.Get <FreeUiManager>().Contexts1.ui.uISessionEntity.uISession == null ||
                SingletonManager.Get <FreeUiManager>().Contexts1.player.flagSelfEntity == null)
            {
                return;
            }

            UpdatePlaine();

            PlayerEntity selfEntity = SingletonManager.Get <FreeUiManager>().Contexts1.ui.uI.Player;

            var data = SingletonManager.Get <FreeUiManager>().Contexts1.ui.map;

            data.TeamInfos.Clear();
            _teamNums = "";

            var map = SingletonManager.Get <FreeUiManager>().Contexts1.ui.map;

            map.TeamPlayerMarkInfos.Clear();

            var modeId = SingletonManager.Get <FreeUiManager>().Contexts1.session.commonSession.RoomInfo.ModeId;

            foreach (PlayerEntity playerEntity in SingletonManager.Get <FreeUiManager>().Contexts1.player.GetEntities())
            {
                try
                {
                    if (playerEntity.hasPlayerInfo && playerEntity.hasPosition &&
                        ((!GameRules.IsBio(modeId) && playerEntity.playerInfo.TeamId == selfEntity.playerInfo.TeamId) ||
                         (GameRules.IsBio(modeId) && playerEntity.hasGamePlay && selfEntity.gamePlay.IsMatchJob(playerEntity.gamePlay.JobAttribute))))
                    {
                        if (!infoMap.ContainsKey(playerEntity.playerInfo.PlayerId))
                        {
                            MiniMapTeamPlayInfo info = new MiniMapTeamPlayInfo(playerEntity.playerInfo.PlayerId, playerEntity.playerInfo.EntityId, true, 1,
                                                                               MapUtils.TeamColor(playerEntity.playerInfo.Num), MiniMapPlayStatue.NORMAL, new Vector3(500, 0, 300), 45f,
                                                                               new List <MiniMapPlayMarkInfo>()
                            {
                                new MiniMapPlayMarkInfo(new Vector3(500, 250), 1, Color.black),
                            }, false, 0,
                                                                               playerEntity.playerInfo.PlayerName, (int)playerEntity.gamePlay.CurHp, playerEntity.gamePlay.MaxHp, (int)playerEntity.gamePlay.InHurtedHp, false, playerEntity.position.Value);

                            infoMap[playerEntity.playerInfo.PlayerId] = info;
                        }

//                        Vector3 leftMinPos = TerrainCommonData.leftMinPos;

                        MiniMapTeamPlayInfo oneInfo = infoMap[playerEntity.playerInfo.PlayerId];

                        if (playerEntity == selfEntity)
                        {
                            oneInfo.IsPlayer = true;
                            data.CurPlayer   = oneInfo;
                        }
                        else
                        {
                            oneInfo.IsPlayer = false;
                        }

                        if (oneInfo.Num != playerEntity.playerInfo.Num)
                        {
                            oneInfo.Num        = playerEntity.playerInfo.Num;
                            oneInfo.PlayerName = playerEntity.playerInfo.PlayerName;
                            oneInfo.Color      = MapUtils.TeamColor(oneInfo.Num);
                        }

                        //pos,rot

                        /*if (playerEntity.hasControlledVehicle)
                         * {
                         *  //车上
                         *  Transform trans = playerEntity.GetVehicleSeatTransform(SingletonManager.Get<FreeUiManager>().Contexts1.vehicle);
                         *  oneInfo.Pos = new Vector2(trans.position.x - leftMinPos.x, trans.position.z - leftMinPos.z);
                         *  oneInfo.FaceDirection = trans.eulerAngles.y;
                         * }
                         * else */
                        if (playerEntity.gamePlay.GameState == GameState.AirPlane)
                        {
                            //飞机上(位置已做过偏移,这里不再偏移)
                            AirPlaneData planeData = data.PlaneData;
                            oneInfo.Pos           = new MapFixedVector2(planeData.Pos.WorldVector3().To2D());
                            oneInfo.Pos3D         = new MapFixedVector3(planeData.Pos.WorldVector3());
                            oneInfo.FaceDirection = planeData.Direction;
                        }
                        else
                        {
//                            oneInfo.Pos = new Vector2(playerEntity.position.Value.x - leftMinPos.x, playerEntity.position.Value.z - leftMinPos.z);
                            oneInfo.Pos           = new MapFixedVector2(playerEntity.position.FixedVector3.To2D());
                            oneInfo.Pos3D         = new MapFixedVector3(playerEntity.position.FixedVector3);
                            oneInfo.FaceDirection = playerEntity.orientation.Yaw;
                        }

                        //Test Trace
                        if (oneInfo.IsPlayer)
                        {
                            TerrainTestSystem.yaw = oneInfo.FaceDirection;
                        }
                        if (_teamNums.Equals(""))
                        {
                            _teamNums = oneInfo.Num.ToString();
                        }
                        else
                        {
                            _teamNums += "|" + oneInfo.Num;
                        }

                        //status
                        if (playerEntity.gamePlay.IsLifeState(EPlayerLifeState.Dead))
                        {
                            oneInfo.Statue = MiniMapPlayStatue.DEAD;
                            data.RemoveMapMark(playerEntity.playerInfo.PlayerId);
                        }
                        else if (playerEntity.gamePlay.IsLifeState(EPlayerLifeState.Dying))
                        {
                            oneInfo.Statue = MiniMapPlayStatue.HURTED;
                        }
                        else
                        {
                            if (playerEntity.IsOnVehicle())
                            {
                                oneInfo.Statue = MiniMapPlayStatue.ZAIJU;
                            }
                            else if (PlayerIsDrop(playerEntity))
                            {
                                oneInfo.Statue = MiniMapPlayStatue.TIAOSAN;
                            }
                            else
                            {
                                oneInfo.Statue = MiniMapPlayStatue.NORMAL;
                            }
                        }

                        //map mark
                        oneInfo.MarkList.Clear();
                        if (oneInfo.IsPlayer)
                        {
                            foreach (var mark in data.MapMarks.Values)
                            {
                                oneInfo.MarkList.Add(mark);

                                TeamPlayerMarkInfo lmark = new TeamPlayerMarkInfo();
                                lmark.Angel     = CommonMathUtil.GetAngle(mark.Pos, oneInfo.Pos.ShiftedUIVector2());
                                lmark.MarkColor = MapUtils.TeamColor(mark.Num);
                                map.TeamPlayerMarkInfos.Add(lmark);
                            }
                            TerrainTestSystem.mark = map.TeamPlayerMarkInfos.Count;
                        }

                        //New
                        oneInfo.PlayerName    = playerEntity.playerInfo.PlayerName;
                        oneInfo.CurHp         = (int)playerEntity.gamePlay.CurHp;
                        oneInfo.MaxHp         = playerEntity.gamePlay.MaxHp;
                        oneInfo.CurHpInHurted = (int)playerEntity.gamePlay.InHurtedHp;
                        oneInfo.IsMark        = data.MapMarks.ContainsKey(oneInfo.PlayerId) ? true : false;
                        oneInfo.TopPos        = PlayerEntityUtility.GetPlayerTopPosition(playerEntity);
                        oneInfo.EntityId      = playerEntity.entityKey.Value.EntityId;
                        data.TeamInfos.Add(oneInfo);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogErrorFormat(e.Message);
                }
            }

            TerrainTestSystem.teamCnt = data.TeamInfos.Count;
            TerrainTestSystem.teamNum = _teamNums;
        }