Пример #1
0
        public void RemoveEnemy(CharacterFaction faction)
        {
            if (faction == Config.Faction)
            {
                return;
            }

            switch (faction)
            {
            case CharacterFaction.Player:
                _enemyMask &= ~Layers.PlayerMask;
                break;

            case CharacterFaction.Square:
                _enemyMask &= ~Layers.SquareMask;
                break;

            case CharacterFaction.Triangle:
                _enemyMask &= ~Layers.TriangleMask;
                break;

            case CharacterFaction.Circle:
                _enemyMask &= ~Layers.CircleMask;
                break;
            }
        }
Пример #2
0
        protected override void Update()
        {
            CharacterYoke.Movement     = new Vector2(InputManager.GetAxis(InputAction.MoveHorizontal), InputManager.GetAxis(InputAction.MoveVertical));
            CharacterYoke.Jump         = InputManager.GetButton(InputAction.Jump);
            CharacterYoke.Drop         = InputManager.GetButton(InputAction.Drop);
            CharacterYoke.MeleeAttack  = InputManager.GetButton(InputAction.MeleeAttack);
            CharacterYoke.RangedAttack = InputManager.GetButton(InputAction.RangedAttack);
            CharacterYoke.DashAttack   = InputManager.GetButton(InputAction.DashAttack);
            CharacterYoke.Interact     = InputManager.GetButton(InputAction.Interact);

            if (InputManager.GetButtonDown(InputAction.ShowInventory))
            {
                _inventoryUI.Toggle();
            }

            if (!IsTransforming && InputManager.GetButtonDown(InputAction.Transform))
            {
                CharacterFaction next = NextFaction(CurrentShape);

                if (next != CurrentShape)
                {
                    _transforming = StartCoroutine(TransformInto(_playerConfig.TransformDuration, next));
                }
            }

            base.Update();
        }
Пример #3
0
        private bool FactionAllowsFaction(Character character, CharacterFaction faction)
        {
            var characters = m_characters.Where(m => m.Account.AccountId == character.Account.AccountId);

            if (characters.All(m => m.Faction == faction))
            {
                return(true);
            }

            return(false);
        }
Пример #4
0
        public GameObject GetPrefab(CharacterFaction type)
        {
            foreach (SpawnPair pair in _toSpawn)
            {
                if (pair.Type == type)
                {
                    return(pair.Prefab);
                }
            }

            return(null);
        }
Пример #5
0
        public bool CharactersAreHostile(BaseCharacterController characterA, BaseCharacterController characterB)
        {
            CharacterFaction factionA = characterA.Config.Faction;
            CharacterFaction factionB = characterB.Config.Faction;

            if (factionA == CharacterFaction.Player || factionB == CharacterFaction.Player)
            {
                AgentController agent = factionA == CharacterFaction.Player ? characterB as AgentController : characterA as AgentController;
                return(_hostileToPlayer[agent]);
            }

            //All factions are hostile to one another
            return(factionA != factionB);
        }
Пример #6
0
        private void ValidateCharacter(string name, CharacterFaction characterFaction, CharacterRace characterRace, CharacterClass characterClass)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new Exception("Character must have a name");
            }

            #region Faction Validation

            if (characterFaction == CharacterFaction.Horde)
            {
                if (characterRace != CharacterRace.Orc &&
                    characterRace != CharacterRace.Tauren &&
                    characterRace != CharacterRace.BloodElf)
                {
                    throw new Exception("Only Orcs, Taurens, and Blood Elfs can fight for the Horde");
                }
            }
            else
            {
                if (characterRace != CharacterRace.Human &&
                    characterRace != CharacterRace.Gnome &&
                    characterRace != CharacterRace.Worgen)
                {
                    throw new Exception("Only Humans, Gnomes, and Worgen can fight for the Alliance");
                }
            }

            #endregion

            #region Race Validation

            if (characterClass == CharacterClass.Druid)
            {
                if (characterRace != CharacterRace.Tauren &&
                    characterRace != CharacterRace.Worgen)
                {
                    throw new Exception("This race cannot be a Druid");
                }
            }

            if (characterRace == CharacterRace.BloodElf && characterClass == CharacterClass.Warrior)
            {
                throw new Exception("Blood Elfs cannot be Warriors");
            }

            #endregion
        }
