Esempio n. 1
0
        //This is to prevent other plugins overwriting god mode by accident
        private void OnPlayerDamaged(UnturnedPlayer player, ref EDeathCause cause, ref ELimb limb, ref UnturnedPlayer killer, ref Vector3 direction, ref float damage, ref float times, ref bool canDamage)
        {
            if (player.GodMode)
            {
                return;
            }

            var untPlayer = PlayerUtil.GetUnturnedPlayer(player);

            var currentRegion = GetRegionAt(untPlayer.Position);

            if (currentRegion == null)
            {
                return;                        //No region? Not our problem!
            }
            //Flag is stop the process of this function because the user opted to disabled the auto-protection feature
            if (currentRegion.Flags.Exists(fg => fg.Name.Equals("DisableGodModeProtection", StringComparison.OrdinalIgnoreCase)))
            {
                return;
            }
            try //This is just here to prevent the console logging at a lot of errors because exceptions will be generated by using this way
            {
                if (currentRegion != null)
                {
                    OnPlayerEnteredRegion(player, currentRegion);
                }
            } catch (Exception) { }
        }
Esempio n. 2
0
        public override Region OnCreate(IRocketPlayer player, string name, string[] args)
        {
            var pos = PlayerUtil.GetUnturnedPlayer(player).Position;
            var r   = args.GetFloatParameter(0);

            if (r == null)
            {
                UnturnedChat.Say(player, "Usage: /screate circle <radius>", Color.red);
                return(null);
            }

            Radius = r.Value;

            Center = new SerializablePosition(pos);

            var region = new Region
            {
                Name   = name,
                Owners = new List <ulong> {
                    PlayerUtil.GetId(player)
                },
                Type = this
            };

            return(region);
        }
Esempio n. 3
0
    public override void UpdateAction()
    {
        base.UpdateAction();

        if (EntityUtil.StateActionMacro(Owner))
        {
            return;
        }

        if (PlayerUtil.GetAttackInput())
        {
            Owner.CurrentAction = PlayerAttackAction.GetInstance();
            return;
        }

        Vector3 velocity = PlayerUtil.GetVelocityInput();

        if (velocity.magnitude < 0.1f)
        {
            Owner.CurrentAction = PlayerIdleAction.GetInstance();
            return;
        }

        Owner.transform.rotation = Quaternion.LookRotation(velocity, Vector3.up);
        Owner.NavAgent.Move(velocity * Owner.Status.CurrentSpeed * Time.deltaTime);

        AnimUtil.RotationAnim(Owner, "run");
    }
        /// <summary>
        /// Split eligible players based upon contribution into "all", "winner", "loser"
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="lockingRealm"></param>
        /// <returns></returns>
        public Tuple <ConcurrentDictionary <Player, int>, ConcurrentDictionary <Player, int>, ConcurrentDictionary <Player, int> > DetermineEligiblePlayers(ILogger logger, Realms lockingRealm)
        {
            ConcurrentDictionary <Player, int> winningRealmPlayers;
            ConcurrentDictionary <Player, int> losingRealmPlayers;
            ConcurrentDictionary <Player, int> eligiblePlayersAllRealms;


            var allEligiblePlayers = GetEligiblePlayers(0).ToList();

            // Reverse the order so we have highest eligbility first.
            allEligiblePlayers.Reverse();

            // var rewardAssignments = new List<LootBagTypeDefinition>();

            // Split the contributing players into segments.
            var eligibilitySplits = PlayerUtil.SegmentEligiblePlayers(
                allEligiblePlayers,
                lockingRealm,
                this,
                true,
                true);

            // All eligible players that are still in game
            eligiblePlayersAllRealms = eligibilitySplits.Item1;
            winningRealmPlayers      = eligibilitySplits.Item2;
            losingRealmPlayers       = eligibilitySplits.Item3;

            logger.Debug($"eligiblePlayersAllRealms Players Count = {eligiblePlayersAllRealms.Count()}");
            logger.Debug($"winningRealmPlayers Players Count = {winningRealmPlayers.Count()}");
            logger.Debug($"losingRealmPlayers Players Count = {losingRealmPlayers.Count()}");

            return(eligibilitySplits);
        }
