Exemplo n.º 1
0
 public Family(
     int decayRef,
     int decayCounterRef,
     bool doesDecayRef,
     int priorityRef,
     int happinessThresholdRef,
     int valueRef,
     int maxValueRef,
     ISpriteState fulfillingSprite,
     IEntityRelationshipHandler relationshipHandler = null,
     int averageForDayRef  = 0,
     int averageForWeekRef = 0)
     : base(
         decayRef,
         decayCounterRef,
         doesDecayRef,
         priorityRef,
         happinessThresholdRef,
         valueRef,
         maxValueRef,
         new[] { "modifyrelationshippointsaction" },
         fulfillingSprite,
         averageForDayRef,
         averageForWeekRef)
 {
     this.RelationshipHandler = relationshipHandler ?? GlobalConstants.GameManager?.RelationshipHandler;
     this.FulfillingSprite    = fulfillingSprite;
 }
Exemplo n.º 2
0
        public virtual void Show(
            string title        = null,
            string content      = null,
            ISpriteState sprite = null,
            IEnumerable <Tuple <string, string> > data = null,
            bool showBackground = true)
        {
            if (!string.IsNullOrEmpty(title))
            {
                this.m_Title.Visible = true;
                this.m_Title.Text    = title;
            }
            else
            {
                this.m_Title.Visible = false;
            }

            this.m_Text.Text    = content;
            this.m_Text.Visible = !content.IsNullOrEmpty();

            if (sprite is null == false)
            {
                this.m_IconSlot.Visible = true;
                this.SetIcon(sprite);
            }
Exemplo n.º 3
0
 public Morality(
     int decayRef,
     int decayCounterRef,
     bool doesDecayRef,
     int priorityRef,
     int happinessThresholdRef,
     int valueRef,
     int maxValueRef,
     ISpriteState fulfillingSprite,
     int averageForDayRef  = 0,
     int averageForWeekRef = 0)
     : base(
         decayRef,
         decayCounterRef,
         doesDecayRef,
         priorityRef,
         happinessThresholdRef,
         valueRef,
         maxValueRef,
         new string[0],
         fulfillingSprite,
         averageForDayRef,
         averageForWeekRef)
 {
 }
Exemplo n.º 4
0
 public Purpose(
     int decayRef,
     int decayCounterRef,
     bool doesDecayRef,
     int priorityRef,
     int happinessThresholdRef,
     int valueRef,
     int maxValueRef,
     ISpriteState fulfillingSprite,
     IEntityRelationshipHandler relationshipHandler = null,
     IQuestProvider questProvider = null,
     int averageForDayRef         = 0,
     int averageForWeekRef        = 0)
     : base(
         decayRef,
         decayCounterRef,
         doesDecayRef,
         priorityRef,
         happinessThresholdRef,
         valueRef,
         maxValueRef,
         new string[0],
         fulfillingSprite,
         averageForDayRef,
         averageForWeekRef)
 {
     this.RelationshipHandler = relationshipHandler ?? GlobalConstants.GameManager?.RelationshipHandler;
     this.QuestProvider       = questProvider ?? GlobalConstants.GameManager?.QuestProvider;
 }
Exemplo n.º 5
0
        public IObservable <Unit> Run()
        {
            IDrawableTile drawableTile = _drawableTileRegistry.GetDrawableTileAtCoordinates(_data._drawableTileCoords);

            _spriteState = _texturePainter.SaveState(drawableTile.Sprite);
            _texturePainter.PaintPixel(drawableTile.Sprite, _data._pixelPosition, _data._paintParams);

            return(Observable.ReturnUnit());
        }
Exemplo n.º 6
0
        public IItemInstance CreateFromTemplate(BaseItemType itemType, bool identified = false)
        {
            List <IBasicValue <float> > values = new List <IBasicValue <float> >
            {
                new ConcreteBasicFloatValue(
                    "weight", itemType.Weight),
                new ConcreteBasicFloatValue(
                    "bonus", itemType.BaseEfficiency),
                new ConcreteBasicFloatValue(
                    "size", itemType.Size),
                new ConcreteBasicFloatValue(
                    "hardness", itemType.Materials.Average(pair => pair.Item1.Hardness)),
                new ConcreteBasicFloatValue(
                    "density", itemType.Materials.Average(pair => pair.Item1.Density))
            };

            List <SpriteState> states = (from sprite in this.ObjectIcons.GetManagedSprites(
                                             itemType.SpriteSheet,
                                             itemType.UnidentifiedName)
                                         select new SpriteState(
                                             sprite.Name,
                                             itemType.SpriteSheet,
                                             sprite))
                                        .ToList();

            ISpriteState chosenState            = this.Roller.SelectFromCollection(states);
            IDictionary <string, Color> colours = itemType.Materials
                                                  .Select(tuple => tuple.Item1)
                                                  .Distinct()
                                                  .ToDictionary(
                itemMaterial => itemMaterial.Name,
                itemMaterial => itemMaterial.Colours.GetRandom());

            foreach (var component in itemType.Components)
            {
                if (colours.ContainsKey(component.IdentifiedName) == false)
                {
                    colours.Add(component.IdentifiedName, component.Materials.Keys.GetRandom().Colours.GetRandom());
                }
            }
            chosenState.OverrideColours(colours);

            ItemInstance itemInstance = new ItemInstance(
                this.GuidManager.AssignGUID(),
                itemType,
                this.DerivedValueHandler.GetItemStandardBlock(values),
                new Vector2Int(-1, -1),
                identified,
                new[] { chosenState },
                new RNG(),
                new List <IAbility>(),
                new List <IJoyAction>());

            return(itemInstance);
        }
Exemplo n.º 7
0
        public void SetCursorSprites(ISpriteState state)
        {
            if (this.Initialised == false)
            {
                this.Awake();
            }

            this.CursorObject.Visible = true;
            this.CursorObject.Clear();
            this.CursorObject.AddSpriteState(state);
        }
Exemplo n.º 8
0
        public virtual void RefreshPlayer()
        {
            this.Player = GlobalConstants.GameManager.Player;

            this.PlayerNameOne.Text         = this.Player.JoyName;
            this.CurrentJob                 = this.Player.CurrentJob;
            this.JobPoints                  = this.CurrentJob.Experience;
            this.SpeciesAndJobOne.ValueName = "Job";
            this.SpeciesAndJobOne.Values    = this.Player.Jobs.Select(job => job.Name).ToArray();
            this.SpeciesAndJobOne.Tooltip   = new List <string>
            {
                GlobalConstants.GameManager.EntityTemplateHandler.Get(this.Player.CreatureType).Description,
                this.Player.CurrentJob.Description
            };

            this.PlayerNameTwo.Text         = this.PlayerNameOne.Text;
            this.SpeciesAndJobTwo.ValueName = "Job";
            this.SpeciesAndJobTwo.Values    = this.SpeciesAndJobOne.Values;
            this.SpeciesAndJobTwo.Tooltip   = new List <string>
            {
                GlobalConstants.GameManager.EntityTemplateHandler.Get(this.Player.CreatureType).Description,
                this.Player.CurrentJob.Description
            };

            if (this.SpeciesAndJobOne.IsConnected("ValueChanged", this, nameof(this.OnJobChange)))
            {
                this.SpeciesAndJobOne.Disconnect("ValueChanged", this, nameof(this.OnJobChange));
            }

            this.SpeciesAndJobOne.Connect("ValueChanged", this, nameof(this.OnJobChange));

            if (this.SpeciesAndJobTwo.IsConnected("ValueChanged", this, nameof(this.OnJobChange)))
            {
                this.SpeciesAndJobTwo.Disconnect("ValueChanged", this, nameof(this.OnJobChange));
            }

            this.SpeciesAndJobTwo.Connect("ValueChanged", this, nameof(this.OnJobChange));

            ISpriteState spriteState = this.Player.States.First();

            this.PlayerIconOne.Clear();
            this.PlayerIconOne.AddSpriteState(spriteState);
            this.PlayerIconOne.OverrideAllColours(spriteState.SpriteData.GetCurrentPartColours());

            this.PlayerIconTwo.Clear();
            this.PlayerIconTwo.AddSpriteState(spriteState);
            this.PlayerIconTwo.OverrideAllColours(spriteState.SpriteData.GetCurrentPartColours());
            this.SetExperienceRemaining();
        }
Exemplo n.º 9
0
 public void Show(ISpriteState replacement)
 {
     if (this.Initialised == false)
     {
         this.Awake();
     }
     this.DragObject.Clear();
     this.DragObject.Visible = false;
     if (replacement is null)
     {
         return;
     }
     this.DragObject.Visible = true;
     this.DragObject.AddSpriteState(replacement);
 }
Exemplo n.º 10
0
        public virtual void RefreshPlayer()
        {
            this.Player = GlobalConstants.GameManager.Player;

            this.PlayerNameOne.Text       = this.Player.JoyName;
            this.SpeciesAndJobOne.Text    = this.Player.CreatureType + " " + this.Player.CurrentJob.Name;
            this.SpeciesAndJobOne.Tooltip = new List <string>
            {
                GlobalConstants.GameManager.EntityTemplateHandler.Get(this.Player.CreatureType).Description,
                this.Player.CurrentJob.Description
            };
            this.CultureNameOne.Text    = this.Player.Cultures.First().CultureName;
            this.CultureNameOne.Tooltip = new List <string>
            {
                this.Player.Cultures.First().Description
            };

            this.PlayerNameTwo.Text       = this.PlayerNameOne.Text;
            this.SpeciesAndJobTwo.Text    = this.SpeciesAndJobOne.Text;
            this.SpeciesAndJobTwo.Tooltip = new List <string>
            {
                GlobalConstants.GameManager.EntityTemplateHandler.Get(this.Player.CreatureType).Description,
                this.Player.CurrentJob.Description
            };
            this.CultureNameTwo.Text    = this.CultureNameOne.Text;
            this.CultureNameTwo.Tooltip = new List <string>
            {
                this.Player.Cultures.First().Description
            };

            ISpriteState spriteState = this.Player.States.First();

            this.PlayerIconOne.Clear();
            this.PlayerIconOne.AddSpriteState(spriteState);
            this.PlayerIconOne.OverrideAllColours(spriteState.SpriteData.GetCurrentPartColours());

            this.PlayerIconTwo.Clear();
            this.PlayerIconTwo.AddSpriteState(spriteState);
            this.PlayerIconTwo.OverrideAllColours(spriteState.SpriteData.GetCurrentPartColours());
        }
Exemplo n.º 11
0
        protected void InstantiateWorld()
        {
            IGameManager gameManager           = GlobalConstants.GameManager;
            List <IBasicValue <float> > values = new List <IBasicValue <float> >
            {
                new ConcreteBasicFloatValue("weight", 1),
                new ConcreteBasicFloatValue("bonus", 1),
                new ConcreteBasicFloatValue("size", 1),
                new ConcreteBasicFloatValue("hardness", 1),
                new ConcreteBasicFloatValue("density", 1)
            };

            this.m_ActiveWorld.Initialise();

            ISpriteState state = null;
            float        scale = (float)GlobalConstants.SPRITE_WORLD_SIZE / GlobalConstants.SPRITE_TEXTURE_SIZE;

            var floorTileMap = gameManager.FloorTileMap;

            floorTileMap.TileSet = this.m_ObjectIcons.GetStaticTileSet(this.m_ActiveWorld.Tiles[0, 0].TileSet, true);
            int surroundFloorIndex = floorTileMap.TileSet.FindTileByName("SurroundFloor");

            var wallTileMap = gameManager.WallTileMap;

            wallTileMap.TileSet = this.m_ObjectIcons.GetStaticTileSet(this.m_ActiveWorld.Tiles[0, 0].TileSet);
            int surroundWallIndex = wallTileMap.TileSet.FindTileByName("SurroundWall");

            for (int i = 0; i < this.m_ActiveWorld.Tiles.GetLength(0); i++)
            {
                for (int j = 0; j < this.m_ActiveWorld.Tiles.GetLength(1); j++)
                {
                    Vector2Int intPos = new Vector2Int(i, j);

                    //Make the fog of war
                    PositionableSprite fog = gameManager.FogPool.Get();
                    fog.Name = "Fog of War " + intPos;
                    fog.Show();
                    fog.Scale = new Vector2(scale, scale);
                    fog.Move(intPos);

                    //Make the floor
                    floorTileMap.SetCell(i, j, surroundFloorIndex);
                }
            }

            //Make the upstairs
            if (this.m_ActiveWorld.Guid != this.m_Overworld.Guid)
            {
                floorTileMap.SetCellv(
                    this.m_ActiveWorld.SpawnPoint.ToVec2(),
                    floorTileMap.TileSet.FindTileByName("upstairs"));
            }

            //Make each downstairs
            foreach (KeyValuePair <Vector2Int, IWorldInstance> pair in this.m_ActiveWorld.Areas)
            {
                floorTileMap.SetCellv(
                    pair.Key.ToVec2(),
                    floorTileMap.TileSet.FindTileByName("downstairs"));
            }

            //Create the walls
            foreach (Vector2Int position in this.m_ActiveWorld.Walls)
            {
                wallTileMap.SetCellv(
                    position.ToVec2(),
                    surroundWallIndex);
            }

            int index = 0;

            index = this.CreateItems(index, this.m_ActiveWorld.Items);

            GlobalConstants.GameManager.EntityHolder.ZIndex = index + 10;
            //Create the entities
            int innerIndex = 0;
            int itemIndex  = 0;

            foreach (IEntity entity in this.m_ActiveWorld.Entities)
            {
                JoyObjectNode gameObject = gameManager.EntityPool.Get();
                gameObject.Show();
                gameObject.AttachJoyObject(entity);
                gameObject.ZIndex = index;
                innerIndex       += gameObject.CurrentSpriteState.SpriteData.Parts.Max(part => part.m_SortingOrder) + 1;
                itemIndex         = this.CreateItems(itemIndex, entity.Contents, false);
                itemIndex         = this.CreateItems(itemIndex, entity.Equipment.Contents, false);
            }

            GlobalConstants.GameManager.FogHolder.ZIndex = index + innerIndex + 10;

            this.Done = true;
        }
Exemplo n.º 12
0
 public void AddSpriteState(ISpriteState state)
 {
     this.Element.AddSpriteState(state);
 }