Пример #1
0
        public SwapUpButton(int x, int y) : base(1, x, y, 0.5f)
        {
            _settings            = DependencyInjection.Resolve <ISettings>();
            _characterDefinition = DependencyInjection.Resolve <CharacterDefinition>();

            Click = Swap;
        }
Пример #2
0
        public static void CreateEnemiesTemporal(Map map)
        {
            CharacterDefinition definition = new CharacterDefinition("", ActorType.Guard);

            Enemy soldier = new Enemy(new Vector2(61.5f, 39.5f), definition, 1);

            soldier.IsActive      = true;
            soldier.IsCollectable = false;
            soldier.IsMovable     = false;
            soldier.Name          = "ENEMY";
            soldier.Direction     = new Vector2(1, 0);
            map.ObjectDatabase.Add(soldier);

            Enemy soldier2 = new Enemy(new Vector2(61.5f, 29.5f), definition, 1);

            soldier2.IsActive      = true;
            soldier2.IsCollectable = false;
            soldier2.IsMovable     = false;
            soldier2.Name          = "ENEMY2";
            soldier2.Direction     = new Vector2(-1, 0);
            map.ObjectDatabase.Add(soldier2);



            Enemies[0] = soldier;
            Enemies[1] = soldier2;
        }
Пример #3
0
        private string _handleToonMessage(string[] sections)
        {
            switch (sections[1])
            {
            case "SETQUESTCOMPLETED":
                int                 questId  = Convert.ToInt32(sections[3]);
                string              toonName = sections[2];
                QuestDefinition     quest    = _questRepository.GetByRomId(questId);
                CharacterDefinition toon     = _characterRepository.FindByName(toonName);
                if (toon == null)
                {
                    toon      = new CharacterDefinition();
                    toon.Name = toonName;
                    LogManager.GetLogger(typeof(RomMessageProcessor)).Warn("Could not load character: " + toonName + " so created a new one.");
                }
                if (!toon.CompletedQuests.Contains(quest))
                {
                    toon.CompletedQuests.Add(quest);
                    _characterRepository.Update(toon);
                }
                break;
            }

            return(null);
        }
Пример #4
0
    protected virtual IEnumerator BuffAction(CombatCharacter caster, CombatCharacter[] targets)
    {
        CharacterDefinition def = caster.Definition;

        caster.CharacterUI.AnimateBuff();
        yield return(new WaitForSeconds(1.0f));
    }
Пример #5
0
        public IconsPalette()
        {
            _items = new List <IconPaletteItem>();
            _characterDefinition = DependencyInjection.Resolve <CharacterDefinition>();
            _mouseInput          = DependencyInjection.Resolve <IMouseInput>();
            _settings            = DependencyInjection.Resolve <IReadOnlySettings>();

            for (var l = 0; l < 4; l++)
            {
                for (var i = 0; i < 25; i++)
                {
                    var source      = new Rectangle((i % 5) * 64, (i / 5) * 64, 64, 64);
                    var destination = new Rectangle(i * 23, 467 + l * 32, 23, 32);

                    if (l == 3)
                    {
                        source.X     = (i % 4) * 80;
                        source.Y     = (i / 4) * 64;
                        source.Width = 80;

                        if (i < 15)
                        {
                            destination.X     = i * 30;
                            destination.Width = 30;
                        }
                    }

                    _items.Add(new IconPaletteItem(i + 64 * l, l, source, destination));
                }
            }
        }