Esempio n. 5
0
        private void RefreshPlayerLevelAndAttributes()
        {
            PlayerInfo playerInfo     = GameProxy.instance.PlayerInfo;
            int        playerLevel    = playerInfo.level;
            int        playerMaxLevel = GlobalData.GetGlobalData().playerLevelMax;
            float      playerExpPercentToNextLevel = PlayerUtil.GetPlayerExpPercentToNextLevel(playerInfo);

            playerExpSlider.value       = playerExpPercentToNextLevel;
            playerExpPercentText.text   = string.Format(Localization.Get("common.percent"), ((int)(playerExpPercentToNextLevel * 100)));
            playerNameAndLevelText.text = string.Format(Localization.Get("ui.player_view.profession_name_and_level"), Localization.Get(playerInfo.heroData.name), playerLevel, playerMaxLevel);

            Dictionary <RoleAttributeType, RoleAttribute> playerAttributeDictionary = PlayerUtil.CalcPlayerAttributesDic(playerInfo);
            Dictionary <RoleAttributeType, RoleAttribute> playerAddAttrByEquipDic   = PlayerUtil.CalcPlayerAttributesDicByEquip(playerInfo);

            hpText.text = playerAttributeDictionary[RoleAttributeType.HP].ValueString;


            RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(playerInfo.heroData.roleType);
            int offence   = 0;
            int attackAdd = 0;

            if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack)
            {
                offence   = (int)playerAttributeDictionary[RoleAttributeType.NormalAtk].value;
                attackAdd = GetRoleAttrValue(playerAddAttrByEquipDic.GetValue(RoleAttributeType.NormalAtk));
            }
            else if (roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack)
            {
                offence   = (int)playerAttributeDictionary[RoleAttributeType.MagicAtk].value;
                attackAdd = GetRoleAttrValue(playerAddAttrByEquipDic.GetValue(RoleAttributeType.MagicAtk));
            }
            offenceText.text = offence.ToString();

            defenceText.text = playerAttributeDictionary[RoleAttributeType.Normal_Def].ValueString;
            speedText.text   = playerAttributeDictionary[RoleAttributeType.Speed].ValueString;

            float crit  = playerAttributeDictionary.ContainsKey(RoleAttributeType.Crit) ? playerAttributeDictionary[RoleAttributeType.Crit].value : 0;
            float dodge = playerAttributeDictionary.ContainsKey(RoleAttributeType.Dodge) ? playerAttributeDictionary[RoleAttributeType.Dodge].value : 0;
            float block = playerAttributeDictionary.ContainsKey(RoleAttributeType.Block) ? playerAttributeDictionary[RoleAttributeType.Block].value : 0;
            float hit   = playerAttributeDictionary.ContainsKey(RoleAttributeType.Hit) ? playerAttributeDictionary[RoleAttributeType.Hit].value : 0;

            critText.text  = string.Format(Localization.Get("common.percent"), crit);
            dodgeText.text = string.Format(Localization.Get("common.percent"), dodge);
            blockText.text = string.Format(Localization.Get("common.percent"), block);
            hitText.text   = string.Format(Localization.Get("common.percent"), hit);

            hpAddText.text          = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.HP) ? string.Format("(+{0})", playerAddAttrByEquipDic[RoleAttributeType.HP].ValueString) : string.Empty;
            attackAddText.text      = attackAdd == 0 ? string.Empty : string.Format("(+{0})", attackAdd);
            defenceAddText.text     = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Normal_Def) ? string.Format("(+{0})", playerAddAttrByEquipDic[RoleAttributeType.Normal_Def].ValueString) : string.Empty;
            actionPointAddText.text = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Speed) ? string.Format("(+{0})", playerAddAttrByEquipDic[RoleAttributeType.Speed].ValueString) : string.Empty;
            float critAdd  = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Crit) ? playerAddAttrByEquipDic[RoleAttributeType.Crit].value : 0;
            float dodgeAdd = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Dodge) ? playerAddAttrByEquipDic[RoleAttributeType.Dodge].value : 0;
            float blockAdd = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Block) ? playerAddAttrByEquipDic[RoleAttributeType.Block].value : 0;
            float hitAdd   = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Hit) ? playerAddAttrByEquipDic[RoleAttributeType.Hit].value : 0;

            critAddText.text  = critAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", critAdd));
            dodgeAddText.text = dodgeAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", dodgeAdd));
            blockAddText.text = blockAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", blockAdd));
            hitAddText.text   = hitAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", hitAdd));
        }
