Exemplo n.º 1
0
        /// <summary>
        /// Creates a new copy of an actor from a particular template.
        /// </summary>
        /// <param name="templateName">The name of the template.</param>
        /// <param name="intialPosition">The initial starting position on the game world.</param>
        /// <returns>Returns an Actor.</returns>
        public Actor GetNewActor(string templateName, Point intialPosition)
        {
            ActorTemplate template = _actorTemplates[templateName];
            Actor         returnMe = new Actor(_owner, template.Name, template.Texture, template.Hitpoints, template.Properties.ToDictionary(p => p, q => 0), template.Jobs.ToList());

            returnMe.Start(intialPosition);
            return(returnMe);
        }
Exemplo n.º 2
0
        public void ActorSerializingTest()
        {
            const string name = "Actor Serialization Test";

            ActorTemplate actor        = new ActorTemplate(new Actor(name, Color.White, Color.Black, '@', Point.None));
            string        serialized   = JsonConvert.SerializeObject(actor);
            var           t            = SadConsole.Serializer.Serialize(new Actor("tst", Color.AliceBlue, Color.AliceBlue, '2', Point.None));
            Actor         deserialized = JsonConvert.DeserializeObject <Actor>(serialized);

            Assert.Equal(name, deserialized.Name);
        }
Exemplo n.º 3
0
    public ActorData(string name, ActorTemplate template)
    {
        this.name   = name;
        this.prefab = template.prefab;

        this.damageSFX = template.damageSFX;
        this.deathSFX  = template.deathSFX;

        this.raceAnimationSet = template.raceAnimationSet;

        InitializeStats(template);
        InitializeEquipment();
        InitializeInventory();
    }
Exemplo n.º 4
0
 public CreateNPActorCommand(ActorTemplate template)
 {
     _template = template;
 }
Exemplo n.º 5
0
 public CreateNPActorCommand(ActorTemplate template, Tile position)
 {
     _template = template;
     _position = position;
 }
Exemplo n.º 6
0
    void InitializeStats(ActorTemplate template)
    {
        //stats
        _stats = new Stat[] {
            //misc
            new Stat(StatType.SightRange, StatCategory.Misc,
                     () => { return(template.sightRange); },
                     () => { return("Base: " + template.sightRange); }),
            new Stat(StatType.SightThreshold, StatCategory.Misc,
                     () => { return(template.sightThreshold); },
                     () => { return("Base: " + template.sightThreshold); }),
            new Stat(StatType.WalkRange, StatCategory.Misc,
                     () => { return(GetVital(VitalType.Stamina).current); },
                     () => { return("Stamina: " + GetVital(VitalType.Stamina).current); }),
            new Stat(StatType.SprintRange, StatCategory.Misc,
                     () => { return(GetVital(VitalType.Stamina).current * 2); },
                     () => { return("Stamina x2: " + GetVital(VitalType.Stamina).current * 2); }),
        };

        //attributes
        _attributes = new Attribute[]
        {
            new Attribute(AttributeType.Strength, template.strength,
                          () => {
                return("<i><color=grey>Physical strength, it governs your damage values and carry weight.</color></i>\n\n" +
                       "Assigned: +" + GetAttribute(AttributeType.Strength).assigned + " / 25\n\n" +
                       template.race.ToString() + ": +" + template.strength);
            }),
            new Attribute(AttributeType.Vitality, template.vitality,
                          () => {
                return("<i><color=grey>Physical conditioning and fitness, it governs your health and stamina.</color></i>\n\n" +
                       "Assigned: +" + GetAttribute(AttributeType.Vitality).assigned + " / 25\n\n" +
                       template.race.ToString() + ": +" + template.vitality);
            }),
            new Attribute(AttributeType.Movement, template.movement,
                          () => {
                return("<i><color=grey>Reflexes, reactions and subconscious instincts, it governs parry, dodge and riposte chances.</color></i>\n\n" +
                       "Assigned: +" + GetAttribute(AttributeType.Movement).assigned + " / 25\n\n" +
                       template.race.ToString() + ": +" + template.movement);
            }),
            new Attribute(AttributeType.Willpower, template.willpower,
                          () => {
                return("<i><color=grey>Mental fortitude and conditioning, governs your resistance to corruption and spell damage.</color></i>\n\n" +
                       "Assigned: +" + GetAttribute(AttributeType.Willpower).assigned + " / 25\n\n" +
                       template.race.ToString() + ": +" + template.willpower);
            })
        };

        for (int i = 0; i < _attributes.Length; i++)
        {
            _attributes[i].OnAttributeChanged += (AttributeType at) =>
            {
                for (int a = 0; a < _vitals.Length; a++)
                {
                    OnVitalChanged((VitalType)a, 0);
                }

                OnAttributeChanged(at);
            }
        }
        ;

        //vitals
        _vitals = new Vital[] {
            new Vital(VitalType.Health,
                      () => {
                return(GetAttribute(AttributeType.Vitality).value);
            },
                      () => {
                return
                ("<i><color=grey>Health represents your physical wellness, if it reaches zero, you are permanently dead.</color></i>\n\n" +
                 "Vitality: +" + GetAttribute(AttributeType.Vitality).value);
            }),
            new Vital(VitalType.Corruption,
                      () => {
                return(GetAttribute(AttributeType.Willpower).value);
            },
                      () => {
                return
                ("<i><color=grey>Corruption represents the detrimental effects of being exposed to magic, both hostile and your own.\n" +
                 "Upon reaching zero, your mind is gone forever.</color></i>\n\n" +
                 "Willpower: +" + (GetAttribute(AttributeType.Willpower).value * 2));
            }),
            new Vital(VitalType.Stamina,
                      () => {
                return(GetAttribute(AttributeType.Movement).value);
            },
                      () => {
                return
                ("<i><color=grey>Stamina represents your physical conditioning, it resets at the start of every turn.</color></i>\n\n" +
                 "Vitality: +" + GetAttribute(AttributeType.Movement).value);
            })
        };

        for (int i = 0; i < _vitals.Length; i++)
        {
            _vitals[i].OnVitalChanged += (VitalType vt, int change) => OnVitalChanged(vt, change);
        }
    }

    void InitializeEquipment()
    {
        _equipment = new Equipable[Enum.GetNames(typeof(EquipSlot)).Length];
    }

    void InitializeInventory()
    {
        _inventory = new Item[3];
    }