Пример #6
0
        public string GetCharacter(CharacterDefinition toon)
        {
            try
            {
                Response.ContentType = "application/json";

                var charDets = GetCharacterDetails(toon);

                if (charDets == null)
                {
                    Response.StatusCode = 404;
                    return(JsonConvert.SerializeObject(new { ErrorMessage = "Character not found" }));
                }

                return(JsonConvert.SerializeObject(new { ErrorMessage = "", Toon = new BNetCharacter()
                                                         {
                                                             Class = charDets.Class,
                                                             Faction = charDets.Faction,
                                                             Level = charDets.Level,
                                                             Name = charDets.Name,
                                                             Race = charDets.Race,
                                                             Realm = charDets.Realm,
                                                             ThumbnailPath = charDets.ThumbnailPath
                                                         } }));
            }
            catch (Exception ex)
            {
                LogError(ex);
                Response.StatusCode = 500;
                return(JsonConvert.SerializeObject(new { ErrorMessage = "System error occured" }));
            }
        }
Пример #7
0
            public int Compare(string[] left, string[] right)
            {
                int leftId  = CharacterDefinition.LookupCharacterClass(left[0]);
                int rightId = CharacterDefinition.LookupCharacterClass(right[0]);

                return(leftId - rightId);
            }
Пример #8
0
        public void TestCanAddItem()
        {
            ISessionFactory fac     = RomViewContainer.Container.GetInstance <ISessionFactory>();
            ISession        session = fac.OpenSession();
            ITransaction    tx      = session.BeginTransaction();

            CallSessionContext.Bind(session);

            try
            {
                IRepository <CharacterDefinition> rep = RomViewContainer.Container.GetInstance <IRepository <CharacterDefinition> >();

                CharacterDefinition def = new CharacterDefinition
                {
                    Name = "Remedial", Race = "Human"
                };

                IRepository <QuestDefinition> qRep = RomViewContainer.Container.GetInstance <IRepository <QuestDefinition> >();
                QuestDefinition dummy = new QuestDefinition()
                {
                    RomId = -1, Name = "TestQuest"
                };
                session.Save(dummy);

                def.CompletedQuests.Add(dummy);
                session.Save(def);
            }
            finally
            {
                tx.Rollback();
                session.Close();
            }
        }
Пример #9
0
        public void TestCanUpdateRemedial()
        {
            ISessionFactory fac     = RomViewContainer.Container.GetInstance <ISessionFactory>();
            ISession        session = fac.OpenSession();
            ITransaction    tx      = session.BeginTransaction();

            CallSessionContext.Bind(session);

            try
            {
                ICharacterRepository rep = RomViewContainer.Container.GetInstance <ICharacterRepository>();

                CharacterDefinition def = rep.FindByName("Remedial");
                def.PrimaryClass   = CharacterClass.Scout;
                def.PrimaryLevel   = 56;
                def.SecondaryLevel = 55;
                def.SecondayClass  = CharacterClass.Mage;
                def.Race           = "Human";
                def.Sex            = Sex.Female;

                rep.Update(def);
                tx.Commit();
            }
            finally
            {
                session.Close();
            }
        }
Пример #10
0
 public KeyFrameSelectorItem(TextButtonOption option, int keyFrameIndex)
 {
     _settings            = DependencyInjection.Resolve <IReadOnlySettings>();
     _characterDefinition = DependencyInjection.Resolve <CharacterDefinition>();
     Option = option;
     SetKeyFrame(keyFrameIndex);
 }
Пример #11
0
    public void SayDialogFor(int playerID, CharacterDefinition character, DialogContext context, string conditional = "")
    {
        CharacterDialogDefinition dialogDefinition = character.dialogDefinition;
        List <CharacterDialog>    allDialog        = dialogDefinition.dialogDictionary[context];
        List <CharacterDialog>    relevantDialog   = new List <CharacterDialog>();

        for (int i = 0; i < allDialog.Count; i++)
        {
            if (allDialog[i].useDialogConditional && allDialog[i].dialogConditional.ToLower() == conditional.ToLower())
            {
                relevantDialog.Add(allDialog[i]);
            }
            else if (!allDialog[i].useDialogConditional)
            {
                relevantDialog.Add(allDialog[i]);
            }
        }

        if (relevantDialog.Count > 0)
        {
            CharacterDialog nextDialog = relevantDialog[Random.Range(0, relevantDialog.Count - 1)];
            if (nextDialog.priority >= currentPriority)
            {
                if (currentChain != null)
                {
                    CoroutineServer.StopCoroutine(currentChain);
                }
                currentPriority = nextDialog.priority;
                currentChain    = CoroutineServer.StartCoroutine(StartDialogChain(playerID, nextDialog));
            }
        }
    }