Пример #7
0
        private void ValidateCharacter(string name, CharacterFaction characterFaction, CharacterRace characterRace, CharacterClass characterClass)
        {
            if(String.IsNullOrEmpty(name))
            {
                throw new Exception("Character must have a name");
            }

            #region Faction Validation
            
            if(characterFaction == CharacterFaction.Horde)
            {
                if(characterRace != CharacterRace.Orc &&
                   characterRace != CharacterRace.Tauren &&
                   characterRace != CharacterRace.BloodElf)
                {
                    throw new Exception("Only Orcs, Taurens, and Blood Elfs can fight for the Horde");
                }
            }
            else
            {
                if (characterRace != CharacterRace.Human &&
                   characterRace != CharacterRace.Gnome &&
                   characterRace != CharacterRace.Worgen)
                {
                    throw new Exception("Only Humans, Gnomes, and Worgen can fight for the Alliance");
                }
            }

            #endregion

            #region Race Validation
            
            if(characterClass == CharacterClass.Druid)
            {
                if(characterRace != CharacterRace.Tauren &&
                   characterRace != CharacterRace.Worgen)
                {
                    throw new Exception("This race cannot be a Druid");
                }
            }

            if(characterRace == CharacterRace.BloodElf && characterClass == CharacterClass.Warrior)
            {
                throw new Exception("Blood Elfs cannot be Warriors");
            }

            #endregion
        }
Пример #8
0
        public bool FactionUnlocked(CharacterFaction faction)
        {
            switch (faction)
            {
            case CharacterFaction.Square:
                return(SquareUnlocked);

            case CharacterFaction.Triangle:
                return(TriangleUnlocked);

            case CharacterFaction.Circle:
                return(CircleUnlocked);
            }

            return(false);
        }
Пример #9
0
        private CharacterFaction NextFaction(CharacterFaction from)
        {
            CharacterFaction next = from + 1;
            int numFactions       = System.Enum.GetValues(typeof(CharacterFaction)).Length;

            while (!FactionUnlocked(next))
            {
                if ((int)next >= numFactions)
                {
                    next = 0;
                }
                else
                {
                    next++;
                }
            }

            return(next);
        }
Пример #10
0
    Sprite GetCombatModifierIcon(HeroManager.Hero hero)
    {
        Sprite combatModifierIcon;
        CharacterFaction enemyFaction = GameManager.currentEvent.enemyType;
        CharacterFaction heroFaction = hero.type.faction;

        if (heroFaction.strongAgainst == enemyFaction)
        {
            combatModifierIcon = combatModifierIcons[2];
        }
        else if (heroFaction.weakAgainst == enemyFaction)
        {
            combatModifierIcon = combatModifierIcons[0];
        }
        else
        {
            combatModifierIcon = combatModifierIcons[1];
        }
        return combatModifierIcon;
    }
Пример #11
0
        public Character(string name, CharacterFaction characterFaction, CharacterRace characterRace, CharacterClass characterClass)
        {
            ValidateCharacter(name, characterFaction, characterRace, characterClass);

            this.Id      = Guid.NewGuid();
            this.Name    = name;
            this.Faction = characterFaction;
            this.Race    = characterRace;
            this.Class   = characterClass;
            this.Active  = true;

            if (characterClass == CharacterClass.DeathKnight)
            {
                this.Level = 55;
            }
            else
            {
                this.Level = 1;
            }
        }
Пример #12
0
        public  Character(string name, CharacterFaction characterFaction, CharacterRace characterRace, CharacterClass characterClass)
        {
            ValidateCharacter(name, characterFaction, characterRace, characterClass);

            this.Id = Guid.NewGuid();
            this.Name = name;
            this.Faction = characterFaction;
            this.Race = characterRace;
            this.Class = characterClass;
            this.Active = true;
            
            if(characterClass == CharacterClass.DeathKnight)
            {
                this.Level = 55;
            }
            else
            {
                this.Level = 1;
            }
        }