Esempio n. 6
0
    public override void UpdateAction()
    {
        base.UpdateAction();
        PlayerUtil.CardInterfaceLogicMacro();


        if (EntityUtil.HitDeadLogicMacro(Owner, "PlayerHitAction", "PlayerDeadAction"))
        {
            return;
        }

        if (PlayerUtil.GetAttackInput())
        {
            Owner.CurrentAction = PlayerAttackAction.GetInstance();
            return;
        }

        Vector3 velocity = PlayerUtil.GetVelocityInput();

        if (velocity.magnitude < 0.1f)
        {
            Owner.CurrentAction = PlayerIdleAction.GetInstance();
            return;
        }

        Owner.transform.rotation = Quaternion.LookRotation(velocity, Vector3.up);
        Owner.NavAgent.Move(velocity * 1.1f * Time.deltaTime);

        AnimUtil.RotationAnim(Owner, "run");
    }
Esempio n. 7
0
    public void SendDamage()
    {
        Character[] enemys = Object.FindObjectsOfType <Character>();
        float       damage = PlayerUtil.CalculatingCardPowerValue(DataTable._Parameter[0]);

        if (enemys == null)
        {
            return;
        }

        foreach (var e in enemys)
        {
            if (e == Owner)
            {
                continue;
            }

            if ((Target.Point -
                 e.transform.position).magnitude <= Isometric.IsometricTileSize.x * 3f)
            {
                e.AddState(new CharacterHitState(e, damage, 0.1f).Init());
                e.AddState(new CharacterState(CharacterStateType.E_Stun, e, DataTable._Parameter[1]));
                IsoParticle.CreateParticle("Sliced_Power1", e.transform.position
                                           + new Vector3(0f, Isometric.IsometricTileSize.y * 0.5f, 0f), 0f
                                           );
                IsoParticle.CreateParticle("Sliced_Power2", e.transform.position
                                           + new Vector3(0f, Isometric.IsometricTileSize.y * 0.5f, 0f),
                                           0f);
            }
        }

        PlayerUtil.ConsumeCardPowerUpStatus();
    }
Esempio n. 8
0
    public override void UpdateAction()
    {
        base.UpdateAction();
        PlayerUtil.CardInterfaceLogicMacro();

        if (EntityUtil.HitDeadLogicMacro(Owner, "PlayerHitAction", "PlayerDeadAction"))
        {
            return;
        }

        float currentAnimTime = AnimUtil.GetAnimNormalizedTime(Owner);

        if (currentAnimTime > 0.6f)
        {
            if (PlayerUtil.GetAttackInput())
            {
                isAttackCommand = true;
            }
        }

        Owner.NavAgent.Move(Owner.transform.forward * Isometric.IsometricTileSize.x * -0.3f * Time.deltaTime);

        if (AnimUtil.IsLastFrame(Owner))
        {
            Owner.CurrentAction = isAttackCommand ? (CharacterAction)PlayerAttack2Action.GetInstance()
                : (CharacterAction)PlayerIdleAction.GetInstance();
            return;
        }
    }
        public override void UpdateState(List <UnturnedPlayer> players)
        {
            foreach (var player in players)
            {
                var group = Region.GetGroup(player);
                if (!GetValueSafe(group))
                {
                    continue;
                }

                var id      = PlayerUtil.GetId(player);
                var veh     = player.Player.movement.getVehicle();
                var isInVeh = veh != null;

                if (!_lastVehicleStates.ContainsKey(id))
                {
                    _lastVehicleStates.Add(id, veh);
                }

                var wasDriving = _lastVehicleStates[id];

                if (!isInVeh || wasDriving ||
                    !GetValueSafe(Region.GetGroup(player)))
                {
                    continue;
                }

                veh.forceRemovePlayer(out byte seat, PlayerUtil.GetCSteamId(player), out Vector3 point, out byte angle);
                VehicleManager.instance.channel.send("tellExitVehicle", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, veh.instanceID, seat, point, angle, true);
            }
        }