Пример #12
0
        public Enemy(Vector2 _position, CharacterDefinition newCharDef, int newID)
        {
            entityStateMachine = new StateMachine();

            // Idle doesn't need an end
            entityStateMachine.AddState(IDLE, IdleBegin, IdleTick, null);

            // Shooting doesn't need Begin or End.
            entityStateMachine.AddState(WALKING, null, WalkingTick, null);

            entityStateMachine.AddState(SEARCHING_PLAYER, null, SearchingPlayerTick, null);
            entityStateMachine.AddState(ATTACKING, null, AttackingTick, null);
            entityStateMachine.AddState(KILLED, null, KilledTick, null);

            charDef  = newCharDef;
            ID       = newID;
            Position = _position;
            script   = new Script.Script(this);

            //executes the init script if exists
            InitScript();
            AnimName = "";

            //starts with the idle animation
            SetAnim("idle");
            time = 0;
        }
Пример #13
0
    public void OnDefinitionChange(CharacterDefinition definition)
    {
        characterAnimator.SetTrigger("Hide");
        this.definition = definition;
        if (definition == null)
        {
            mainImage.sprite = null;
            typeImage.sprite = null;
            nameLabel.text   = "";
            starImage.gameObject.SetActive(false);
        }
        else
        {
            mainImage.sprite = definition.Representation;
            typeImage.sprite = definition.Type.Representation;
            nameLabel.text   = definition.name;
            starImage.gameObject.SetActive(false);
            starImage.color = definition.Type.Color;
        }
        this.gameObject.SetActive(definition != null);

        if (definition != null)
        {
            characterAnimator.SetBool("IsAlive", character.IsAlive);
        }
    }
        public void PutInvokeDefinition(string characterClassName, int invoke, int group, int length)
        {
            byte characterClass = CharacterDefinition.LookupCharacterClass(characterClassName);

            invokeMap[characterClass] = invoke == 1;
            groupMap[characterClass]  = group == 1;
            // TODO: length def ignored
        }
Пример #15
0
        /// <summary>
        /// Load character definitions
        /// </summary>
        public void LoadDefinitions()
        {
            //TODO: Read character definitions from file

            guardDefinition = new CharacterDefinition("", ActorType.Guard);
            bossDefinition  = new CharacterDefinition("", ActorType.Gretel_Grosse);
            dogDefinition   = new CharacterDefinition("", ActorType.Dog);
        }
Пример #16
0
#pragma warning disable IDE0060 // Remove unused parameter
        public void PutInvokeDefinition(string characterClassName, int invoke, int group, int length)
#pragma warning restore IDE0060 // Remove unused parameter
        {
            byte characterClass = CharacterDefinition.LookupCharacterClass(characterClassName);

            invokeMap[characterClass] = invoke == 1;
            groupMap[characterClass]  = group == 1;
            // TODO: length def ignored
        }
Пример #17
0
 public void LoadDefinition(int definitionIndex)
 {
     if (definitionIndex >= 0 && definitionIndex < characterSet.Count)
     {
         CharacterDefinition definition = characterSet.GetDefinition(definitionIndex);
         characterName.text = definition.name;
         activeDefinition   = definition;
     }
 }
Пример #18
0
 private void ChangeCharacter(int index)
 {
     currentCharacterIndex          = index;
     currentCharacter               = characterDefinitionSet.GetDefinition(currentCharacterIndex);
     characterSpriteRenderer.sprite = currentCharacter.portrait;
     currentTank = currentCharacter.defaultTankDefinition;
     tankRepresentation.LoadTankDefinition(currentTank);
     characterNameText.text = currentCharacter.name;
 }