Пример #13
0
        private bool UnlockShape(CharacterFaction shape)
        {
            switch (shape)
            {
            case CharacterFaction.Square:
                if (SquareUnlocked)
                {
                    return(false);
                }

                SquareUnlocked = true;
                break;

            case CharacterFaction.Triangle:
                if (TriangleUnlocked)
                {
                    return(false);
                }

                TriangleUnlocked = true;
                break;

            case CharacterFaction.Circle:
                if (CircleUnlocked)
                {
                    return(false);
                }

                CircleUnlocked = true;
                break;

            default:
                throw new System.NotImplementedException();
            }

            return(true);
        }
Пример #14
0
        private void OnCharacterSpawned(BaseCharacterController character)
        {
            AgentController agent = character as AgentController;

            if (agent != null)
            {
                CharacterFaction faction = agent.Config.Faction;
                if (!_agentsByFaction[faction].Contains(agent))
                {
                    _agentsByFaction[faction].Add(agent);
                }

                if (!_hostileToPlayer.ContainsKey(agent))
                {
                    _hostileToPlayer[agent] = false;
                }
            }
            else if (Player == null)
            {
                //Must be a player
                Player = character as PlayerController;
                Debug.Assert(Player != null);
            }
        }
Пример #15
0
    public void EventFight(bool sendcitizen = false)
    {
        if (!sendcitizen)
        {
            HeroManager.Hero hero         = HeroManager.recruitedHeroes[GameManager.heroSelectScreenIndex];
            CharacterFaction enemyFaction = GameManager.currentEvent.enemyType;

            int enemyStrength = random.Next(0, 7) + GameManager.enemyStrengthModifer;
            int heroStrength  = random.Next(0, 7) + hero.strength;
            if (hero.heroName.name != "Jonvrab")
            {
                heroStrength += GameManager.jonvrabStrengthModifier;
            }
            GameManager.enemyStrengthModifer = 0;

            if (hero.type.faction.strongAgainst == enemyFaction)
            {
                heroStrength++;
            }
            else if (hero.type.faction.weakAgainst == enemyFaction)
            {
                heroStrength--;
            }

            hero.mentality++;

            heroEventManager.OnParticipatingEvent(hero);

            int battleResult = Mathf.Clamp(heroStrength - enemyStrength, -2, 2);

            if (firstEvent)
            {
                battleResult = 2;
                firstEvent   = false;
            }

            switch (battleResult)
            {
            case -2:
                LoseEvent();
                if (buildingName == null)
                {
                    buildingName = "empty field";
                }
                eventResultText =
                    GameManager.currentEvent.eventLoseText.Replace("X", hero.heroName.name) + " " +
                    hero.heroName.name + " is injured and lost 1 mentality.";
                hero.injured       = true;
                hero.eventsInjured = 3 + GameManager.extraInjuryDuration;
                hero.mentality--;
                break;

            case -1:
                eventResultText = GameManager.currentEvent.eventWinText.Replace("X", hero.heroName.name) +
                                  " However, HERO was injured and lost 1 strength.".Replace("HERO", hero.heroName.name);
                hero.strength--;
                hero.injured       = true;
                hero.eventsInjured = 3 + GameManager.extraInjuryDuration;
                break;

            case 0:
                eventResultText = GameManager.currentEvent.eventWinText.Replace("X", hero.heroName.name) +
                                  " However, HERO was injured.".Replace("HERO", hero.heroName.name);
                hero.injured       = true;
                hero.eventsInjured = 3 + GameManager.extraInjuryDuration;
                break;

            case 1:
                eventResultText = GameManager.currentEvent.eventWinText.Replace("X", hero.heroName.name);
                break;

            case 2:
                if (hero.strength < 3)
                {
                    eventResultText = GameManager.currentEvent.eventWinText.Replace("X", hero.heroName.name) +
                                      " HERO gained 1 strength and mentality!".Replace("HERO", hero.heroName.name);
                    hero.strength++;
                }
                else
                {
                    eventResultText = GameManager.currentEvent.eventWinText.Replace("X", hero.heroName.name) +
                                      " HERO gained 1 mentality!".Replace("HERO", hero.heroName.name);
                }
                hero.mentality++;
                break;
            }
        }
        else
        {
            LoseEvent();

            if (buildingName == null)
            {
                buildingName = "empty field";
            }

            string citizentext = GameManager.currentEvent.eventLoseText.Replace("X", "the random citizen");

            eventResultText = char.ToUpper(citizentext[0]) + citizentext.Substring(1);
        }

        foreach (HeroManager.Hero hiredHero in HeroManager.recruitedHeroes)
        {
            hiredHero.mentality--;
            hiredHero.eventsInjured--;
            if (hiredHero.eventsInjured == 0)
            {
                hiredHero.injured = false;
            }
            if (hiredHero.eventsInjured < 2 && GameManager.hospitalsBuilt > 0)
            {
                hiredHero.injured = false;
            }

            if (hiredHero.mentality <= hiredHero.heroName.upsetMentalityThreshold)
            {
                heroEventManager.UpsetEvent(hiredHero);
            }
        }

        GameManager.uiController.FinalizeEvent(eventResultText, sendcitizen);
    }
