Added Factorys

This commit is contained in:
MasterGordon 2018-04-16 18:18:22 +02:00
parent 0c43dc4efd
commit 7d4ec26f34
12 changed files with 295 additions and 31 deletions

View File

@ -39,6 +39,106 @@ body {
padding: 4;
}
#selectFactory {
position: fixed;
border: 1px, solid, black;
border: solid;
border-color: yellow;
background-image: url(../images/infobg.png);
width: 1192;
height: 568;
padding: 4;
}
.factory {
float: left;
width: 289;
margin: 2;
height: 140;
font-family: 'Electrolize', sans-serif;
background-color: lightgray;
}
.factory h1 {
float: left;
font-size: 20;
line-height: 7;
width: 40%;
height: 100%;
margin-left: 10%;
}
.factory h2 {
font-size: 18;
}
#buyfactory {
width: 1192;
height: 128;
font-family: 'Electrolize', sans-serif;
color: floralwhite;
}
.factoryToBuy {
float: left;
height: 120;
width: 230;
background-color: lightgray;
margin: 2px;
}
.factoryToBuy p {
text-align: center;
color: black;
float: left;
font-size: 18px;
line-height: 29px;
width: 50%;
}
.factoryToBuy h1 {
text-align: center;
color: black;
float: left;
font-size: 20px;
line-height: 43px;
width: 100%;
}
.factoryToBuy h2 {
text-align: center;
color: black;
float: left;
font-size: 18px;
line-height: 43px;
width: 100%;
}
.factoryToBuy span {
text-align: center;
color: black;
float: left;
font-size: 18px;
line-height: 24px;
width: 65%;
}
.factoryToBuy span span {
font-size: 12px;
width: 100%
}
.factoryToBuy img {
float: left;
margin-left: 16;
}
#factoryScroll {
overflow-y: scroll;
width: 1192;
height: 440;
}
#playerinfo {
position: fixed;
width: 100%;

View File

@ -12,6 +12,7 @@
<script src="js/libs/copyCSS.js"></script>
<script src="js/libs/js.cookie.js"></script>
<script src="jquery-ui/jquery-ui.min.js"></script>
<script src="js/libs/seedrandom.min.js"></script>
<!-- Own scripts-->
<script src="js/userinterface.js"></script>
<script src="js/util.js"></script>
@ -52,6 +53,12 @@
<span id="money">
??? Dollar
</span>
<div id="selectFactory">
<div id="factoryScroll">
<div class="factory"><h1>Factory 0</h1><div class="minerals"><br><h2>Minerals:</h2><br> - iron<br> - coal<br> - copper<br> - soda</div></div>
</div>
<div id="buyfactory"></div>
</div>
<span style="position: fixed;color: white" id="speed"></span>
<div id="playerinfo"><span id="lastsave">Last Save 10Min ago</span><br><button id="forcesave">Force Save</button><button id="logout">Logout</button></div>
</body>

BIN
images/ui/factorys.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
images/ui/reroll.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

View File