Пример #19
0
 public Settings()
 {
     FileName             = "char";
     _characterDefinition = DependencyInjection.Resolve <CharacterDefinition>();
     SelectedAnimation    = _characterDefinition.Animations[SelectedAnimationIndex];
     SelectedKeyFrame     = SelectedAnimation.KeyFrames[SelectedKeyFrameIndex];
     SelectedFrame        = _characterDefinition.Frames[SelectedFrameIndex];
     SelectedPart         = SelectedFrame.Parts[SelectedPartIndex];
 }
Пример #20
0
 public Character CreateCharacter(CharacterDefinition type)
 {
     // TODO
     return(new Character
     {
         Type = type,
         Strength = GlobalUtils.Rand(10) + (type.Strength / 2),
         Speed = GlobalUtils.Rand(10) + type.Speed,
         Energy = (GlobalUtils.Rand(20) + type.Energy) * 3
     });
 }
Пример #21
0
    public void Setup(CharacterDefinition definition)
    {
#if UNITY_EDITOR
        if (characterUI == null)
        {
            characterUI = GetComponent <CombatCharacterUI>();
        }
#endif
        this.definition    = definition;
        this.currentHealth = definition == null? 0 : definition.Health;
        characterUI.OnDefinitionChange(definition);
    }
        /// <summary>
        /// Put mapping from unicode code point to character class.
        /// </summary>
        /// <param name="codePoint">Code point.</param>
        /// <param name="characterClassName">Character class name.</param>
        public void PutCharacterCategory(int codePoint, string characterClassName)
        {
            characterClassName = characterClassName.Split(' ')[0]; // use first
                                                                   // category
                                                                   // class

            // Override Nakaguro
            if (codePoint == 0x30FB)
            {
                characterClassName = "SYMBOL";
            }
            characterCategoryMap[codePoint] = CharacterDefinition.LookupCharacterClass(characterClassName);
        }
Пример #23
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUI.BeginChangeCheck();
            prevDefinition = (CharacterDefinition)EditorGUILayout.ObjectField(prevDefinition, typeof(CharacterDefinition), false);

            if (EditorGUI.EndChangeCheck())
            {
                character.Setup(prevDefinition);
                EditorUtility.SetDirty(target);
            }
        }
Пример #24
0
        private static Tuple <int, int> CreateRange(IDefinitionWithPrecomputedData definition, int level)
        {
            CharacterDefinition characterDefinition = definition as CharacterDefinition;

            if (characterDefinition == null || characterDefinition.actionRange == null)
            {
                return(null);
            }
            int valueWithLevel  = characterDefinition.actionRange.min.GetValueWithLevel(level);
            int valueWithLevel2 = characterDefinition.actionRange.max.GetValueWithLevel(level);

            return(new Tuple <int, int>(valueWithLevel, valueWithLevel2));
        }
        /// <summary>
        /// Put mapping from unicode code point to character class.
        /// </summary>
        /// <param name="codePoint">Code point.</param>
        /// <param name="characterClassName">Character class name.</param>
        public void PutCharacterCategory(int codePoint, string characterClassName)
        {
            characterClassName = characterClassName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]; // use first
                                                                                                                         // category
                                                                                                                         // class

            // Override Nakaguro
            if (codePoint == 0x30FB)
            {
                characterClassName = "SYMBOL";
            }
            characterCategoryMap[codePoint] = CharacterDefinition.LookupCharacterClass(characterClassName);
        }
Пример #26
0
        private int RenderCharacter(char c, int x, int y)
        {
            if (mCharacterDefinitions.ContainsKey(c))
            {
                CharacterDefinition cd = mCharacterDefinitions[c];
                if (x + cd.Width >= 0 && x < 8)
                {
                    Array.ForEach(cd.Points, p => SetGrid(x + p.X, y + p.Y, true));
                }
                return(cd.Width);
            }

            return(4);
        }