Пример #16
0
        /// <summary>This overload is used from optimizer and is optimized for performance, do not modify</summary>
        public Character(Character baseCharacter, object[] items, int count)
        {
            IsLoading = true;
            _name = baseCharacter._name;
            _realm = baseCharacter._realm;
            _region = baseCharacter._region;
            _race = baseCharacter._race;
            _currentModel = baseCharacter._currentModel;
            _calculationOptions = baseCharacter._calculationOptions;
            _primaryProfession = baseCharacter._primaryProfession;
            _secondaryProfession = baseCharacter._secondaryProfession;
            _class = baseCharacter._class;
            AssignAllTalentsFromCharacter(baseCharacter, false);
            CalculationToOptimize = baseCharacter.CalculationToOptimize;
            OptimizationRequirements = baseCharacter.OptimizationRequirements;
            _bossOptions = baseCharacter._bossOptions;
            _faction = baseCharacter._faction;

            _item = new ItemInstance[SlotCount];
            Array.Copy(items, _item, count);

            IsLoading = false;
            ActiveBuffs = new List<Buff>(baseCharacter.ActiveBuffs);
            RecalculateSetBonuses();
        }
Пример #17
0
 private void SetFaction()
 {
     if (_race == CharacterRace.Draenei || _race == CharacterRace.Dwarf || _race == CharacterRace.Gnome || _race == CharacterRace.Human || _race == CharacterRace.NightElf || _race == CharacterRace.Worgen)
         _faction = CharacterFaction.Alliance;
     else
     {
         _faction = CharacterFaction.Horde;
     }
 }
