Beispiel #1
0
        public Building(Vector2Int position, TilableDef def)
        {
            this.position = position;
            this.def      = def;
            this.recipe   = new Recipe(this.def.recipeDef, this, position);
            this.work     = 0;

            if (this.def.type == TilableType.BuildingConnected)
            {
                this.mainGraphic = GraphicInstance.GetNew(
                    this.def.graphics,
                    new Color(112 / 255f, 78 / 255f, 46 / 255f, .5f),               // update alpha when constructed
                    Res.textures[this.def.graphics.textureName + "_0"],
                    1
                    );
                this._connectedUtility = new ConnectedTilable(this);
            }
            this.addGraphics = new Dictionary <string, GraphicInstance>();

            Tilable tilable = Loki.map.grids[Layer.Plant].GetTilableAt(this.position);

            if (tilable != null && tilable.def.cuttable)
            {
                tilable.AddOrder(Defs.orders["cut_plants"]);
            }
        }
Beispiel #2
0
 // Update the meshes to correct UVs depending on the property lookingAt (direction from human.movement)
 public void UpdateLookingAt(Direction dir)
 {
     this.bodyGraphic = GraphicInstance.GetNew(
         this.human.def.graphics,
         Defs.colorPallets["human_body"].colors[this.skinData.bodyColorID],
         Res.textures["Body_" + (this.skinData.bodyID).ToString()],
         0,
         MeshPool.GetHumanPlaneMesh(this.size, dir)
         );
     this.headGraphic = GraphicInstance.GetNew(
         this.human.def.graphics,
         Defs.colorPallets["human_body"].colors[this.skinData.bodyColorID],
         Res.textures["Head_" + (this.skinData.headID).ToString()],
         1,
         MeshPool.GetHumanPlaneMesh(this.size, dir)
         );
     this.eyesGraphic = GraphicInstance.GetNew(
         this.human.def.graphics,
         Color.white,
         Res.textures["Eye_" + (this.skinData.eyeID).ToString()],
         2,
         MeshPool.GetHumanPlaneMesh(this.size, dir)
         );
     this.hairGraphic = GraphicInstance.GetNew(
         this.human.def.graphics,
         Defs.colorPallets["human_hair"].colors[this.skinData.hairColorID],
         Res.textures["Hair_" + (this.skinData.hairID).ToString()],
         3,
         MeshPool.GetHumanPlaneMesh(this.size, dir)
         );
 }
Beispiel #3
0
        public Stackable(Vector2Int position, TilableDef def, int count)
        {
            this.position    = position;
            this.def         = def;
            this.inventory   = new InventoryTilable(this, count);
            this.position    = position;
            this.def         = def;
            this.mainGraphic = GraphicInstance.GetNew(this.def.graphics);

            Loki.stackableLabelController.AddLabel(this);
        }
Beispiel #4
0
 public Stackable(Vector2Int position, StockArea area)
 {
     this.position    = position;
     this.def         = Defs.empty;
     this.area        = area;
     this.inventory   = null;
     this.mainGraphic = GraphicInstance.GetNew(
         this.def.graphics,
         this.area.color,
         Res.TextureUnicolor(this.area.color),
         1
         );
 }
Beispiel #5
0
 public Mountain(Vector2Int position, TilableDef def)
 {
     this.position          = position;
     this.def               = def;
     this._connectedUtility = new ConnectedTilable(this);
     this.mainGraphic       = GraphicInstance.GetNew(
         this.def.graphics,
         default(Color),
         Res.textures[this.def.graphics.textureName + "_0"],
         1
         );
     this.addGraphics = new Dictionary <string, GraphicInstance>();
 }
Beispiel #6
0
 public void WorkDirt()
 {
     this.dirt = true;
     this.addGraphics["dirt"] = GraphicInstance.GetNew(
         this.def.graphics,
         Color.white,
         Res.textures["dirt_ready"],
         2
         );
     if (this.bucket != null)
     {
         this.bucket.rebuildMatrices = true;
     }
 }
Beispiel #7
0
 public virtual void UpdateOrderGraphics()
 {
     if (!this.addGraphics.ContainsKey(this.currentOrder.name))
     {
         this.addGraphics.Add(this.currentOrder.name,
                              GraphicInstance.GetNew(
                                  this.currentOrder.graphics,
                                  Color.white,
                                  Res.textures[this.currentOrder.graphics.textureName],
                                  42
                                  )
                              );
     }
 }
Beispiel #8
0
 public void Construct()
 {
     this.mainGraphic = GraphicInstance.GetNew(
         this.def.graphics,
         new Color(112 / 255f, 78 / 255f, 46 / 255f, 1f),
         this.mainGraphic.texture,
         1
         );
     this.UpdateGraphics();
     if (this.bucket != null)
     {
         this.bucket.rebuildMatrices = true;
     }
 }
Beispiel #9
0
        public BaseCharacter(Vector2Int position, LivingDef def)
        {
            this.stats    = new CharacterStats();
            this.def      = def;
            this.movement = new CharacterMovement(position, this);
            this.brain    = new CharacterBrain(this, this.GetBrainNode());
            this.name     = this.SetName();

            if (this.def.graphics != null && this.def.graphics.textureName != string.Empty)               // @TODO: do this but better.
            {
                this.graphics = GraphicInstance.GetNew(this.def.graphics);
            }

            Loki.tick.toAdd.Enqueue(this.Update);
        }