Пример #27
0
    // Render the inspector view.
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        CharacterDefinition characterDefinition = target as CharacterDefinition;

        GUIStyle labelStyle = GUI.skin.label;

        labelStyle.fontStyle = FontStyle.Bold;

        string totalDamageLabelText = string.Format("Total Damage: {0}", characterDefinition.GetTotalDamage());

        EditorGUILayout.LabelField(totalDamageLabelText, labelStyle);
    }
Пример #28
0
        public override int Put(string[] entry)
        {
            // Get wordId of current entry
            int wordId = m_buffer.Position;

            // Put entry
            int result = base.Put(entry);

            // Put entry in targetMap
            int characterId = CharacterDefinition.LookupCharacterClass(entry[0]);

            AddMapping(characterId, wordId);
            return(result);
        }
Пример #29
0
        public Actor(Map _map, Vector2 _position, CharacterDefinition newCharacterDefinition, int newActorID)
        {
            entityStateMachine = new StateMachine();

            // Idle doesn't need an end
            entityStateMachine.AddState(IDLE, IdleBegin, IdleTick, null);

            // Shooting doesn't need Begin or End.
            entityStateMachine.AddState(PATROLLING, null, PatrollingTick, null);

            entityStateMachine.AddState(CHASING_PLAYER, null, ChasingPlayerTick, null);
            entityStateMachine.AddState(ATTACKING, null, AttackingTick, null);
            entityStateMachine.AddState(SUFFERING_PAIN, null, SufferingPainTick, null);
            entityStateMachine.AddState(DYING, null, DyingTick, null);
            entityStateMachine.AddState(KILLED, null, KilledTick, null);

            characterDefinition = newCharacterDefinition;
            ActorID             = newActorID;

            script = new Script(this);

            //executes the init script if exists
            InitScript();
            AnimationName = "";

            //starts with the idle animation
            SetAnim("idle");
            time = 0;


            //copy the actor's attributes from the character definition

            MaxSpeed                   = characterDefinition.MaxSpeed;
            MaxForce                   = characterDefinition.MaxForce;
            HasPain                    = characterDefinition.HasPain;
            Score                      = characterDefinition.Score;
            WeaponType                 = characterDefinition.WeaponType;
            BoundingRadius             = 0.7f;
            MustGetCloseEnoughToAttack = characterDefinition.MustGetCloseEnoughToAttack;

            //TODO read the difficulty from the game variables
            HitPoints        = characterDefinition.HitPoints[(int)Difficulty.None];
            CurrentHitPoints = 0;
            Map = _map;

            MoveTo(_position);

            Behavior = new SteeringBehavior(this, _map);
        }
Пример #30
0
    public virtual bool HasLineOfSightTarget(Character target)
    {
        CharacterDefinition target_definition = target.char_definition;
        RaycastHit2D        hit = Physics2D.Linecast(line_of_sight_origin.position, target_definition.center_mass.position, line_of_sight_blocking_mask);

        if (hit)
        {
            hit = Physics2D.Linecast(line_of_sight_origin.position, target_definition.head.position, line_of_sight_blocking_mask);
            if (hit)
            {
                hit = Physics2D.Linecast(line_of_sight_origin.position, target_definition.feet.position, line_of_sight_blocking_mask);
            }
        }
        return(!hit);
    }
Пример #31
0
        private static Dictionary<char, CharacterDefinition> GetCharacterDefinitions()
        {
            var defs = new Dictionary<char, CharacterDefinition>();

            StringReader sr = new StringReader(File.ReadAllText("text.txt"));
            while (sr.Peek() != -1) {
                if (Char.IsWhiteSpace((char)sr.Peek())) {
                    sr.Read();
                    continue;
                }

                CharacterDefinition cd = new CharacterDefinition(sr);
                defs.Add(cd.Key, cd);
            }

            return defs;
        }