@ -168,14 +168,58 @@ class Item {
}
}
//var bodenvorkommen = ["copper","stonecoal","browncoal",""]
var bodenvorkommen = ["bauxite", //0
"beryllium", //1
"lead", //2
"chrome", //3
"diamonds", //4
"iron", //5
"naturalgas", //6
"oil", //7
"gold", //8
"kaolin", //9
"cobalt", //10
"coal", //11
"copper", //12
"lithium", //13
"magnesium", //14
"manganese", //15
"molybdenum", //16
"nickel", //17
"phosphate", //18
"platinum", //19
"potash", //20
"rubies", //21
"silver", //22
"soda", //23
"tantalum", //24
"titanium", //25
"uranium", //26
"vanadium", //27
"tungsten", //28
"zinc", //29
"tin", //30
"salt" //31
]
class Factory {
constructor(tier) {
this.ores = []
this.tier = tier
if (this.tier == undefined)
this.tier = 0
if (this.tier == 0) {
this.ores.push(5)
this.ores.push(11)
this.ores.push(12)
this.ores.push(23)
} else {
var myrng = new Math.seedrandom(this.tier);
this.ores.push(Math.abs(myrng.int32()) % bodenvorkommen.length)
this.ores.push(Math.abs(myrng.int32()) % bodenvorkommen.length)
this.ores.push(Math.abs(myrng.int32()) % bodenvorkommen.length)
this.ores.push(Math.abs(myrng.int32()) % bodenvorkommen.length)
}
this.tiles = []
this.items = []
for (var x = 0; x < 25; x++) {
@ -204,6 +248,26 @@ class Factory {
}
}
unloadImages() {
for (var x = 0; x < 25; x++) {
for (var y = 0; y < 12; y++) {
if (this.tiles[x][y] != 0) {
this.tiles[x][y].unloadImages()
}
}
}
}
loadImages() {
for (var x = 0; x < 25; x++) {
for (var y = 0; y < 12; y++) {
if (this.tiles[x][y] != 0) {
this.tiles[x][y].loadImages()
}
}
}
}
getTiles() {
var temp = []
for (var x = 0; x < 25; x++) {

View File

@ -1,3 +1,9 @@
var version = "Indev 1.0"
var factorysToBuy = 0
var factoryPrice = 50000
var factoryRerollPrice = 2
var factorys = []
var inventory = {}
var money = 100
@ -56,6 +62,9 @@ function save() {
game = {}
game.money = money
game.gametime = gametime
game.factorysToBuy = factorysToBuy
game.factoryRerollPrice = factoryRerollPrice
game.factoryPrice = factoryPrice
game.inventory = []
for (var i = 0; i < inventory.items.length; i++) {
game.inventory.push(inventory.items[i].id)
@ -113,7 +122,7 @@ function loadGameData() {
inventory = new Inventory()
//game = Cookies.get("game")
$.get("php/playerdata.php", function(data) {
if (JSON.parse(data).gametime != undefined) {
if (JSON.parse(data).money != undefined) {
game = JSON.parse(data)
} else {
game = 0
@ -123,6 +132,9 @@ function loadGameData() {
console.log("Loading Game")
money = game.money
gametime = game.gametime
factorysToBuy = game.factorysToBuy
factoryRerollPrice = game.factoryRerollPrice
factoryPrice = game.factoryPrice
inventory = new Inventory()
factorys = []
for (var i = 0; i < game.inventory.length; i++) {
@ -221,7 +233,7 @@ function gametick(timestep) {
tick.push(new Date().getTime())
if (tick.length > 48) {
tick = tick.splice(1)
$("#speed").text("Game Speed: " + ((tick[47] - tick[0] + 30) / 10) + "%")
$("#speed").html("Game Speed: " + ((tick[47] - tick[0] + 30) / 10) + "%<br>" + version)
}
if (Math.round((new Date().getTime() - lastsave) / 60000) > 5 && lastsave != 0) {
save()
@ -376,6 +388,7 @@ function prepairRender() {
$('#inventoryBig').hide()
$('#selectItem').hide()
$('#options').hide()
$('#selectFactory').hide()
for (var i = 0; i < items.length; i++) {
var tag = '<img id="itemSel_' + i + '" draggable="false" class="buildtile itemhover" src="images/items/' + items[i].name + '.png">'
$('#selectItem').append(tag)
@ -433,7 +446,7 @@ function prepairRender() {
$('#clickToSell').text(lang.clickToSell)
}
var infoBarIcons = ["build.png", "move.png", "rotate.png", "delete.png", null, "upgrade.png", "info.png", null, "rocket.png"]
var infoBarIcons = ["build.png", "move.png", "rotate.png", "delete.png", null, "upgrade.png", "info.png", null, "factorys.png"]
var infoGlowOpacity = 0
var infoGlowOpacityD = 0.03
@ -450,6 +463,8 @@ function drawInfoBar() {
selectedX = 2
} else if (mode == "delete") {
selectedX = 3
} else if (mode == "selectFactory") {
selectedX = 8
}
if (selectedX != -1) {
@ -481,8 +496,8 @@ function drawInfoBar() {
$('#infoDesc h1').text(lang.tiles[selectedTile.name].name)
$('#infoDesc p').text(lang.tiles[selectedTile.name].description)
} else {
$('#infoDesc h1').text("")
$('#infoDesc p').text("")
$('#infoDesc h1').text("Factory " + currentFactory)
$('#infoDesc p').html("<br>"+lang.mineralslable + "<br><br> - " + lang.minerals[factorys[currentFactory].ores[0]] + "<br> - " + lang.minerals[factorys[currentFactory].ores[1]] + "<br> - " + lang.minerals[factorys[currentFactory].ores[2]] + "<br> - " + lang.minerals[factorys[currentFactory].ores[3]])
}
if (selectedTile.maxwork != 0 && mode != "selectbuilding" && mode != "building") {
$('#infoDesc p').css("height", 154)

View File

@ -30,7 +30,7 @@
},{
"id": 7,
"name": "rawpaper",
"value": 30
"value": 100
},{
"id": 8,
"name": "paper",

22
js/libs/pixi.min.js vendored

File diff suppressed because one or more lines are too long

1
js/libs/seedrandom.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(a,b){function c(c,j,k){var n=[];j=1==j?{entropy:!0}:j||{};var s=g(f(j.entropy?[c,i(a)]:null==c?h():c,3),n),t=new d(n),u=function(){for(var a=t.g(m),b=p,c=0;a<q;)a=(a+c)*l,b*=l,c=t.g(1);for(;a>=r;)a/=2,b/=2,c>>>=1;return(a+c)/b};return u.int32=function(){return 0|t.g(4)},u.quick=function(){return t.g(4)/4294967296},u.double=u,g(i(t.S),a),(j.pass||k||function(a,c,d,f){return f&&(f.S&&e(f,t),a.state=function(){return e(t,{})}),d?(b[o]=a,c):a})(u,s,"global"in j?j.global:this==b,j.state)}function d(a){var b,c=a.length,d=this,e=0,f=d.i=d.j=0,g=d.S=[];for(c||(a=[c++]);e<l;)g[e]=e++;for(e=0;e<l;e++)g[e]=g[f=s&f+a[e%c]+(b=g[e])],g[f]=b;(d.g=function(a){for(var b,c=0,e=d.i,f=d.j,g=d.S;a--;)b=g[e=s&e+1],c=c*l+g[s&(g[e]=g[f=s&f+b])+(g[f]=b)];return d.i=e,d.j=f,c})(l)}function e(a,b){return b.i=a.i,b.j=a.j,b.S=a.S.slice(),b}function f(a,b){var c,d=[],e=typeof a;if(b&&"object"==e)for(c in a)try{d.push(f(a[c],b-1))}catch(a){}return d.length?d:"string"==e?a:a+"\0"}function g(a,b){for(var c,d=a+"",e=0;e<d.length;)b[s&e]=s&(c^=19*b[s&e])+d.charCodeAt(e++);return i(b)}function h(){try{var b;return j&&(b=j.randomBytes)?b=b(l):(b=new Uint8Array(l),(k.crypto||k.msCrypto).getRandomValues(b)),i(b)}catch(b){var c=k.navigator,d=c&&c.plugins;return[+new Date,k,d,k.screen,i(a)]}}function i(a){return String.fromCharCode.apply(0,a)}var j,k=this,l=256,m=6,n=52,o="random",p=b.pow(l,m),q=b.pow(2,n),r=2*q,s=l-1;if(b["seed"+o]=c,g(b.random(),a),"object"==typeof module&&module.exports){module.exports=c;try{j=require("crypto")}catch(a){}}else"function"==typeof define&&define.amd&&define(function(){return c})}([],Math);

View File

@ -25,6 +25,8 @@ function style() {
$('#screen').css('margin-left', screenMarginLeft)
$('#buildselect').css('margin-top', screenMarginTop)
$('#buildselect').css('margin-left', screenMarginLeft)
$('#selectFactory').css('margin-top', screenMarginTop)
$('#selectFactory').css('margin-left', screenMarginLeft)
$('#selectItem').css('margin-top', screenMarginTop)
$('#selectItem').css('margin-left', screenMarginLeft)
$('#inventoryBig').css('margin-top', screenMarginTop)
@ -197,6 +199,16 @@ function clickEvents() {
closeUi()
}
break
case 8:
//selectFactory BUTTON
if (mode == "none") {
mode = "selectFactory"
drawFactorys()
$('#selectFactory').fadeIn(200)
} else {
closeUi()
}
break
}
}
})
@ -494,6 +506,11 @@ function closeUi() {
$('#selectItem').fadeOut(200)
return false
}
if (mode == "selectFactory") {
mode = "none"
$('#selectFactory').fadeOut(200)
return false
}
}
function sort() {
@ -611,3 +628,48 @@ function drawBigInventory(inventory) {
currentIndex++
}
}
function drawFactorys() {
$('#factoryScroll').empty()
if (factorysToBuy == 0)
factorysToBuy = gametime
for (var i = 0; i < factorys.length; i++) {
$('#factoryScroll').append('<div id="factory' + i + '" class="factory"><h1>Factory ' + i + '</h1><div class="minerals"><br><h2>' + lang.mineralslable + '</h2>' + "<br> - " + lang.minerals[factorys[i].ores[0]] + "<br> - " + lang.minerals[factorys[i].ores[1]] + "<br> - " + lang.minerals[factorys[i].ores[2]] + "<br> - " + lang.minerals[factorys[i].ores[3]] + '</div></div>')
$('#factory' + i).click(function() {
var id = $(this).attr("id");
id = parseInt(id.substr(7))
factorys[currentFactory].unloadImages()
factorys[id].loadImages()
currentFactory = id
closeUi()
})
}
$('#buyfactory').empty()
$('#buyfactory').append('<div id="reroll" class="factoryToBuy"><br><h2>' + lang.clickToBuyFactory + '</h2><img src="images/ui/reroll.png"/><span>' + lang.reroll + '<br><span>' + formatCount(factoryRerollPrice) + ' ' + lang.money + '</span></span></div>')
$('#reroll').click(function() {
if (money >= factoryRerollPrice) {
money -= factoryRerollPrice
factorysToBuy = gametime
factoryRerollPrice = factoryRerollPrice * 3.5
drawFactorys()
}
})
var myrng = new Math.seedrandom(factorysToBuy);
for (var i = 0; i < 4; i++) {
tier = Math.abs(myrng.int32())
var rng = new Math.seedrandom(tier);
$('#buyfactory').append('<div class="factoryToBuy" id="factoryToBuy' + tier + '"><br><p>' + lang.minerals[Math.abs(rng.int32()) % bodenvorkommen.length] + '</p><p>' + lang.minerals[Math.abs(rng.int32()) % bodenvorkommen.length] + '</p><p>' + lang.minerals[Math.abs(rng.int32()) % bodenvorkommen.length] + '</p><p>' + lang.minerals[Math.abs(rng.int32()) % bodenvorkommen.length] + '</p><h1>' + formatCount(factoryPrice) + " " + lang.money + '</h1></div>')
$('#factoryToBuy' + tier).click(function() {
var id = $(this).attr("id");
id = parseInt(id.substr(12))
if (money >= factoryPrice) {
money -= factoryPrice
factoryPrice = factoryPrice * 1.7 + 240000
factoryRerollPrice = Math.round(factoryRerollPrice / 2 + 1)
factorys.push(new Factory(id))
factorysToBuy = gametime
drawFactorys()
}
})
}
}

View File

@ -63,13 +63,49 @@
}
}
},
"minerals": ["bauxite",
"beryllium",
"lead",
"chrome",
"diamonds",
"iron",
"naturalgas",
"oil",
"gold",
"kaolin",
"cobalt",
"coal",
"copper",
"lithium",
"magnesium",
"manganese",
"molybdenum",
"nickel",
"phosphate",
"platinum",
"potash",
"rubies",
"silver",
"soda",
"tantalum",
"titanium",
"uranium",
"vanadium",
"tungsten",
"zinc",
"tin",
"salt"
],
"items": ["None", "Log", "Planks", "Stone", "Charcoal", "Sawdust", "Charcoal Dust", "Raw Paper", "Paper", "Siev", "Filter", "Koks", "Briquettes"],
"more": "Show Inventory / Sell Items",
"inventory": "Inventory",
"player": "Player",
"infotooltips": ["Build", "Move", "Rotate", "Delete!", "", "Upgrade", "Information", "", "Go To Space!!"],
"infotooltips": ["Build", "Move", "Rotate", "Delete!", "", "Upgrade", "Information", "", "My Factorys"],
"cost": "Cost",
"clickToSell": "Click on items to sell them.",
"reroll": "Reroll Offers",
"clickToBuyFactory": "Click on a Factory to Buy.",
"money": "Dollars",
"mineralslable": "Minerals:",
"numbers": ["", " Thousand", " Million", " Billion", " Trillion", " Quadrillion", " Quintillion", " Sextillion", " Septillion", " Octillion", " Nonillion", " Decillion", " Undecillion", " Duodecillion", " Tredecillion", " Quattuordecillion", " Quindecillion", " Sexdecillion", " Septendecillion", " Octodecillion", " Novemdecillion", " Vigintillion"]
}

View File

@ -5,5 +5,6 @@ rotate
delete
showmore
selectItem
selectFactory
400 Items = 0.5 MB