예제 #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));
        }
예제 #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);
        }
예제 #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));
            }
        }