Esempio n. 10
0
    public void SendDamage()
    {
        Character[] enemys = Object.FindObjectsOfType <Character>();
        float       damage = PlayerUtil.CalculatingCardPowerValue(80f);

        if (enemys == null)
        {
            return;
        }

        foreach (var e in enemys)
        {
            if (e == Owner)
            {
                continue;
            }
            float angle = Mathf.Acos(Vector3.Dot((e.transform.position - Owner.transform.position).normalized, Owner.transform.forward))
                          * Mathf.Rad2Deg;
            if ((Owner.transform.position - e.transform.position).magnitude <= Isometric.IsometricTileSize.x * 1.8f &&
                angle < 80f)
            {
                e.AddNotifyEvent(new CharacterNotifyEvent(CharacterNotifyType.E_Damage, damage));
                IsoParticle.CreateParticle("Sliced_Power1", e.transform.position
                                           + new Vector3(0f, Isometric.IsometricTileSize.y * 0.5f, 0f),
                                           angle);
                IsoParticle.CreateParticle("Sliced_Power2", e.transform.position
                                           + new Vector3(0f, Isometric.IsometricTileSize.y * 0.5f, 0f),
                                           angle + 90f);
            }
        }

        PlayerUtil.ConsumeCardPowerUpStatus();
    }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            var player = PlayerUtil.GetUnturnedPlayer(caller);
            var pos    = player.Position;

            UnturnedChat.Say(caller, $"Position: X: {pos.x}, Y: {pos.y}, Z: {pos.z}; + Rotation: {player.Player.transform.rotation.eulerAngles.y}", Color.green);
        }
Esempio n. 12
0
        public override void UpdateState(List <UnturnedPlayer> players)
        {
            for (int i = 0; i < players.Count; i++)
            {
                var player  = players[i];
                var id      = PlayerUtil.GetId(player);
                var veh     = player.Player.movement.getVehicle();
                var isInVeh = veh != null;

                if (!_lastVehicleStates.ContainsKey(id))
                {
                    _lastVehicleStates.Add(id, veh);
                }

                var wasDriving = _lastVehicleStates[id];

                if (!isInVeh || wasDriving ||
                    !GetValueSafe(Region.GetGroup(player)))
                {
                    continue;
                }
                sbyte index = -1;
                for (var i1 = 0; i1 < veh.passengers.Length; i1++)
                {
                    Passenger p = veh.passengers[i1];
                    index++;
                    if (p.player.playerID.steamID == PlayerUtil.GetCSteamId(player))
                    {
                        break;
                    }
                }

                veh.kickPlayer((byte)index);
            }
        }
Esempio n. 13
0
    public override void UpdateAction()
    {
        base.UpdateAction();
        if (EntityUtil.StateActionMacro(Owner))
        {
            return;
        }

        Owner.NavAgent.Move(Owner.transform.forward * Isometric.IsometricGridSize * Owner.Status.CurrentSpeed * curve.Evaluate(ElapsedTime) * Time.deltaTime
                            + Owner.transform.forward * Mathf.Clamp01(Vector3.Dot(PlayerUtil.GetVelocityInput(), Owner.transform.forward)) * Isometric.IsometricGridSize * Owner.Status.CurrentSpeed * Time.deltaTime);

        float currentAnimTime = AnimUtil.GetAnimNormalizedTime(Owner);

        if (AnimUtil.IsLastFrame(Owner))
        {
            Owner.CurrentAction = isAttackCommand ? (CharacterAction)PlayerAttack1Action.GetInstance()
                : (CharacterAction)PlayerIdleAction.GetInstance();
            return;
        }

        if (currentAnimTime >= 0.78f && isAttackCommand)
        {
            Owner.CurrentAction = (CharacterAction)PlayerAttack1Action.GetInstance();
            return;
        }

        if (currentAnimTime <= 0.77f)
        {
            if (PlayerUtil.GetAttackInput())
            {
                isAttackCommand = true;
            }
        }
    }