Пример #32
0
 void SetVariablesToSelectedObject()
 {
     GameObject active = Selection.activeGameObject;
     if (active == null) {
         selectedCharacter = null;
         return;
     }
     Frame[] f = active.GetComponentsInParent<Frame>(true);
     if (f.Any()) {
         currentlySelectedFrameIndex = f[0].index;
     }
     CharacterAnimation[] a = active.GetComponentsInParent<CharacterAnimation>(true);
     if (a.Any()) {
         AnimationID[] idsArray = Enum.GetValues(typeof(AnimationID)).Cast<AnimationID>().ToArray();
         selectedAnimationIdIndex = new List<AnimationID>(idsArray).IndexOf(a[0].id);
     }
     CharacterDefinition[] c = active.GetComponentsInParent<CharacterDefinition>(true);
     if (c.Any()) {
         selectedCharacter = c[0];
     }
 }
Пример #33
0
 public void Initialize(CharacterDefinition.PicDef pd)
 {
     Texture2D tex = GameConst.Content.Load<Texture2D>(@"character/" + pd.texture);
     framesize.X = pd.width;
     framesize.Y = pd.height;
     Size = new Vector2(pd.size, pd.size);
     foreach (CharacterDefinition.AnimDef ad in pd.anims)
     {
         CharacterAnimation cani = new CharacterAnimation(ad.name);
         cani.FrameCount = ad.framecount;
         cani.EventFrame = ad.eventframe;
         cani.Loop = ad.loop;
         cani.Speed = ad.speed;
         foreach (CharacterDefinition.AnimFrameDef fd in ad.frames)
         {
             cani.AddFrame(fd.x, fd.y, fd.w, fd.h, fd.center);
             cani.Reset();
         }
         Animations[ad.name] = cani;
         animTextures[ad.name] = tex;
     }
     currentAnim = Animations["Idle"];
 }
Пример #34
0
 public void AddCharacterDefinition(CharacterDefinition.PicDef pd)
 {
     Texture2D tex = GameConst.Content.Load<Texture2D>(@"character/" + pd.texture);
     if (tex != null)
     {
         foreach (CharacterDefinition.AnimDef ad in pd.anims)
         {
             CharacterAnimation cani = new CharacterAnimation(ad.name);
             cani.FrameCount = ad.framecount;
             cani.EventFrame = ad.eventframe;
             cani.Loop = ad.loop;
             cani.Speed = ad.speed;
             foreach (CharacterDefinition.AnimFrameDef fd in ad.frames)
             {
                 cani.AddFrame(fd.x, fd.y, fd.w, fd.h, fd.center);
                 cani.Reset();
             }
             Animations[ad.name] = cani;
             animTextures[ad.name] = tex;
         }
     }
 }
Пример #35
0
 public CharacterPic(CharacterDefinition.PicDef pd, int inlayer)
     : base(null, inlayer)
 {
     Initialize(pd);
 }
Пример #36
0
 void RenderSelectCharacterBar()
 {
     List<CharacterDefinition> characters = CharacterManager.Instance().GetCharacters();
     if (GUILayout.Button("New character")) {
         CharacterManager.Instance().BuildEmptyCharacter();
     }
     EditorGUILayout.BeginHorizontal();
     if (GUILayout.Button("---")) {
         selectedCharacter = null;
         DisableAllCharactersExcept();
     }
     foreach (CharacterDefinition c in characters) {
         Color oldColor = GUI.color;
         if (c == selectedCharacter) {
             GUI.color = CURRENTLY_SELECTED_COLOR;
         }
         if (GUILayout.Button(c.CharacterName)) {
             DisableAllCharactersExcept(c);
             selectedCharacter = c;
         }
         GUI.color = oldColor;
     }
     EditorGUILayout.EndHorizontal();
 }
Пример #37
0
 void DisableAllCharactersExcept(CharacterDefinition except=null)
 {
     foreach(CharacterDefinition c in CharacterManager.Instance().GetCharacters()) {
         c.gameObject.SetActive(c == except);
     }
 }