コード例 #1
0
 public void UnlockForFree(PlayerCharacter playerCharacter)
 {
     Unlocked = true;
 }
コード例 #2
0
        //todo: rethink these, we should add skill or talent, so we can first check if we are immune/susceptible to it
        //in which case we can pre-multiply the damage or just not apply the skill and return "Immune"

        public bool IsFriendly(BaseCharacter target)
        {
            if (target == null)
            {
                return(true);
            }

            //pet can't be attacked if it's idle only
            var targetIsPet = target.CharacterMono.GetComponent <PetMono>();

            if (targetIsPet != null && targetIsPet.PetData.CurrentBehaviour == PetBehaviour.PetOnly)
            {
                return(true);
            }

            //pet can't attack player
            if (CharacterMono == null)
            {
                return(true);
            }

            var iAmPet = CharacterMono.GetComponent <PetMono>();

            if (iAmPet != null && target is PlayerCharacter)
            {
                return(true);
            }

            if (iAmPet)
            {
                return(GetObject.PlayerCharacter.IsFriendly(target));
            }

            if (targetIsPet)
            {
                return(IsFriendly(GetObject.PlayerCharacter));
            }

            var allReps     = Rm_RPGHandler.Instance.Repositories.Quests.AllReputations;
            var players     = new PlayerCharacter[2];
            var combatChars = new CombatCharacter[2];

            switch (CharacterType)
            {
            case CharacterType.Player:
                players[0] = (PlayerCharacter)this;
                break;

            case CharacterType.NPC:
            case CharacterType.Enemy:
                combatChars[0] = (CombatCharacter)this;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (target.CharacterType)
            {
            case CharacterType.Player:
                players[players[0] == null ? 0 : 1] = (PlayerCharacter)target;
                break;

            case CharacterType.NPC:
            case CharacterType.Enemy:
                combatChars[combatChars[0] == null ? 0 : 1] = (CombatCharacter)target;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (players.Count(p => p != null) == 2)
            {
                return(true);
            }
            else if (players.Count(p => p != null) == 1 && combatChars.Count(p => p != null) == 1)
            {
                var targetChar   = combatChars[0];
                var rep          = allReps.FirstOrDefault(r => r.ID == targetChar.ReputationId);
                var playerRepVal = GetObject.PlayerSave.QuestLog.AllReputations.FirstOrDefault(r => r.ReputationID == targetChar.ReputationId);
                if (rep != null && playerRepVal != null)
                {
                    return(!rep.AttackIfBelowReputation || playerRepVal.Value >= rep.BelowReputationValue);
                }
                else
                {
                    Debug.LogError("Could not find reputation for  " + targetChar.Name + "[ RepId: " + targetChar.ReputationId + "]");
                }
            }
            else
            {
                var myrep    = allReps.FirstOrDefault(r => r.ID == combatChars[0].ReputationId);
                var enemyrep = allReps.FirstOrDefault(r => r.ID == combatChars[1].ReputationId);


                if (myrep == enemyrep)
                {
                    return(true);
                }

                //EE
                if (myrep.EnemyFactions.First(e => e.ID == enemyrep.ID).IsTrue&&
                    enemyrep.EnemyFactions.First(e => e.ID == myrep.ID).IsTrue)
                {
                    return(false);
                }
                else if (myrep.EnemyFactions.First(e => e.ID == enemyrep.ID).IsTrue || enemyrep.EnemyFactions.First(e => e.ID == myrep.ID).IsTrue)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(true);
        }
コード例 #3
0
        public bool CanCast(PlayerCharacter player)
        {
            var canCast = true;


            if (RequireVitalBelowX)
            {
                canCast = player.GetVitalByID(RequiredVitalId).CurrentValue <=
                          player.GetVitalByID(RequiredVitalId).MaxValue *VitalConditionParameter;
            }
            if (canCast == false)
            {
                return(false);
            }

            if (ReqPrevSkillInCombo)
            {
                var stillExists =
                    Rm_RPGHandler.Instance.Repositories.Skills.AllSkills.FirstOrDefault(s => s.ID == PrevSkillForComboID);

                if (stillExists != null)
                {
                    canCast = stillExists.CurrentComboTime < MaxComboTime;
                }
            }
            if (canCast == false)
            {
                return(false);
            }

            if (RequireVitalAboveX)
            {
                canCast = player.GetVitalByID(RequiredVitalId).CurrentValue >=
                          player.GetVitalByID(RequiredVitalId).MaxValue *VitalConditionParameter;
            }
            if (canCast == false)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(RequiredEquippedWepTypeID))
            {
                var weapon = player.Equipment.GetSlot("Weapon").Item as Weapon;
                if (weapon != null)
                {
                    canCast = weapon.WeaponTypeID == RequiredEquippedWepTypeID;
                }
            }
            if (canCast == false)
            {
                return(false);
            }

            if (ResourceRequirement > 0 && UseResourceOnCast)
            {
                canCast = player.GetVitalByID(ResourceIDUsed).CurrentValue - ResourceRequirement >= 0;

                if (player.GetVitalByID(ResourceIDUsed).IsHealth)
                {
                    canCast = player.GetVitalByID(ResourceIDUsed).CurrentValue - ResourceRequirement >= 1;
                }
            }
            if (canCast == false)
            {
                return(false);
            }

            return(canCast);
        }