Beispiel #10
0
        public override void UpdateGraphics()
        {
            if (this.def.type == TilableType.Grass)               // If we are a grass
            {
                this._leafColor  = Defs.colorPallets["cols_leafsGreen"].GetRandom();
                this.mainGraphic = GraphicInstance.GetNew(def.graphics, this._leafColor);
            }
            else if (this.def.type == TilableType.Tree)                 // If we are groot

            {
                this._leafColor  = Defs.colorPallets["cols_leafsGreen"].GetRandom();
                this._woodColor  = Defs.colorPallets["cols_wood"].colors[0];
                this.mainGraphic = GraphicInstance.GetNew(
                    def.graphics,
                    this._woodColor,
                    Res.textures[this.def.graphics.textureName + "_base"],
                    1
                    );

                if (this.addGraphics.ContainsKey("leafs"))
                {
                    this.addGraphics["leafs"] = GraphicInstance.GetNew(
                        def.graphics,
                        this._leafColor,
                        Res.textures[this.def.graphics.textureName + "_leafs"],
                        2
                        );
                }
                else
                {
                    this.addGraphics.Add("leafs",
                                         GraphicInstance.GetNew(
                                             def.graphics,
                                             this._leafColor,
                                             Res.textures[this.def.graphics.textureName + "_leafs"],
                                             2
                                             )
                                         );
                }
            }
            else                 // Standard graphics no coloring or override.
            {
                this.mainGraphic = GraphicInstance.GetNew(def.graphics);
            }
        }
Beispiel #11
0
 public Field(Vector2Int position, TilableDef def, GrowArea area)
 {
     this.addGraphics = new Dictionary <string, GraphicInstance>();
     this.area        = area;
     this.dirt        = false;
     this.position    = position;
     this.def         = def;
     this.mainGraphic = GraphicInstance.GetNew(
         this.def.graphics,
         this.area.color,
         Res.TextureUnicolor(this.area.color),
         1
         );
     this.addGraphics.Add("dirt",
                          GraphicInstance.GetNew(
                              this.def.graphics,
                              Color.white,
                              Res.TextureUnicolor(Color.clear),
                              2
                              )
                          );
 }
Beispiel #12
0
 public Stackable(Vector2Int position, TilableDef def, int count)
 {
     this.position    = position;
     this.def         = def;
     this.inventory   = new Inventory(this, count);
     this.mainGraphic = GraphicInstance.GetNew(this.def.graphics);
     this.area        = null;
     this.SetNeigbours();
     Loki.stackableLabelController.AddLabel(this);
     if (count > 0)
     {
         WorldUtils.AddStackable(def, this);
     }
     this.inventory.OnClear += delegate {
         WorldUtils.ClearStackable(this.inventory.def, this);
     };
     this.inventory.OnAdd += delegate {
         WorldUtils.AddStackable(this.inventory.def, this);
     };
     this.inventory.OnChangeCount += delegate(int change) {
         WorldUtils.UpdateStackableCount(this.inventory.def, change);
     };
 }
Beispiel #13
0
        /// Update this.tilable graphics according to the tilable connections.
        public void UpdateGraphics()
        {
            int connsInt = 0;

            this.SetLinks();
            int i = 0;

            foreach (int direction in DirectionUtils.cardinals)
            {
                if (this.connections[direction])
                {
                    connsInt += DirectionUtils.connections[i];
                }
                i++;
            }

            // Check if we need a roof or basicly checks corners here.
            i = 0;
            this.allCorners = true;
            bool hasCorner = false;

            foreach (int direction in DirectionUtils.corners)
            {
                if (
                    (i != 0 || this.connections[direction] && (this.connections[(int)Direction.W] && this.connections[(int)Direction.S])) &&
                    (i != 1 || this.connections[direction] && (this.connections[(int)Direction.W] && this.connections[(int)Direction.N])) &&
                    (i != 2 || this.connections[direction] && (this.connections[(int)Direction.E] && this.connections[(int)Direction.N])) &&
                    (i != 3 || this.connections[direction] && (this.connections[(int)Direction.E] && this.connections[(int)Direction.S]))
                    )
                {
                    this.corners[i] = true;
                    hasCorner       = true;
                }
                else
                {
                    this.corners[i] = false;
                    this.allCorners = false;
                }

                i++;
            }

            if (connsInt != this.connectionsInt)
            {
                this.connectionsInt = connsInt;


                if (this.allCorners)
                {
                    this.tilable.mainGraphic = GraphicInstance.GetNew(
                        this.tilable.def.graphics,
                        default(Color),
                        Res.textures[this.tilable.def.graphics.textureName + "_cover"],
                        1
                        );

                    Loki.map.GetTilableAt(this.tilable.position, Layer.Ground).hidden = true;
                }
                else
                {
                    this.tilable.mainGraphic = GraphicInstance.GetNew(
                        this.tilable.def.graphics,
                        default(Color),
                        Res.textures[this.tilable.def.graphics.textureName + "_" + this.connectionsInt.ToString()],
                        1
                        );

                    if (hasCorner)
                    {
                        this.tilable.addGraphics.Add("cover",
                                                     GraphicInstance.GetNew(
                                                         this.tilable.def.graphics,
                                                         default(Color),
                                                         Res.textures[this.tilable.def.graphics.textureName + "_cover"],
                                                         2,
                                                         MeshPool.GetCornersPlane(this.corners)
                                                         )
                                                     );
                    }
                    Loki.map.GetTilableAt(this.tilable.position, Layer.Ground).hidden = false;
                }
            }
        }
Beispiel #14
0
 public Ground(Vector2Int position, TilableDef def)
 {
     this.position    = position;
     this.def         = def;
     this.mainGraphic = GraphicInstance.GetNew(def.graphics);
 }