Пример #18
0
    /// <summary>
    /// 创建角色(base,无装备,有武器)
    /// </summary>
    /// <param name="id">ID</param>
    /// <param name="name">名字</param>
    /// <param name="faction">势力(玩家,友军,敌人)</param>
    /// <param name="type">(英雄,普通)</param>
    /// <param name="constitution">体质</param>
    /// <param name="strength">力量</param>
    /// <param name="agility">灵巧</param>
    /// <param name="dexterous">洞察</param>
    /// <param name="concentration">专注</param>
    /// <param name="weapon">武器</param>
    /// <param name="allExperience">全部经验</param>
    /// <param name="skills">技能</param>
    /// <param name="currentExperience">当前经验</param>
    public CharacterProperty(int id, string name, CharacterFaction faction, CharacterType type, string sprite, CharacterKind kind,
                             int constitution, int strength, int agility, int dexterous, int concentration, Item weapon, float allExperience, float resistance = 0,
                             int[] skills = null, float currentExperience = 0, int headID = 0, int clothID = 0, int pantsID = 0, int beltID = 0, BuffProp buffProp = null)
    {
        #region 装备处理
        if (this.EquipmentProp == null)
        {
            this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID);
        }
        if ((headID != 0) || (clothID != 0) || (pantsID != 0) || (beltID != 0))
        {
            this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID);
            resistance        += EquipmentProp.Resistance;
            constitution      += EquipmentProp.Constitution;
            strength          += EquipmentProp.Strength;
            dexterous         += EquipmentProp.Dexterous;
            agility           += EquipmentProp.Agility;
            concentration     += EquipmentProp.Concentration;
        }
        #endregion

        #region 加成处理
        if (buffProp != null)
        {
            this.BuffItemProp = buffProp;
            constitution     += buffProp.Constitution;
            strength         += buffProp.Strength;
            dexterous        += buffProp.Dexterous;
            agility          += buffProp.Agility;
            concentration    += buffProp.Concentration;

            //else ...
        }
        #endregion

        this.ID            = id;
        this.Name          = name;
        this.Faction       = faction;
        this.Type          = type;
        this.Sprite        = sprite;
        this.AllExperience = allExperience;
        this.Resistance    = resistance;
        this.Constitution  = constitution;
        this.Strength      = strength;
        this.Agility       = agility;
        this.Dexterous     = dexterous;
        this.Concentration = concentration;
        this.HealthLevel   = 100;
        this.charKind      = kind;

        this.Level             = CountLevel(allExperience, out currentExperience);
        this.CurrentExperience = currentExperience;
        this.Power             = constitution + strength + agility + dexterous + concentration;

        this.WeaponWith = weapon;

        //通常角色
        if (type == CharacterType.Common)
        {
            this.MaxHealth       = 100 + 3 * constitution;
            this.MaxStamina      = 100 + 1 * constitution;
            this.HealthRecovery  = 0.2f;
            this.StaminaRecovery = 5f;
            this.MoveSpeed       = 1.3f * (1 + 0.01f * agility);
            this.AimingSpeed     = 2 * (1 + 0.02f * concentration);
            this.Critical        = 0.1f + 0.01f * dexterous;
            this.MeleeRaise      = 1.5f;
            this.ShootRaise      = 1.5f;
            this.ThrowRaise      = 1.5f;
            this.MaxAngle        = 10 * (1 - 0.01f * concentration);
            this.KickDamage      = 20 + strength;
            this.PunchDamage     = 20 + strength;

            if (weapon is MeleeWeapon)
            {
                MeleeWeapon melee = (MeleeWeapon)weapon;
                this.MeleeDamage    = melee.MeleeDamage + strength;
                this.ThrowDamage    = melee.ThrowDamage + strength;
                this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility);
            }
            else if (weapon is ShootWeapon)
            {
                ShootWeapon shoot = (ShootWeapon)weapon;
                this.MinAngle       = (110 - shoot.Accuracy / 15);
                this.Capacity       = shoot.Accuracy * MaxAngle / 10;
                this.PullingTime    = shoot.LaShuanTime * (1 - 0.02f * agility);
                this.ReloadTime     = shoot.ReloadTime * (1 - 0.01f * agility);
                this.MeleeDamage    = shoot.MeleeDamage + strength;
                this.ShootDamage    = shoot.ShootDamage;
                this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility);
                this.DeclineRange   = shoot.DamageRange;
            }
        }
        //英雄角色
        else if (type == CharacterType.Hero)
        {
            this.SkillA = skills[0];
            this.SkillB = skills[1];
            this.SkillC = skills[2];
            this.SkillD = skills[3];
            this.SkillE = skills[4];
            this.SkillF = skills[5];
            this.SkillG = skills[6];
            this.SkillH = skills[7];
            this.SkillI = skills[8];
            this.SkillJ = skills[9];
            this.SkillK = skills[10];
            this.SkillL = skills[11];
            this.SkillM = skills[12];
            this.SkillN = skills[13];
            this.SkillO = skills[14];
            this.SkillP = skills[15];
            this.SkillQ = skills[16];
            this.SkillR = skills[17];
            this.SkillS = skills[18];
            this.SkillT = skills[19];

            this.MaxHealth       = 100 + 3 * constitution + 20 * SkillA;
            this.MaxStamina      = 100 + 1 * constitution + 20 * SkillF;
            this.HealthRecovery  = 0.2f + 2 * SkillM + 100 * SkillN;
            this.StaminaRecovery = 5 + 2 * SkillL;
            this.MoveSpeed       = 1.3f * (1 + 0.01f * agility + 0.15f * SkillR);
            this.AimingSpeed     = 2f * (1 + 0.02f * concentration + 0.1f * SkillQ);
            this.Critical        = 0.1f + 0.01f * dexterous + 0.04f * SkillD;
            this.MeleeRaise      = 1.5f + 0.5f * SkillI;
            this.ShootRaise      = 1.5f + 0.5f * SkillJ;
            this.ThrowRaise      = 1.5f + 1 * SkillT;
            this.MaxAngle        = 10 * (1 - 0.01f * concentration - 0.04f * SkillE);
            this.Resistance      = this.Resistance + 0.04f * SkillG + 0.1f * SkillN;
            this.KickDamage      = 20 + 20 * SkillH;

            if (weapon is MeleeWeapon)
            {
                MeleeWeapon melee = (MeleeWeapon)weapon;
                this.MeleeDamage    = (melee.MeleeDamage + strength) * (1 + 0.04f * SkillB);
                this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility - 0.04f * SkillC);
                this.ThrowDamage    = melee.ThrowDamage * (1 + SkillT) + strength;
            }
            else if (weapon is ShootWeapon)
            {
                ShootWeapon shoot = (ShootWeapon)weapon;
                this.MinAngle       = (110 - shoot.Accuracy / 15) * (1 - 0.1f * SkillP);
                this.Capacity       = shoot.Accuracy * MaxAngle / 10f;
                this.ReloadTime     = shoot.ReloadTime * (1 - 0.01f * agility - 0.1f * SkillO);
                this.PullingTime    = shoot.LaShuanTime * (1 - 0.02f * agility - 0.08f * SkillK);
                this.MeleeDamage    = (shoot.MeleeDamage * (1 + SkillT) + strength) * (1 + 0.04f * SkillB);
                this.ShootDamage    = shoot.ShootDamage;
                this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility - 0.04f * SkillC);
            }
        }
    }