Esempio n. 14
0
    public void AddBuff()
    {
        Character[] enemys = Object.FindObjectsOfType <Character>();

        if (enemys == null)
        {
            return;
        }

        foreach (var e in enemys)
        {
            if (e == Owner)
            {
                continue;
            }

            if ((Owner.transform.position - e.transform.position).magnitude <= Isometric.IsometricTileSize.x * 3f)
            {
                if (e != null)
                {
                    Vector3 pos = e.transform.position;
                    e.CurrentAction?.FinishAction();
                    GameObject.Destroy(e.gameObject);
                    NodeUtil.CreateEntity("Slime", pos);
                }
                IsoParticle.CreateParticle("Sliced_Power1", e.transform.position
                                           + new Vector3(0f, Isometric.IsometricTileSize.y * 0.5f, 0f), 0f);
            }
        }

        PlayerUtil.ConsumeCardPowerUpStatus();
    }
Esempio n. 15
0
        private void LayingCardsDone()
        {
            // With only one card left, just end the game
            if (HandCardCount == 1)
            {
                DiscardCard();
                return;
            }

            // Check if there are any (more) single cards to lay down
            singleLayDownCards = PlayerUtil.UpdateSingleLaydownCards(HandCardSpot.Objects, laydownCards);
            PossibleSinglesChanged.Invoke(singleLayDownCards);

            if (singleLayDownCards.Count == HandCardCount)
            {
                KeepOneSingleCard();
            }

            if (singleLayDownCards.Count > 0)
            {
                currentCardIdx = 0;
                layStage       = LayStage.SINGLES;
            }
            else
            {
                DiscardCard();
            }
        }
Esempio n. 16
0
 public bool IsOwner(IRocketPlayer player)
 {
     if (player is ConsolePlayer)
     {
         return(true);
     }
     return(player.HasPermission("regions.overrideowner") || IsOwner(PlayerUtil.GetId(player)));
 }
Esempio n. 17
0
    public override void StartAction(Character owner)
    {
        base.StartAction(owner);
        AnimUtil.PlayAnim(owner, "effect0");

        damage = PlayerUtil.CalculatingCardPowerValue(DataTable._Parameter[0]);
        Owner.AddState(new CharacterState(CharacterStateType.E_Invincibility, Owner).Init());
    }
        public void Initialize()
        {
            var playerEntity = PlayerUtil.CreatePlayerEntity(_contexts,
                                                             Vector2.zero,
                                                             0);

            GameManager.Instance.Player = playerEntity;
        }
Esempio n. 19
0
 private void OnPlayerDisconnect(IRocketPlayer player)
 {
     _lastPositions.Remove(PlayerUtil.GetId(player));
     if (!_playersInRegions.ContainsKey(PlayerUtil.GetId(player)))
     {
         return;
     }
     OnPlayerLeftRegion(player, _playersInRegions[PlayerUtil.GetId(player)]);
 }
Esempio n. 20
0
 public static void SetPosition2(IRocketPlayer player, SerializablePosition pos)
 {
     if (SecondsPositions.ContainsKey(PlayerUtil.GetId(player)))
     {
         SecondsPositions[PlayerUtil.GetId(player)] = pos;
         return;
     }
     SecondsPositions.Add(PlayerUtil.GetId(player), pos);
 }
Esempio n. 21
0
    public void OnTriggerExit(Collider other)
    {
        if (!PlayerUtil.IsPlayer(other.gameObject))
        {
            return;
        }

        _teslaTrafoController.Switch(false);
        Debug.Log("Tesla Trafo switched off");
    }
