示例#1
0
    private void Awake()
    {
        _senses             = this.GetComponent <EnemySenses>();
        _chars              = this.GetComponent <EntityCharacteristics>();
        _movementController = this.GetComponent <EnemyMovement>();
        _chars.SetMaxHealth(100);
        _chars.SetMaxStamina(100);

        _chars.ChangeHealth(100);
        _chars.ChangeStamina(100);

        UpdateHealthInUI();
    }
示例#2
0
    private bool _longHitReady; // tells whether LongHitStart has ended and animation should proceed

    private void Awake()
    {
        _chars               = this.gameObject.GetComponent <EntityCharacteristics>();
        _eventHandler        = this.gameObject.GetComponent <EntityEventHandler>();
        _movementController  = this.gameObject.GetComponent <PlayerMovement>();
        _animationController = this.gameObject.GetComponent <PlayerAnimation>();
        _combatController    = this.gameObject.GetComponent <EntityCombat>();
        _UI = this.gameObject.GetComponent <PlayerUI>();

        _isAllowedToMove = true;

        _longHitLastFrame = false;
        _longHitReady     = false;

        FindAllWeaponManagers();
        _activeWeaponIndex = 0;

        DisableActiveHitManager("Awake");
    }
示例#3
0
        public void GuideUser(string username)
        {
            this.Writer.Clear();
            // Retrieve name
            this.Writer.WriteLineInfo(string.Format(PROMPT_MESSAGE, "name"));
            var characterName = this.Reader.ReadLine();

            // Retrieve faction
            this.FactionsInGame = this.DbContext.Factions.Select(f => f.Name).ToList();
            this.Writer.WriteLineInfo("~Available factions:");
            foreach (var faction in this.FactionsInGame)
            {
                this.Writer.WriteLine(faction);
            }
            this.Writer.WriteLineInfo(string.Format(PROMPT_MESSAGE, "faction"));
            var characterFaction = this.Reader.ReadLine().ToLower();

            if (!this.FactionsInGame.Any(f => f.ToLower() == characterFaction))
            {
                this.Writer.WriteLineError(string.Format(INVALID_INPUT, "faction"));
                return;
            }
            var getFactionId = this.DbContext.Factions.Where(f => f.Name.ToLower() == characterFaction).FirstOrDefault().Id;

            // Retrieve race
            this.RacesInGame = this.DbContext.Factions
                               .Where(f => f.Id == getFactionId)
                               .FirstOrDefault()
                               .Races.ToList()
                               .Select(r => r.Name)
                               .ToList();
            this.Writer.WriteLineInfo("~Available races:");
            foreach (var race in this.RacesInGame)
            {
                this.Writer.WriteLine(race);
            }
            this.Writer.WriteLineInfo(string.Format(PROMPT_MESSAGE, "race"));
            var characterRace = this.Reader.ReadLine().ToLower();

            if (!this.RacesInGame.Any(r => r.ToLower() == characterRace))
            {
                this.Writer.WriteLineError(string.Format(INVALID_INPUT, "race"));
                return;
            }
            var getRaceId = this.DbContext.Races.Where(r => r.Name.ToLower() == characterRace).FirstOrDefault().Id;

            // Retrieve class
            this.ClassesInGame = this.DbContext.Races
                                 .Where(r => r.Id == getRaceId)
                                 .FirstOrDefault()
                                 .Classes
                                 .ToList()
                                 .Select(p => p.Name)
                                 .ToList();
            this.Writer.WriteLineInfo("~Available classes:");
            foreach (var gameClass in this.ClassesInGame)
            {
                this.Writer.WriteLine(gameClass);
            }
            this.Writer.WriteLineInfo(string.Format(PROMPT_MESSAGE, "class"));
            var characterClass = this.Reader.ReadLine().ToLower();

            if (!this.ClassesInGame.Any(c => c.ToLower() == characterClass))
            {
                this.Writer.WriteLineError(string.Format(INVALID_INPUT, "class"));
                return;
            }

            // Retrieve profession
            this.ProfessionsInGame = this.DbContext.Professions.Select(p => p.Name).ToList();
            this.Writer.WriteLineInfo("~Available professions:");
            foreach (var profession in this.ProfessionsInGame)
            {
                this.Writer.WriteLine(profession);
            }
            this.Writer.WriteLineInfo(string.Format(PROMPT_MESSAGE, "profession"));
            var characterProfession = this.Reader.ReadLine().ToLower();

            if (!this.ProfessionsInGame.Any(p => p.ToLower() == characterProfession))
            {
                this.Writer.WriteLineError(string.Format(INVALID_INPUT, "profession"));
                return;
            }

            var getPlayerId     = this.DbContext.Players.Where(p => p.Username == username).FirstOrDefault().Id;
            var getClassId      = this.DbContext.Classes.Where(c => c.Name.ToLower() == characterClass).FirstOrDefault().Id;
            var getProfessionId = this.DbContext.Professions.Where(p => p.Name.ToLower() == characterProfession).FirstOrDefault().Id;

            EntityCharacteristics.Add(characterName);
            EntityCharacteristics.Add(getPlayerId.ToString());
            EntityCharacteristics.Add(getRaceId.ToString());
            EntityCharacteristics.Add(getClassId.ToString());
            EntityCharacteristics.Add(getFactionId.ToString());
            EntityCharacteristics.Add(getProfessionId.ToString());

            try
            {
                this.EntityCreator.CreateEntity(this.EntityCharacteristics);
                this.Writer.WriteLineSuccess(string.Format(SUCCESSEFUL_CREATION, EntityCharacteristics[0]));
            }
            catch (Exception ex)
            {
                Writer.WriteLineError(UNSUCCESSEFUL_CREATION);
            }
        }