1// -------------------------------------------------------------------------- // 2// ------------------------------ ANCHOR DEMO FLAG --------------------------------- // 3// -------------------------------------------------------------------------- // 4var urlSearchParams2 = function(name) { 5 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); 6 if (results == null){ 7 return null; 8 } 9 else { 10 return decodeURI(results[1]) || 0; 11 } 12} 13//const urlParams = new URLSearchParams(window.location.search); 14 15var demo = urlSearchParams2('demo'); 16//var demo = true; 17 18PIXI.settings.ROUND_PIXELS = true; 19 20// -------------------------------------------------------------------------- // 21// ----------------------------- ANCHOR CUSTOM FONTS ------------------------------- // 22// -------------------------------------------------------------------------- // 23window.WebFontConfig = { 24 google: { 25 families: ['Roboto', 'Roboto Slab', interactive_customSettings.link.font_sheet[0]] 26 } 27}; 28 29// --- NOTE Include the web-font loader script --- // 30(function () { 31 var wf = document.createElement('script'); 32 wf.src = ('https:' === document.location.protocol ? 'https' : 'http') + 33 '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; 34 wf.type = 'text/javascript'; 35 wf.async = 'true'; 36 var s = document.getElementsByTagName('script')[0]; 37 s.parentNode.insertBefore(wf, s); 38})(); 39 40var result_message = '', 41 message_text = ''; 42 43// -------------------------------------------------------------------------- // 44// --------------------------- ANCHOR CANVAS SETTINGS ------------------------------ // 45// -------------------------------------------------------------------------- // 46 47var canvas_width = interactive_basicSettings.basic.canvasElement.width, 48 canvas_height = interactive_basicSettings.basic.canvasElement.height, 49 canvas_transparency = interactive_basicSettings.basic.canvasElement.transparency, 50 canvas_resolution = interactive_basicSettings.basic.canvasElement.resolution; 51 52// -------------------------------------------------------------------------- // 53// ------------------------------ ANCHOR PIXI SETUP -------------------------------- // 54// -------------------------------------------------------------------------- // 55if (!document.getElementById('playCanvas')) { 56 var app = new PIXI.Application({ 57 width: canvas_width, 58 height: canvas_height, 59 transparent: canvas_transparency, 60 resolution: window.devicePixelRatio 61 }); 62 63 // --- NOTE Append PIXI Element to DOM --- // 64 document.getElementById('interactiveGameCanvas').appendChild(app.view); 65 66 var canvasView = app.view; 67 68 var rendererOptions = { 69 antialias: false, 70 view: canvasView, 71 resolution: "2", 72 transparent: false, 73 preserveDrawingBuffer: false, 74 autoResize: true, 75 autoDensity: true, 76 clearBeforeRender: true 77 }; 78 79 this.renderer = PIXI.autoDetectRenderer(canvas_width, canvas_height, rendererOptions); 80 81 if (app.view.getContext('webgl')) { 82 drawScene(); 83 } else { 84 app.renderer.view.style.width = canvas_width + "px"; 85 app.renderer.view.style.height = canvas_height + "px"; 86 87 app.stage.scale.set(2, 2); 88 } 89 90 app.view.style.display = 'none'; 91} else { 92 webview = true; 93 94 var canvas = document.getElementById('playCanvas'); 95 96 var app = new PIXI.Application({ 97 view: canvas, 98 width: canvas_width * 2, 99 height: canvas_height * 2, 100 transparent: canvas_transparency, 101 resolution: canvas_resolution, 102 forceCanvas: true 103 }); 104 105 app.renderer.view.style.width = canvas_width + "px"; 106 app.renderer.view.style.height = canvas_height + "px"; 107 108 app.stage.scale.set(2, 2); 109} 110 111// --- NOTE If using WebGL -- // 112function resize(canvas) { 113 var gl = app.view.getContext('webgl'); 114 var realToCSSPixels = window.devicePixelRatio; 115 116 // Lookup the size the browser is displaying the canvas in CSS pixels 117 // and compute a size needed to make our drawingbuffer match it in 118 // device pixels. 119 var displayWidth = Math.floor(gl.canvas.clientWidth * realToCSSPixels); 120 var displayHeight = Math.floor(gl.canvas.clientHeight * realToCSSPixels); 121 122 // Check if the canvas is not the same size. 123 if (gl.canvas.width !== displayWidth || 124 gl.canvas.height !== displayHeight) { 125 126 // Make the canvas the same size 127 gl.canvas.width = displayWidth; 128 gl.canvas.height = displayHeight; 129 } 130} 131 132function drawScene() { 133// var gl = canvasE.getContext('webgl'); 134 var gl = app.view.getContext('webgl'); 135 136 resize(gl.canvas); 137 138 gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); 139} 140 141var width = (window.innerWidth > 0) ? window.innerWidth : screen.width; 142 143if (document.getElementById('rez')) { 144 if ((width - 20) < interactive_basicSettings.basic.canvasElement.width) { 145 app.view.style.width = (screen.width - 15) + "px"; 146 app.view.style.height = (screen.width - 15) + "px"; 147 } else if (screen.width - 20 < interactive_basicSettings.basic.canvasElement.height) { 148 app.view.style.width = (screen.width - 35) + "px"; 149 app.view.style.height = (screen.width - 35) + "px"; 150 } 151} else { 152 if ((width - 10) < interactive_basicSettings.basic.canvasElement.width) { 153 app.view.style.width = (window.innerWidth - 35) + "px"; 154 app.view.style.height = (window.innerWidth - 35) + "px"; 155 } else if (screen.width < interactive_basicSettings.basic.canvasElement.height) { 156 app.view.style.width = (screen.width - 35) + "px"; 157 app.view.style.height = (screen.width - 35) + "px"; 158 } 159} 160 161// --- Add background color to PIXI Element --- // 162app.renderer.backgroundColor = 0x4d4d4d; 163 164// -------------------------------------------------------------------------- // 165// ------------------------------- ANCHOR USER INIT -------------------------------- // 166// -------------------------------------------------------------------------- // 167 168// --- NOTE Define user settings --- // 169var uID, 170 uName, 171 uPointBalance, 172 uPointHold, 173 uPointOld; 174 175if (!demo) { 176 uID = JSON.stringify(document.querySelector('#userIdentifier').value); 177 if (!document.getElementById('userPoints')) { 178 uPointBalance = document.querySelector('.userPointBalance #p_lt_zoneHeader_newPointBalance_repItems_ctl00_ctl00_lblTotal').innerText; 179 180 uPointOld = document.querySelector('.userPointBalance #p_lt_zoneHeader_newPointBalance_repItems_ctl00_ctl00_lblTotal').innerText; 181 } else { 182 uPointBalance = document.querySelector('#userPoints').value; 183 uPointOld = document.querySelector('#userPoints').value; 184 } 185 uPointHold = 0; 186} else { 187 uID = '007'; 188 uName = 'Guest'; 189 uPointBalance = 100; 190 uPointHold = 100; 191 uPointOld = 100; 192} 193 194 195// -------------------------------------------------------------------------- // 196// ------------------------------ ANCHOR GAME CALLS -------------------------------- // 197// -------------------------------------------------------------------------- // 198function sendRequest(wager) { 199 var xhttp = new XMLHttpRequest(), 200 url = '/cmspages/InteractiveGamesWebService.asmx/GetPlayResult', 201 req = '{encryptedUserId: ' + uID + ',gameId:' + gameid.id + ',wager: ' + wager + '}'; 202 203 xhttp.open('POST', url, true); 204 xhttp.setRequestHeader('Content-type', 'application/json'); 205 206 xhttp.onload = function() { 207 if (this.status == 200) { 208 var data = JSON.parse(this.responseText); 209 data = JSON.parse(data.d); 210 211 // console.log(data); 212 213 var winNow = data.Winner, 214 successful = data.Successful, 215 result_message = data.ResultMessage, 216 prize_name = data.PrizeName; 217 218 if (successful === true) { 219 uPointHold = numberWithCommas(data.UserCurrency); 220 221 animations.wager.out[interactive_customSettings.animations.wager.out](); 222 animations.landing.out[interactive_customSettings.animations.landing.out](); 223 animations.play.in[interactive_customSettings.animations.play.in](); 224 225 for (var i = 0; i < main_active_objs.length; i++) { 226 main_active_objs[i].interactive = true; 227 main_active_objs[i].buttonMode = true; 228 } 229 230 win_currentwon_txt.text = result_message; 231 232 233 if (winNow === true) { 234 winner = true; 235 // createResults(); 236 if (prize_name === 'Interactive Game Plinko Test prize. 10 points.') { 237 var prize_split = prize_name.split('. '); 238 var prize = prize_split[1]; 239 var replace = /\./gm; 240 var final_prize = prize.replace(replace, '!'); 241 message_text = final_prize; 242 } else { 243 244 var final_prize = prize_name; 245 message_text = final_prize; 246 } 247 248 249 message_text = final_prize; 250 } else { 251 winner = false;
252 // createResults(); 253 } 254 255 } else { 256 alert.alertIn(result_message); 257 } 258 } 259 } 260 261 xhttp.onerror = function() { 262 console.log('Error: Game Calls'); 263 } 264 265 xhttp.send(req); 266} 267 268function determine_wagers() { 269 var xhttp = new XMLHttpRequest(), 270 url = '/cmspages/InteractiveGamesWebService.asmx/GetGameWagerList', 271 req = '{encryptedUserId: ' + uID + ',gameId: ' + gameid.id + '}'; 272 273 xhttp.open('POST', url, true); 274 xhttp.setRequestHeader('Content-type', "application/json"); 275 276 xhttp.onload = function() { 277 if (this.status == 200) { 278 var data = JSON.parse(this.responseText); 279 data = JSON.parse(data.d); 280 } 281 } 282 283 xhttp.send(req); 284} 285 286// --------------------------------- ANCHOR Set up Containers ----------------------------------- // 287 288// ------ NOTE Stages ------ // 289var stage_ui = new PIXI.Container, 290 stage_landing = new PIXI.Container, 291 stage_main = new PIXI.Container, 292 stage_objects = new PIXI.Container, 293 stage_win = new PIXI.Container, 294 stage_loader = new PIXI.Container, 295 loadingContainer = new PIXI.Container, 296 alertContainer = new PIXI.Container; 297 298// ------ NOTE Stage Components ------ // 299 300// --- Landing --- // 301var landing_assets = new PIXI.Container, 302 landing_ui = new PIXI.Container; 303 304// --- Main --- // 305var main_assets = new PIXI.Container, 306 main_ui = new PIXI.Container; 307 308// --- Win --- // 309var win_assets = new PIXI.Container, 310 win_ui = new PIXI.Container; 311 312// --- Always UI --- // 313var ui = new PIXI.Container; 314 315// ------ NOTE Component Containers ------ // 316 317// --- Landing --- // 318var landing_assets_background = new PIXI.Container, 319 landing_assets_decoration = new PIXI.Container, 320 landing_assets_logo = new PIXI.Container; 321 322var landing_ui_play_btn = new PIXI.Container, 323 landing_ui_wagers = new PIXI.Container, 324 landing_ui_wager_btn_1 = new PIXI.Container, 325 landing_ui_wager_btn_2 = new PIXI.Container, 326 landing_ui_wager_btn_3 = new PIXI.Container; 327 328// --- Main --- // 329var main_assets_background = new PIXI.Container, 330 main_assets_decoration = new PIXI.Container, 331 main_assets_spinner = new PIXI.Container, 332 main_assets_main_ticker = new PIXI.Container; 333 334var main_ui_upoint_balance = new PIXI.Container, 335 main_ui_uname = new PIXI.Container, 336 main_ui_wager = new PIXI.Container, 337 main_ui_auto_btn = new PIXI.Container; 338 339// --- Win --- // 340var win_assets_background = new PIXI.Container, 341 win_assets_win_decoration = new PIXI.Container; 342 win_assets_lose_decoration = new PIXI.Container; 343 344var win_ui_replay_btn = new PIXI.Container, 345 win_ui_playmessage = new PIXI.Container, 346 win_ui_totalwon = new PIXI.Container; 347 348var options_info = new PIXI.Container, 349 directions_info = new PIXI.Container; 350 351// --------------------------------- NOTE Set up Assets ----------------------------------- // 352var options_icon, 353 options_soundON, 354 options_soundOFF, 355 options_screenMIN, 356 options_screenMAX; 357 358var landing_background, 359 landing_decoration, 360 landing_logo, 361 landing_play_btn, 362 landing_wager, 363 landing_wager_btn_1, 364 landing_wager_btn_2, 365 landing_wager_btn_3; 366 367var main_background, 368 main_decoration, 369 main_decoration_2, 370 main_match_objs = [], 371 main_active_objs = [], 372 boxArray = [], 373 main_reveal_animation, 374 main_revealed = 0, 375 main_upoint_balance, 376 main_uname, 377 main_wager, 378 main_auto_btn; 379 380var win_background, 381 win_win_decoration, 382 win_lose_decoration, 383 win_replay_btn, 384 win_playmessage, 385 win_currentwon = 0, 386 win_totalwon = 0; 387 388var alert_plate, 389 alert_btn; 390 391// --- Sprite Sheets --- // 392var ui_sheet, 393 asset_sheet, 394 sound_sheet; 395 396var playing = false; 397 398// ---------------------- NOTE Init Main Timeline Function ------------------------ // 399var timeLine = new TimelineMax(); 400 401// -------------------------- NOTE Default All Settings --------------------------- // 402options_settings = false, 403options_sound = true, 404options_screenMIN = true; 405 406// ------------------------------- NOTE Graphics ---------------------------------- // 407var blurFilter = new PIXI.filters.BlurFilter(2); 408 409var button; 410 411var options_info_gfx, 412 options_btn_container; 413 414var alert_points_gfx; 415 416var wager_btn_background_gfx; 417 418// ------------------------------ NOTE Text Elements ------------------------------ // 419// --- UI --- // 420var ui_upoints_txt = new MultiStyleText(interactive_customSettings.text.ui_upoints_txt.text + "<h1>" + numberWithCommas(uPointBalance) + "</h1>", { 421 "default": { 422 "fontFamily": interactive_customSettings.text.ui_upoints_txt.default.fontFamily, 423 "fontSize": interactive_customSettings.text.ui_upoints_txt.default.fontSize, 424 "fontWeight": interactive_customSettings.text.ui_upoints_txt.default.fontWeight, 425 "fill": interactive_customSettings.text.ui_upoints_txt.default.fill, 426 "align": interactive_customSettings.text.ui_upoints_txt.default.align, 427 "lineHeight": interactive_customSettings.text.ui_upoints_txt.default.lineHeight 428 }, 429 "h1": { 430 "fontFamily": interactive_customSettings.text.ui_upoints_txt.h1.fontFamily, 431 "fontSize": interactive_customSettings.text.ui_upoints_txt.h1.fontSize, 432 "fontWeight": interactive_customSettings.text.ui_upoints_txt.h1.fontWeight, 433 "fill": interactive_customSettings.text.ui_upoints_txt.h1.fill, 434 "align": interactive_customSettings.text.ui_upoints_txt.h1.align, 435 "lineHeight": interactive_customSettings.text.ui_upoints_txt.h1.lineHeight 436 }, 437 "strong": { 438 "fontWeight": interactive_customSettings.text.ui_upoints_txt.strong.fontWeight 439 }, 440 "em_default": { 441 "fontWeight": interactive_customSettings.text.ui_upoints_txt.em_default.fontWeight 442 }, 443 "em_h1": { 444 "fontWeight": interactive_customSettings.text.ui_upoints_txt.em_h1.fontWeight 445 }, 446 "spc": { 447 "fontSize": interactive_customSettings.text.ui_upoints_txt.spc.fontSize, 448 "lineHeight": interactive_customSettings.text.ui_upoints_txt.spc.lineHeight 449 } 450}); 451 452var options_info_txt = new MultiStyleText(interactive_customSettings.text.options_info_txt.text, { 453 "default": { 454 "wordWrap": true, 455 "wordWrapWidth": 390, 456 "fontFamily": interactive_customSettings.text.options_info_txt.default.fontFamily, 457 "fontSize": interactive_customSettings.text.options_info_txt.default.fontSize, 458 "fontWeight": interactive_customSettings.text.options_info_txt.default.fontWeight, 459 "fill": interactive_customSettings.text.options_info_txt.default.fill, 460 "align": interactive_customSettings.text.options_info_txt.default.align, 461 "lineHeight": interactive_customSettings.text.options_info_txt.default.lineHeight, 462 "valign": 'baseline' 463 }, 464 "h1": { 465 "fontFamily": interactive_customSettings.text.options_info_txt.h1.fontFamily, 466 "fontSize": interactive_customSettings.text.options_info_txt.h1.fontSize, 467 "fontWeight": interactive_customSettings.text.options_info_txt.h1.fontWeight, 468 "fill": interactive_customSettings.text.options_info_txt.h1.fill, 469 "align": interactive_customSettings.text.options_info_txt.h1.align, 470 "lineHeight": interactive_customSettings.text.options_info_txt.h1.lineHeight, 471 "valign": 'top' 472 }, 473 "strong": { 474 "fontWeight": interactive_customSettings.text.options_info_txt.strong.fontWeight 475 }, 476 "em_default": { 477 "fontWeight": interactive_customSettings.text.options_info_txt.em_default.fontWeight 478 }, 479 "em_h1": { 480 "fontWeight": interactive_customSettings.text.options_info_txt.em_h1.fontWeight 481 }, 482 "spc": { 483 "fontSize": interactive_customSettings.text.options_info_txt.spc.fontSize, 484 "lineHeight": interactive_customSettings.text.options_info_txt.spc.lineHeight 485 } 486}); 487 488var landing_wager_message_txt = new MultiStyleText(interactive_customSettings.text.landing_wager_message_txt.text, { 489 "default": { 490 "fontFamily": interactive_customSettings.text.landing_wager_message_txt.default.fontFamily, 491 "fontSize": interactive_customSettings.text.landing_wager_message_txt.default.fontSize, 492 "fontWeight": interactive_customSettings.text.landing_wager_message_txt.default.fontWeight, 493 "fill": interactive_customSettings.text.landing_wager_message_txt.default.fill, 494 "align": interactive_customSettings.text.landing_wager_message_txt.default.align, 495 "lineHeight": interactive_customSettings.text.landing_wager_message_txt.default.lineHeight, 496 "padding": 10 497 }, 498 "h1": { 499 "fontFamily": interactive_customSettings.text.landing_wager_message_txt.h1.fontFamily, 500 "fontSize": interactive_customSettings.text.landing_wager_message_txt.h1.fontSize, 501 "fontWeight": interactive_customSettings.text.landing_wager_message_txt.h1.fontWeight, 502 "fill": interactive_customSettings.text.landing_wager_message_txt.h1.fill, 503 "align": interactive_customSettings.text.landing_wager_message_txt.h1.align, 504 "lineHeight": interactive_customSettings.text.landing_wager_message_txt.h1.lineHeight 505 }, 506 "strong": { 507 "fontWeight": interactive_customSettings.text.landing_wager_message_txt.strong.fontWeight 508 }, 509 "em_default": { 510 "fontWeight": interactive_customSettings.text.landing_wager_message_txt.em_default.fontWeight 511 }, 512 "em_h1": { 513 "fontWeight": interactive_customSettings.text.landing_wager_message_txt.em_h1.fontWeight 514 }, 515 "spc": { 516 "fontSize": interactive_customSettings.text.landing_wager_message_txt.spc.fontSize, 517 "lineHeight": interactive_customSettings.text.landing_wager_message_txt.spc.lineHeight 518 } 519 }); 520 521// --- NOTE Win --- // 522var win_playmessage_txt = new MultiStyleText('-', { 523 "default": { 524 "wordWrap": true, 525 "wordWrapWidth": 390,
526 "fontFamily": interactive_customSettings.text.win_playmessage_txt.default.fontFamily, 527 "fontSize": interactive_customSettings.text.win_playmessage_txt.default.fontSize, 528 "fontWeight": interactive_customSettings.text.win_playmessage_txt.default.fontWeight, 529 "fill": interactive_customSettings.text.win_playmessage_txt.default.fill, 530 "align": interactive_customSettings.text.win_playmessage_txt.default.align, 531 "lineHeight": interactive_customSettings.text.win_playmessage_txt.default.lineHeight 532 }, 533 "h1": { 534 "fontFamily": interactive_customSettings.text.win_playmessage_txt.h1.fontFamily, 535 "fontSize": interactive_customSettings.text.win_playmessage_txt.h1.fontSize, 536 "fontWeight": interactive_customSettings.text.win_playmessage_txt.h1.fontWeight, 537 "fill": interactive_customSettings.text.win_playmessage_txt.h1.fill, 538 "align": interactive_customSettings.text.win_playmessage_txt.h1.align, 539 "lineHeight": interactive_customSettings.text.win_playmessage_txt.h1.lineHeight 540 }, 541 "strong": { 542 "fontWeight": interactive_customSettings.text.win_playmessage_txt.strong.fontWeight 543 }, 544 "em_default": { 545 "fontWeight": interactive_customSettings.text.win_playmessage_txt.em_default.fontWeight 546 }, 547 "em_h1": { 548 "fontWeight": interactive_customSettings.text.win_playmessage_txt.em_h1.fontWeight 549 }, 550 "spc": { 551 "fontSize": interactive_customSettings.text.win_playmessage_txt.spc.fontSize, 552 "lineHeight": interactive_customSettings.text.win_playmessage_txt.spc.lineHeight 553 } 554}); 555 556var win_currentwon_txt = new MultiStyleText(result_message, { 557 "default": { 558 "fontFamily": interactive_customSettings.text.win_currentwon_txt.default.fontFamily, 559 "fontSize": interactive_customSettings.text.win_currentwon_txt.fontSize, 560 "fontWeight": interactive_customSettings.text.win_currentwon_txt.fontWeight, 561 "fill": interactive_customSettings.text.win_currentwon_txt.fill, 562 "align": interactive_customSettings.text.win_currentwon_txt.align, 563 "lineHeight": interactive_customSettings.text.win_currentwon_txt.default.lineHeight 564 }, 565 "h1": { 566 "fontFamily": interactive_customSettings.text.win_currentwon_txt.h1.fontFamily, 567 "fontSize": interactive_customSettings.text.win_currentwon_txt.h1.fontSize, 568 "fontWeight": interactive_customSettings.text.win_currentwon_txt.h1.fontWeight, 569 "fill": interactive_customSettings.text.win_currentwon_txt.h1.fill, 570 "align": interactive_customSettings.text.win_currentwon_txt.h1.align, 571 "lineHeight": interactive_customSettings.text.win_currentwon_txt.h1.lineHeight 572 }, 573 "strong": { 574 "fontWeight": interactive_customSettings.text.win_currentwon_txt.strong.fontWeight 575 }, 576 "em_default": { 577 "fontWeight": interactive_customSettings.text.win_currentwon_txt.em_default.fontWeight 578 }, 579 "em_h1": { 580 "fontWeight": interactive_customSettings.text.win_currentwon_txt.em_h1.fontWeight 581 }, 582 "spc": { 583 "fontSize": interactive_customSettings.text.win_currentwon_txt.spc.fontSize, 584 "lineHeight": interactive_customSettings.text.win_currentwon_txt.spc.lineHeight 585 } 586}); 587 588var alert_txt = new MultiStyleText('text', { 589 "default": { 590 "wordWrap": true, 591 "wordWrapWidth": 380, 592 "fontFamily": interactive_customSettings.text.alert.default.fontFamily, 593 "fontSize": interactive_customSettings.text.alert.default.fontSize, 594 "fontWeight": interactive_customSettings.text.alert.default.fontWeight, 595 "fill": interactive_customSettings.text.alert.default.fill, 596 "align": interactive_customSettings.text.alert.default.align, 597 "lineHeight": interactive_customSettings.text.alert.default.lineHeight 598 }, 599 "h1": { 600 "fontFamily": interactive_customSettings.text.alert.h1.fontFamily, 601 "fontSize": interactive_customSettings.text.alert.h1.fontSize, 602 "fontWeight": interactive_customSettings.text.alert.h1.fontWeight, 603 "fill": interactive_customSettings.text.alert.h1.fill, 604 "align": interactive_customSettings.text.alert.h1.align 605 }, 606 "strong": { 607 "fontWeight": interactive_customSettings.text.alert.strong.fontWeight 608 }, 609 "em_default": { 610 "fontWeight": interactive_customSettings.text.alert.em_default.fontWeight 611 }, 612 "em_h1": { 613 "fontWeight": interactive_customSettings.text.alert.em_h1.fontWeight 614 }, 615 "spc": { 616 "fontSize": interactive_customSettings.text.alert.spc.fontSize, 617 "lineHeight": interactive_customSettings.text.alert.spc.lineHeight 618 } 619}); 620 621var button_txt = new MultiStyleText(interactive_customSettings.text.button.text, { 622 "default": { 623 "fontFamily": interactive_customSettings.text.button.default.fontFamily, 624 "fontSize": interactive_customSettings.text.button.default.fontSize, 625 "fontWeight": interactive_customSettings.text.button.default.fontWeight, 626 "fill": interactive_customSettings.text.button.default.fill, 627 "align": interactive_customSettings.text.button.default.align, 628 "lineHeight": interactive_customSettings.text.button.h1.lineHeight 629 }, 630 "h1": { 631 "fontFamily": interactive_customSettings.text.button.h1.fontFamily, 632 "fontSize": interactive_customSettings.text.button.h1.fontSize, 633 "fontWeight": interactive_customSettings.text.button.h1.fontWeight, 634 "fill": interactive_customSettings.text.button.h1.fill, 635 "align": interactive_customSettings.text.button.h1.align, 636 "lineHeight": interactive_customSettings.text.button.h1.lineHeight 637 }, 638 "strong": { 639 "fontWeight": interactive_customSettings.text.button.strong.fontWeight 640 }, 641 "em_default": { 642 "fontWeight": interactive_customSettings.text.button.em_default.fontWeight 643 }, 644 "em_h1": { 645 "fontWeight": interactive_customSettings.text.button.em_h1.fontWeight 646 }, 647 "spc": { 648 "fontSize": interactive_customSettings.text.button.spc.fontSize, 649 "lineHeight": interactive_customSettings.text.button.spc.lineHeight 650 } 651}); 652 653// --------------------------------- Effects --------------------------------- // 654 // - Create a RevoltFX instance - // 655// var fx = new revolt.FX(); // - loaded via the script tag 656// 657// var rfxBundleSettings = interactive_customSettings.link.effects[0]; // - Replace with custom Link 658// var rfxSpritesheet = interactive_customSettings.link.effects[1]; // - Replace with custom Link 659// var additionalAssets = ['/images/interactiveGames/revolt/examples/assets/rfx-examples.json']; 660// 661// // - Load bundle files and the additional example spritesheet - // 662// fx.loadBundleFiles(rfxBundleSettings, rfxSpritesheet, null, additionalAssets).then(function (data) { 663// app.ticker.add(function () { 664// fx.update(); // - Update the RevoltFX instance 665// }); 666// 667// }).catch(function (err) { 668// console.log('Error', err); 669// }); 670 671// -------------------------------------------------------------------------- // 672// -------------------------------- ANCHOR LOADER ---------------------------------- // 673// -------------------------------------------------------------------------- //
674// --- Load Spritesheet and Main Function --- // 675PIXI.loader 676 .add('asset_ui', interactive_customSettings.link.asset_sheet[0]) 677 .add('asset_main', interactive_customSettings.link.asset_sheet[1]) 678 .add(interactive_customSettings.link.sound_sheet[0]) 679 .on('progress', loadProgressHandler) 680 .on('complete', loadCompleteHandler) 681 .load(main); 682 683// - Loading Animation - // 684var loadShield = { 685 loadSetup: function (loading) { 686 var oh_logo = new PIXI.Sprite.from('/images/interactiveGames/OH_logo.png'); 687 688 oh_logo.anchor.set(0.5,0.5); 689 oh_logo.position.set(250,180); 690 691 if (loading === true) { 692 oh_logo.visible = true; 693 } else { 694 oh_logo.visible = false; 695 } 696 697 var loading_shield = new PIXI.Graphics(); 698 loading_shield.beginFill(0xffffff); 699 loading_shield.drawRect(0, 0, 500, 500); 700 loading_shield.endFill(); 701 loading_shield.alpha = 0.9; 702 703 var loading_txt = new PIXI.Text('Loading', { 704 fontFamily: 'Roboto', 705 fontSize: 14, 706 fill: 0x5a57a1, 707 align: 'center', 708 fontWeight: '100' 709 }); 710 711 loading_txt.anchor.set(0.5, 0.5); 712 loading_txt.position.set(250, 270); 713 714 var loading_graphic = new PIXI.Graphics(); 715 loading_graphic.beginFill(0x5a57a1); 716 loading_graphic.drawRect(250, 250, 300, 5); 717 loading_graphic.endFill(); 718 719 var loading_graphicBorder = new PIXI.Graphics(); 720 loading_graphicBorder.lineStyle(1, 0xc5a57a1, 1, 1, false); 721 loading_graphicBorder.drawRect(-155, -7, 305, 8); 722 723 var loading_sprite = loading_graphic.generateCanvasTexture(1, 1); 724 725 var loadingSprite = new PIXI.Sprite(loading_sprite); 726 727 loadingSprite.anchor.set(0.5, 0.5); 728 loadingSprite.position.set(250, 250); 729 730 loading_graphic.x = (loadingContainer.width / 2) - (loading_graphic.width / 2); 731 loading_graphic.y = (loadingContainer.height / 2) - (loading_graphic.height / 2); 732 733 loading_graphicBorder.x = (loadingContainer.width / 2) - ((loading_graphicBorder.width / 2) - 3); 734 loading_graphicBorder.y = (loadingContainer.height / 2) - ((loading_graphicBorder.height / 2) - 3); 735 736 loadingContainer.addChild(loading_shield); 737 loadingContainer.addChild(loading_txt); 738 loadingContainer.addChild(loading_graphicBorder); 739 loadingContainer.addChild(loadingSprite); 740 loadingContainer.addChild(oh_logo); 741 742 var timeLine_loading = new TimelineMax({ 743 repeat: -1 744 }); 745 746 timeLine_loading 747 .to(loadingSprite, .5, { pixi: { width: 0 }, ease: Power2.easeInOut }) 748 .to(loadingSprite, .5, { pixi: { x: loadingSprite.x + 150 }, ease: Power2.easeInOut }, '-=.5') 749 .to(loadingSprite, 0, { pixi: { x: loadingSprite.x - 150 } }) 750 .to(loadingSprite, 1, { pixi: { x: loadingSprite.x - 150 } }) 751 .to(loadingSprite, .5, { pixi: { x: loadingSprite.x }, ease: Power2.easeInOut }) 752 .to(loadingSprite, .5, { pixi: { width: 300 }, ease: Power2.easeInOut }, '-=.5'); 753 754 loadingContainer.alpha = 0; 755 756 app.stage.addChild(loadingContainer); 757 758// stage_loader.addChild(loadShield.loadIn()); 759 760// app.stage.addChild(stage_loader); 761 }, 762 loadIn: function () { 763 TweenMax.to(loadingContainer, 0.5, { pixi: { alpha: 1 }}); 764 loadingContainer.visible = true; 765 }, 766 loadOut: function () { 767 TweenMax.to(loadingContainer, 0.5, { pixi: { alpha: 0 }}); 768 loadingContainer.visible = true; 769 } 770}; 771 772// - NOTE Convert Progress to Percent Loaded - // 773function convertPercentage(percent) { 774 var percentLoaded; 775 776 percentLoaded = canvas_width * (percent / 100); 777 778 return percentLoaded; 779} 780 781// - NOTE Progress Bar Handler - // 782function loadProgressHandler(loader, resource) { 783 stage_landing.visible = false; 784 stage_main.visible = false; 785 stage_win.visible = false; 786 stage_ui.visible = false; 787 788 loadShield.loadSetup(true); 789} 790 791// - NOTE Load Complete Handler - // 792function loadCompleteHandler() { 793 var id = setInterval(frame, 10); 794 795 function frame() { 796 clearInterval(id); 797 stage_landing.visible = true; 798 stage_main.visible = true; 799 stage_win.visible = true; 800 stage_ui.visible = true; 801 802 app.stage.removeChild(stage_loader); 803 } 804} 805 806// -------------------------------------------------------------------------- // 807// --------------------------- ANCHOR MAIN FUNCTION -------------------------------- // 808// -------------------------------------------------------------------------- // 809function main() { 810 // --- Get Spritesheet --- // 811 asset_ui = PIXI.loader.resources['asset_ui'].spritesheet; 812 asset_sheet = PIXI.loader.resources['asset_main'].spritesheet; 813 814 // --- Import Game Functions --- // 815// document.getElementById('insertGame').src = interactive_customSettings.link.game[0]; 816 var setup = document.getElementById('insertGame'); 817 var script = document.createElement('script'); 818 script.type = 'text/javascript'; 819 script.src = interactive_customSettings.link.game[0]; 820 setup.appendChild(script); 821 822 ui_upoints_txt.anchor.set(0.5,0); 823 824 // --- NOTE UI --- // 825 ui_upoints_txt.position.set(interactive_customSettings.ui.upoints_txt.position[0], interactive_customSettings.ui.upoints_txt.position[1]); 826 827 // --------- SNOTE et Scale (if needed) --------- // 828 win_ui_playmessage.width = 500; 829 830 // --------- NOTE Add Stages to App.Stage --------- // 831 app.stage.addChild(stage_ui); 832 app.stage.addChild(ui); 833 834 optionsSetup(); 835 wagersSetup(); 836} 837 838// -------------------------------------------------------------------------- // 839// --------------------------- ANCHOR SETUP FUNCTIONS ------------------------------ // 840// -------------------------------------------------------------------------- // 841// ---------------------------- NOTE Options Setup ----------------------------- // 842function optionsSetup() { 843 options_info_gfx = new PIXI.Sprite(asset_ui.textures['wagerscreen_background.png']); 844 options_info_gfx.position.set(0,0); 845 846 var options_btn = new PIXI.Sprite(asset_ui.textures['button.png']); 847 848 button_txt.anchor.set(0.5,0.5); 849 850 options_btn_container = new PIXI.Container; 851 options_btn_container.interactive = true; 852 options_btn_container.buttonMode = true; 853 854 button_txt.position.set(options_btn.width - (options_btn.width/2), options_btn.height - (options_btn.height/2)); 855 856 options_btn_container.addChild(options_btn); 857 options_btn_container.addChild(button_txt); 858 859 options_btn_container.position.set(60, 400); 860 861 alert_plate = new PIXI.Sprite(asset_ui.textures['wagerscreen_background.png']); 862 alert_plate.position.set(0,0); 863 864 // --- NOTE Asset Creation --- // 865 options_icon = new PIXI.Sprite(asset_ui.textures['settings.png']); 866 options_soundON = new PIXI.Sprite(asset_ui.textures['soundON.png']); 867 options_soundOFF = new PIXI.Sprite(asset_ui.textures['soundOFF.png']); 868 options_screenMIN = new PIXI.Sprite(asset_ui.textures['minScreen.png']); 869 options_screenMAX = new PIXI.Sprite(asset_ui.textures['maxScreen.png']); 870
871 // --------- NOTE Set XY --------- // 872 options_icon.position.set(interactive_customSettings.options.icon.position.start[0], interactive_customSettings.options.icon.position.start[1]); 873 options_soundON.position.set(interactive_customSettings.options.soundON.position.start[0], interactive_customSettings.options.soundON.position.start[1]); 874 options_soundOFF.position.set(interactive_customSettings.options.soundOFF.position.start[0], interactive_customSettings.options.soundOFF.position.start[1]); 875 options_screenMIN.position.set(interactive_customSettings.options.screenMIN.position.start[0], interactive_customSettings.options.screenMIN.position.start[1]); 876 options_screenMAX.position.set(interactive_customSettings.options.screenMAX.position.start[0], interactive_customSettings.options.screenMAX.position.start[1]); 877 options_info.position.set(interactive_customSettings.options.info.position.start[0], interactive_customSettings.options.info.position.start[1]); 878 options_info_txt.position.set(60, 60); 879 880 options_soundOFF.alpha = 0; 881 options_soundOFF.visible = false; 882 883 // --------- NOTE Make Buttons Interactive --------- // 884 options_icon.interactive = false; 885 options_icon.buttonMode = true; 886 887 options_soundON.interactive = false; 888 options_soundON.buttonMode = true; 889 890 options_soundOFF.interactive = false; 891 options_soundOFF.buttonMode = true; 892 893 options_screenMIN.interactive = true; 894 options_screenMIN.buttonMode = true; 895 896 options_screenMAX.interactive = true; 897 options_screenMAX.buttonMode = true; 898 899 options_icon.alpha = 0; 900 options_soundON.alpha = 0; 901 options_soundOFF.alpha = 0; 902 903 // --------- NOTE Add Stages to App.Stage --------- // 904 options_info.addChild(options_info_gfx); 905 options_info.addChild(options_info_txt); 906 options_info.addChild(options_btn_container); 907 908 stage_ui.addChild(landing_ui_wagers); 909 stage_ui.addChild(options_icon); 910 stage_ui.addChild(options_soundON); 911 stage_ui.addChild(options_soundOFF); 912 stage_ui.addChild(options_screenMIN); 913 stage_ui.addChild(options_screenMAX); 914 stage_ui.addChild(options_info); 915 916 // --------- NOTE Event Listeners --------- // 917 options_icon.on('pointerdown', function() {showSettings()}); 918 options_soundON.on('pointerdown', function() {soundToggle('off')}); 919 options_soundOFF.on('pointerdown', function() {soundToggle('on')}); 920} 921 922// ---------------------------- NOTE Wager Setup ----------------------------- // 923var wagerTiersBtns = [], 924 landing_ui_array = []; 925 926function getWagerTiers() { 927 var wagerArray = []; 928 929 wager_btn_background_gfx = new PIXI.Sprite(asset_ui.textures['wagerscreen_background.png']); 930 wager_btn_background_gfx.position.set(0,0); 931 932 for (var i = 0; i < interactive_basicSettings.basic.wagerTiers.length; i++) { 933 wagerArray.push(interactive_basicSettings.basic.wagerTiers[i]); 934 wagerArray.sort(function(a, b){return b - a}); 935 } 936 937 wagerArray.sort(function(a, b){return b - a}); 938 wagerArray.reverse(); 939 940 for (var i = 0; i < wagerArray.length; i++) { 941 var landing_wager_btn_txt = new MultiStyleText(wagerArray[i], { 942 "default": { 943 fontFamily: interactive_customSettings.text.landing_wager_btn1_txt.default.fontFamily, 944 fontSize: interactive_customSettings.text.landing_wager_btn1_txt.default.fontSize, 945 fill:interactive_customSettings.text.landing_wager_btn1_txt.default.fill, 946 align: interactive_customSettings.text.landing_wager_btn1_txt.default.align 947 } 948 }); 949 950 var wager_btn_gfx = new PIXI.Sprite(asset_ui.textures['wager_btn.png']); 951 952// var wager_btn_gfx = new PIXI.Graphics(); 953// wager_btn_gfx.beginFill(0x49c574); 954// wager_btn_gfx.drawRect(0, 0, 100, 100); 955// wager_btn_gfx.endFill(); 956// 957// var wager_btn_outline = new PIXI.Graphics(); 958// wager_btn_outline.lineStyle(2, 0x49c574, 1, 1, false); 959// wager_btn_outline.drawRect(0, 0, 100, 100); 960 961// var wager_shadow_gfx = new PIXI.Graphics(); 962// wager_shadow_gfx.beginFill(0x000000); 963// wager_shadow_gfx.drawRect(0, 0, 100, 100); 964// wager_shadow_gfx.endFill(); 965// wager_shadow_gfx.filters = [blurFilter]; 966 967 var wager_btn = { 968 landing_wager_btn_txt: landing_wager_btn_txt, 969// wager_btn_outline: wager_btn_outline, 970 wager_btn_gfx: wager_btn_gfx, 971// wager_shadow_gfx: wager_shadow_gfx 972 }; 973 974 975 landing_wager_btn_txt.anchor.set(0.5,0.5); 976 wager_btn.alpha = 0.9; 977 wagerTiersBtns.push(wager_btn); 978 } 979 980 for (var i = 0; i < wagerTiersBtns.length; i++) { 981 wagerTiersBtns[i].landing_wager_btn_txt.position.set(wagerTiersBtns[i].wager_btn_gfx.width - (wagerTiersBtns[i].wager_btn_gfx.width/2), wagerTiersBtns[i].wager_btn_gfx.height - (wagerTiersBtns[i].wager_btn_gfx.height/2)); 982 } 983 984 for (var i = 0; i < wagerTiersBtns.length; i++) { 985 wagerTiersBtns[i].wager_btn_gfx.interactive = true; 986 wagerTiersBtns[i].wager_btn_gfx.buttonMode = true; 987 } 988 989 landing_ui_array.push(landing_ui_wager_btn_1,landing_ui_wager_btn_2,landing_ui_wager_btn_3); 990 991 for (var i = 0; i < wagerTiersBtns.length; i++) { 992// landing_ui_array[i].addChild(wagerTiersBtns[i].wager_shadow_gfx); 993 landing_ui_array[i].addChild(wagerTiersBtns[i].wager_btn_gfx); 994// landing_ui_array[i].addChild(wagerTiersBtns[i].wager_btn_outline); 995 landing_ui_array[i].addChild(wagerTiersBtns[i].landing_wager_btn_txt); 996 } 997}; 998 999function wagersSetup() { 1000 if (!demo) { 1001 determine_wagers(); 1002 } 1003 1004 getWagerTiers(); 1005 1006 landing_ui_wagers.position.set(interactive_customSettings.landing.wager.position.start[0], interactive_customSettings.landing.wager.position.start[1]); 1007 landing_ui_wager_btn_1.position.set(interactive_customSettings.landing.wager_btn_1.position.start[0], interactive_customSettings.landing.wager_btn_1.position.start[1]); 1008 landing_ui_wager_btn_2.position.set(interactive_customSettings.landing.wager_btn_2.position.start[0], interactive_customSettings.landing.wager_btn_2.position.start[1]); 1009 landing_ui_wager_btn_3.position.set(interactive_customSettings.landing.wager_btn_3.position.start[0], interactive_customSettings.landing.wager_btn_3.position.start[1]); 1010 1011 landing_wager_message_txt.anchor.set(0.5, 0.5); 1012 landing_wager_message_txt.position.set(250,250); 1013 1014 // --------- NOTE Add Assets/UI to Containers --------- // 1015 landing_ui_wagers.addChild(wager_btn_background_gfx); 1016 landing_ui_wagers.addChild(ui_upoints_txt); 1017 1018 landing_ui_wagers.addChild(landing_wager_message_txt); 1019 landing_ui_wagers.addChild(landing_ui_wager_btn_1); 1020 landing_ui_wagers.addChild(landing_ui_wager_btn_2); 1021 landing_ui_wagers.addChild(landing_ui_wager_btn_3); 1022 1023 for (var i = 0; i < wagerTiersBtns.length; i++) { 1024 wagerTiersBtns[i].wager_btn_gfx.interactive = true; 1025 wagerTiersBtns[i].wager_btn_gfx.buttonMode = true; 1026 } 1027 1028 // --------------------------------- NOTE Wager Tier Event ----------------------------------- // 1029// for (var i = 0; i < wagerTiersBtns.length; i++) { 1030// wagerTiersBtns[i].wager_btn_gfx.on('mouseover', function(mouseData){ 1031//// TweenMax.to(wagerTiersBtns[i].wager_btn_outline, 0.25, { pixi: { width: 110, height: 110, x: -3, y: -3}}); 1032// }); 1033// 1034// wagerTiersBtns[i].wager_btn_gfx.on('mouseout', function(mouseData){ 1035//// TweenMax.to(wagerTiersBtns[i].wager_btn_outline, 0.25, { pixi: { width: 103, height: 103, x: 0, y: 0}}); 1036// }); 1037// 1038// wagerTiersBtns[i].wager_btn_gfx.on('pointerdown', function(){ 1039//// TweenMax.to(wagerTiersBtns[i].wager_btn_outline, 0.25, { pixi: { width: 115, height: 115, x: -6, y: -6}}); 1040// if (plays < 1) { 1041// showDirections(parseInt(wagerTiersBtns[i-1].landing_wager_btn_txt.text)); 1042// } else { 1043// wager_selected(parseInt(wagerTiersBtns[i-1].landing_wager_btn_txt.text)); 1044// } 1045// }); 1046// } 1047// app.stage.addChild(landing_wager_message_txt); 1048 1049 wagerTiersBtns[0].wager_btn_gfx.on('pointerdown', function(){ 1050 if (plays < 1) { 1051 showDirections(parseInt(wagerTiersBtns[0].landing_wager_btn_txt.text)); 1052 } else { 1053 wager_selected(parseInt(wagerTiersBtns[0].landing_wager_btn_txt.text)); 1054 } 1055 }); 1056 1057 if (wagerTiersBtns[1]) { 1058 wagerTiersBtns[1].wager_btn_gfx.on('pointerdown', function(){ 1059 if (plays < 1) { 1060 showDirections(parseInt(wagerTiersBtns[1].landing_wager_btn_txt.text)); 1061 } else { 1062 wager_selected(parseInt(wagerTiersBtns[1].landing_wager_btn_txt.text)); 1063 } 1064 }); 1065 } 1066 1067 if (wagerTiersBtns[2]) { 1068 wagerTiersBtns[2].wager_btn_gfx.on('pointerdown', function(){ 1069 if (plays < 1) { 1070 1071 showDirections(parseInt(wagerTiersBtns[2].landing_wager_btn_txt.text)); 1072 } else { 1073 wager_selected(parseInt(wagerTiersBtns[2].landing_wager_btn_txt.text)); 1074 } 1075 }); 1076 } 1077 1078 if (document.getElementById('playCanvas')) { 1079 setTimeout(function() { 1080 document.getElementById('loadIMG').style.display = 'none'; 1081 document.getElementById('playCanvas').style.display = 'block'; 1082 }, 1000); 1083 } else { 1084 setTimeout(function() { 1085 document.getElementById('loadIMG').style.display = 'none'; 1086 app.view.style.display = 'block'; 1087 }, 1000); 1088 } 1089} 1090 1091 1092// ----------------------------------------------------------------------------------------------------------------------- // 1093// -------------------------------------------------- ANCHOR STANDARD FUNCTIONS ------------------------------------------------- // 1094// ----------------------------------------------------------------------------------------------------------------------- // 1095var plays = 0, 1096 musicPlaying = 0; 1097 1098function pressPlay() { 1099 animations.wager.in[interactive_customSettings.animations.wager.in](); 1100} 1101 1102// ---------------------------- NOTE Add Commas ----------------------------- // 1103function numberWithCommas(x) { 1104 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); 1105} 1106 1107// ---------------------------- NOTE 50/50 Chance ----------------------------- // 1108function coinflip() { 1109 var win = Math.floor(Math.random() * 100); 1110 1111 if (win < 50) { 1112 return true; 1113 } else { return false;} 1114} 1115 1116// ---------------------------- NOTE Execute when User Chooses Wager ----------------------------- // 1117function wager_selected(num) { 1118 playing = true; 1119 plays++; 1120 1121 musicPlaying++; 1122 1123 if (musicPlaying < 2) { 1124 sound.play({ 1125 isLoaded: true, 1126 sprite: 'music', 1127 volume: 0.5, 1128 loop: true 1129 }); 1130 } 1131 1132 1133 1134 if (!demo) { 1135 sendRequest(num); 1136 for (var i = 0; i < wagerTiersBtns.length; i++) { 1137 loadShield.loadIn(); 1138 wagerTiersBtns[i].wager_btn_gfx.interactive = false;
1139 wagerTiersBtns[i].wager_btn_gfx.buttonMode = false; 1140 } 1141 } else { 1142 var flip = Math.floor(Math.random() * 4); 1143 1144 if (flip < 2) { 1145 winner = false; 1146 } else { 1147 winner = true; 1148 } 1149 1150 message_text = 'Another demo play!' 1151 1152 animations.wager.out[interactive_customSettings.animations.wager.out](); 1153 animations.landing.out[interactive_customSettings.animations.landing.out](); 1154 animations.play.in[interactive_customSettings.animations.play.in](); 1155 1156 1157 for (var i = 0; i < main_active_objs.length; i++) { 1158 main_active_objs[i].interactive = true; 1159 main_active_objs[i].buttonMode = true; 1160 } 1161 1162 // createResults(); 1163 } 1164} 1165 1166function play_wager(num) { 1167 var currentWager = num; 1168 1169 1170 animations.wager.out[interactive_customSettings.animations.wager.out](); 1171 animations.landing.out[interactive_customSettings.animations.landing.out](); 1172 animations.play.in[interactive_customSettings.animations.play.in](); 1173} 1174 1175// ----------------------------------------------------------------------------------------------------------------------- // 1176// ------------------------------------------------------- ANCHOR SETTINGS ------------------------------------------------------ // 1177// ----------------------------------------------------------------------------------------------------------------------- // 1178// ---------------------------- NOTE Show Settings ----------------------------- // 1179function showSettings() { 1180 TweenMax.to(options_info, .5, { pixi: {x: interactive_customSettings.options.info.position.end[0], y: interactive_customSettings.options.info.position.end[1]}}); 1181} 1182 1183// ---------------------------- NOTE Sound Toggle ----------------------------- // 1184function soundToggle(setting) { 1185 var soundTime = new TimelineMax(); 1186 if (setting === 'off') { 1187 soundTime 1188 .to(options_soundON, .5, { pixi: {alpha: 0, visible: false}, ease:Power2.easeIn}) 1189 .to(options_soundOFF, .5, { pixi: {alpha: 1, visible: true}, ease:Power2.easeOut}); 1190 PIXI.sound.toggleMuteAll(); 1191 } else { 1192 soundTime 1193 .to(options_soundOFF, .5, { pixi: {alpha: 0, visible: false}, ease:Power2.easeIn}) 1194 .to(options_soundON, .5, { pixi: {alpha: 1, visible: true}, ease:Power2.easeOut}); 1195 PIXI.sound.toggleMuteAll(); 1196 } 1197 1198 options_sound = !options_sound; 1199} 1200 1201// ---------------------------- NOTE Screen Width ----------------------------- // 1202function set_width() { 1203 if (window.innerWidth < interactive_basicSettings.basic.canvasElement.width) { 1204 app.view.style.width = (window.innerWidth - 45) + 'px'; 1205 app.view.style.height =( window.innerWidth - 45) + 'px'; 1206 } 1207} 1208 1209// ---------------------------- NOTE Show Directions ----------------------------- // 1210function showDirections(num) { 1211 TweenMax.to(options_info, .5, { pixi: { y: 0}}); 1212 options_info_gfx.interactive = true; 1213// main_auto_btn.interactive = false; 1214// musicPlaying++; 1215 1216// if (musicPlaying < 2) { 1217// sound.play({ 1218// isLoaded: true, 1219// sprite: 'music', 1220// volume: 0.1, 1221// loop: true 1222// }); 1223// } 1224 1225 for (var i = 0; i < wagerTiersBtns.length; i++) { 1226 loadShield.loadIn(); 1227 wagerTiersBtns[i].wager_btn_gfx.interactive = false; 1228 wagerTiersBtns[i].wager_btn_gfx.buttonMode = false; 1229 } 1230 1231 options_icon.interactive = false; 1232 animations.wager.out[interactive_customSettings.animations.wager.out](); 1233 options_btn_container.on('pointerdown', function() { 1234 TweenMax.to(options_info, .5, { pixi: { y: -500}}); 1235 options_info.interactive = false; 1236 // main_auto_btn.interactive = false; 1237 1238 if (playing === false) { 1239 wager_selected(num); 1240 } 1241 1242 options_icon.interactive = true; 1243 }); 1244} 1245 1246// ---------------------------- NOTE Replay ----------------------------- // 1247function reset() { 1248 playing = false; 1249 1250 animations.win.out[interactive_customSettings.animations.win.out](); 1251 1252 setTimeout(function() { 1253 for (var i = 0; i < wagerTiersBtns.length; i++) { 1254 wagerTiersBtns[i].wager_btn_gfx.interactive = true; 1255 wagerTiersBtns[i].wager_btn_gfx.buttonMode = true; 1256 } 1257 1258 1259 1260 pressPlay(); 1261 }, 1000); 1262 1263} 1264 1265// ----------------------------------------------------------------------------------------------------------------------- // 1266// ------------------------------------------------------ ANCHOR Win Function ---------------------------------------------------- // 1267// ----------------------------------------------------------------------------------------------------------------------- // 1268 1269function win() { 1270 // main_auto_btn.interactive = false;
1271 win_currentwon_txt.visible = false; 1272// win_currentwon_txt.text = interactive_customSettings.text.win_currentwon_txt.text; 1273 1274 if (winner === true) { 1275 animations.win.in[interactive_customSettings.animations.win.in](); 1276 1277 setTimeout(function() { 1278 animations.win.win[interactive_customSettings.animations.win.win](); 1279 }, 1000); 1280 } else { 1281 animations.win.in[interactive_customSettings.animations.win.in](); 1282 1283 setTimeout(function() { 1284 animations.win.loss[interactive_customSettings.animations.win.loss](); 1285 }, 1000); 1286 } 1287} 1288 1289// ----------------------------------------------------------------------------------------------------------------------- // 1290// --------------------------------------------------------- ANCHOR Alert ------------------------------------------------------- // 1291// ----------------------------------------------------------------------------------------------------------------------- // 1292 1293var alert = { 1294 alert_setup: function() { 1295 alert_btn = new PIXI.Sprite(asset_ui.textures['button.png']); 1296 alert_btn.interactive = true; 1297 alert_btn.buttonMode = true; 1298 1299 alertContainer.alpha = 0; 1300 1301 alert_btn.on('mouseover', function() { 1302 }); 1303 }, 1304 alertIn: function(text) { 1305 var alert_continue_txt = new MultiStyleText(interactive_customSettings.text.button.text, { 1306 "default": { 1307 "fontFamily": interactive_customSettings.text.button.default.fontFamily, 1308 "fontSize": interactive_customSettings.text.button.default.fontSize, 1309 "fontWeight": interactive_customSettings.text.button.default.fontWeight, 1310 "fill": interactive_customSettings.text.button.default.fill, 1311 "align": interactive_customSettings.text.button.default.align 1312 }, 1313 "h1": { 1314 "fontFamily": interactive_customSettings.text.button.h1.fontFamily, 1315 "fontSize": interactive_customSettings.text.button.h1.fontSize, 1316 "fontWeight": interactive_customSettings.text.button.h1.fontWeight, 1317 "fill": interactive_customSettings.text.button.h1.fill, 1318 "align": interactive_customSettings.text.button.h1.align 1319 }, 1320 "strong": { 1321 "fontWeight": interactive_customSettings.text.button.strong.fontWeight 1322 }, 1323 "em_default": { 1324 "fontWeight": interactive_customSettings.text.button.em_default.fontWeight 1325 }, 1326 "em_h1": { 1327 "fontWeight": interactive_customSettings.text.button.em_h1.fontWeight 1328 } 1329 }); 1330 1331 alert_continue_txt.anchor.set(0.5,0.5); 1332 1333 alert_txt.text = '<h1>' + text + '</h1>'; 1334 1335 alert_txt.x = 60; 1336 alert_txt.y = 40; 1337 1338 alert_btn.x = 60; 1339 alert_btn.y = 400; 1340 1341 alert_continue_txt.x = alert_btn.x + (alert_btn.width / 2); 1342 alert_continue_txt.y = alert_btn.y + (alert_btn.height / 2); 1343 1344 alert_txt.alpha = 1; 1345 alert_txt.visible = true; 1346 1347 alertContainer.addChild(alert_plate); 1348 alertContainer.addChild(alert_txt); 1349 alertContainer.addChild(alert_btn); 1350 alertContainer.addChild(alert_continue_txt); 1351 1352 alertContainer.y = 0; 1353 1354 alert_btn.on('pointerdown', function() {alert.alertOut();loadShield.loadOut();}); 1355 1356 var alertTween = new TimelineMax(); 1357 1358 app.stage.addChild(alertContainer); 1359 1360 alertContainer.y = 0; 1361 1362 alertTween 1363 .to(alertContainer, 0, { pixi: {visible: true}}) 1364 .to(alertContainer, .5, { pixi: {alpha: 1}}); 1365 }, 1366 alertOut: function() { 1367 for (var i = 0; i < wagerTiersBtns.length; i++) { 1368 wagerTiersBtns[i].wager_btn_gfx.interactive = true; 1369 wagerTiersBtns[i].wager_btn_gfx.buttonMode = true; 1370 } 1371 1372 animations.wager.in[interactive_customSettings.animations.wager.in](); 1373 var alertTween = new TimelineMax(); 1374 1375 alertTween 1376 .to(alertContainer, .5, { pixi: {alpha: 0}}) 1377 .to(alertContainer, .5, { pixi: {y: alertContainer.y}}, '-=.5') 1378 .to(alertContainer, 0, { pixi: {visible: false}}); 1379 } 1380}; 1381 1382// ----------------------------------------------------------------------------------------------------------------------- // 1383// ------------------------------------------------- ANCHOR 8BIT FUNCTIONS ----------------------------------------------- // 1384// ----------------------------------------------------------------------------------------------------------------------- // 1385let interactionButtonArray = []; 1386 1387// gameState keeps track of the number of interactions in the game, the current state array, and the current option (animation) the user has chosen 1388let gameState = { 1389 interactions: 0, // The number of interactions for this game 1390 previousState: '', 1391 currentState: '', 1392 previousChoice: '', 1393 currentChoice: '' 1394}; 1395 1396let gameEnd = { 1397 choice: 0 1398} 1399 1400let optionContainers = []; 1401 1402function setState(section) { 1403 1404} 1405 1406function playState(state, num) { 1407// Plays an animation based on the current state and what the player chose 1408// - interactive_customSettings.animations.state is an array with the different states 1409// -- Each index of the array is another array with the that points to the animation chosen by the player 1410 if (winner === false) { 1411 if (coinflip === false) { 1412 animations.play.state[interactive_customSettings.animations.play.stateLoss[state[num]
1412]](); 1413 } 1414 } else { 1415 animations.play.state[interactive_customSettings.animations.play.state[state[num]]](); 1416 } 1417} 1418 1419function updateGamestate(state, choice) { 1420 gameState.previousState = gameState.currentState; 1421 gameState.currentState = state; 1422 gameState.previousChoice = gameState.currentChoice; 1423 gameState.currentChoice = choice; 1424} 1425 1426function handleOutcome() { 1427 let outcomeEvent = Math.floor(Math.random() * animations.play.outcome[gameEnd.choice].loss.length); 1428 1429 winner === true ? animations.play.outcome[gameEnd.choice].win() : animations.play.outcome[gameEnd.choice].loss[outcomeEvent](); 1430} 1431 1432function stateButtonSetup() { 1433 let states = interactive_customSettings.animations.state, 1434 player_options = 0; 1435 1436 for (let i = 0; i < states.length; i++) { 1437 if (states[i].active === true) { 1438 let stateContainer = new PIXI.Container(); 1439 1440 for(let o = 0; o < states[i].options.length; o++) { 1441 if (states[i].options[o].active === true) { 1442 for(let b = 0; b < 3; b++) { 1443 let playerOptionContainer = new PIXI.Container(); 1444 gameState.interactions++; 1445 player_options++; 1446 let playerOption = new PIXI.Sprite(asset_sheet.textures['playerChoiceButton' + player_options + '.png']); 1447 playerOptionContainer.addChild(playerOption); 1448 playerOption.buttonMode = true; 1449 stateContainer.addChild(playerOptionContainer); 1450 } 1451 } 1452 } 1453 1454 optionContainers.push(stateContainer); 1455 1456 createRollovers(); 1457 } 1458 } 1459} 1460 1461// Begin by playing an animation (could be looping) on screen. The user then chooses an interatction from 1 of 3 buttons. 1462// -- The game may have up to 4 of these interactions 1463// --- After each interaction, update the "gameState" object to reflect the current state of the game. 1464// ---- The 'gameState' object records how many interactions a game has, what interaction the player is currently on, and what the current "state" was just played. 1465// -- On the final interaction play the animation that matches the current state and the proper win/loss condition from that state.
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.