Esempio n. 22
0
        public Group GetGroup(IRocketPlayer player)
        {
            if (IsOwner(player))
            {
                return(Group.OWNERS);
            }
            var id = PlayerUtil.GetId(player);

            return(GetAllMembers().Any(member => member == id) ? Group.MEMBERS : Group.NONMEMBERS);
        }
Esempio n. 23
0
        /// <summary>
        /// Start Matchmaking
        /// </summary>
        /// <param name="playerId">The id of the player</param>
        /// <param name="playerProps">Custom player properties relevant to the matchmaking function</param>
        /// <param name="groupProps">Custom group properties relevant to the matchmaking function</param>
        public void RequestMatch(string playerId, MatchmakingPlayerProperties playerProps, MatchmakingGroupProperties groupProps)
        {
            player = PlayerUtil.GeneratePlayer();
            //request = CreateMatchmakingRequest(playerId, playerProps, groupProps);

            matchmakingController = new MatchmakingController(Endpoint);

            matchmakingController.StartRequestMatch(player, GetAssignment, OnError);
            State = MatchmakingState.Requesting;
            Debug.Log(State);
        }
Esempio n. 24
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        PlayerUtil util = target as PlayerUtil;

        if (GUILayout.Button("Set Player Script for Player Prefab"))
        {
            util.SetPlayerScript();
        }
    }
Esempio n. 25
0
        void OnPlayerDied(PlayerDiedEvent evt)
        {
            var state = evt.PlayerState;

            state.Stocks    = (sbyte)Mathf.Max(0, state.Stocks - 1);
            evt.PlayerState = state;
            if (state.Stocks > 0)
            {
                PlayerUtil.RespawnPlayer(evt);
            }
        }
Esempio n. 26
0
        public PickDropAction(PlayerControls player, bool skipHoldingCheck = false)
        {
            this.player           = player;
            this.skipHoldingCheck = skipHoldingCheck;

            currentlyHolding = PlayerUtil.GetCarrying(player);

            Keyboard.Get().SendDown(Keyboard.Input.PICK_DROP);

            Logger.Log("PickDropAction instantiated");
        }
        void OnPlayerDied(PlayerDiedEvent evt)
        {
            var state = evt.PlayerState;

            state.Stocks--;
            evt.PlayerState = state;
            if (state.Stocks > 0)
            {
                PlayerUtil.RespawnPlayer(evt);
            }
        }
        private void OnPlayerEnteredRegion(IRocketPlayer player, Region region)
        {
            var id = PlayerUtil.GetId(player);

            _playersInRegions.Add(id, region);

            foreach (RegionFlag f in region.ParsedFlags)
            {
                f.OnRegionEnter((UnturnedPlayer)player);
            }
        }
Esempio n. 29
0
        private void OnPlayerEnteredRegion(IRocketPlayer player, Region region)
        {
            var id = PlayerUtil.GetId(player);

            _playersInRegions.Add(id, region);

            for (var i = 0; i < region.ParsedFlags.Count; i++)
            {
                region.ParsedFlags[i].OnRegionEnter((UnturnedPlayer)player);
            }
        }
Esempio n. 30
0
        internal void OnPlayerLeftRegion(IRocketPlayer player, Region region)
        {
            var id = PlayerUtil.GetId(player);

            _playersInRegions.Remove(id);

            for (var i = 0; i < region.ParsedFlags.Count; i++)
            {
                region.ParsedFlags[i].OnRegionLeave((UnturnedPlayer)player);
            }
        }
Esempio n. 31
0
    void Start()
    {
        experience = 0;
        health = 100;
        sword = GameObject.Find("sword01").GetComponent<MeshRenderer>();
        sword.enabled = false;
        hp.text = getHealth().ToString();

        points.text = combo_points.ToString();

        playerStats = new PlayerUtil();

        //c_quest = new Quest(1, "Skeletons!", "Skeleton", 2, 80);
        UpdateQuests();
    }