Пример #19
0
        private IEnumerator TransformInto(float duration, CharacterFaction transformTo)
        {
            SpriteRenderer current;

            switch (CurrentShape)
            {
            case CharacterFaction.Square:
                current = _square;
                break;

            case CharacterFaction.Triangle:
                current = _triangle;
                break;

            case CharacterFaction.Circle:
                current = _circle;
                break;

            case CharacterFaction.Player:
            default:
                current = null;
                Debug.Assert(false, "Don't do that");
                break;
            }

            SpriteRenderer next;

            switch (transformTo)
            {
            case CharacterFaction.Square:
                next = _square;
                break;

            case CharacterFaction.Triangle:
                next = _triangle;
                break;

            case CharacterFaction.Circle:
                next = _circle;
                break;

            case CharacterFaction.Player:
            default:
                next = null;
                Debug.Assert(false, "Don't do that");
                break;
            }

            if (current == null || next == null)
            {
                yield break;
            }

            float t         = 0.0f;
            float startTime = Time.time;

            while (t <= 1.0f)
            {
                t             = (Time.time - startTime) / duration;
                next.color    = Color.Lerp(Color.clear, Color.white, t);
                current.color = Color.Lerp(Color.white, Color.clear, t);

                yield return(null);
            }

            CurrentShape     = transformTo;
            _characterSprite = next;
            _transforming    = null;
        }