private void Awake() { Instance = this; Application.targetFrameRate = 30; DontDestroyOnLoad(gameObject); gameObject.AddComponent <Loom>(); }
public override void MatchedTilesAsBonus(GameDriver driver, TileType matchedType) { if (Random.Range(0, 100) <= bonusChance) { driver.AddStats(matchedType, 3, matchedType); driver.AddBonus(type); } }
public static List <Toy> Perform(GameDriver driver) { Log.Debug("Loading: Toys"); var toysFolder = DataPath.Get("Toys"); var toyFiles = Directory.GetFiles(toysFolder); var toys = new List <Toy>(); foreach (var toyFile in toyFiles) { var toy = JsonData.DeserializeFromFile <Toy>(toyFile); toy.Active = false; toy.Name = Path.GetFileNameWithoutExtension(toyFile); foreach (var damage in toy.DamagePoints) { damage.Active = true; } if (driver.CurrentToy != null && toy.Name == driver.CurrentToy.Name) { toy.Active = true; driver.CurrentToy = toy; } toys.Add(toy); } return(toys); }
// //Call this from the cube when placement is cancelled // public static void cancelPlaceCube() { GameObject.Destroy(gameDriver.cubeSelected); gameDriver.cubeSelected = null; StateMachine.isPlacingCube = false; GameDriver.selectLightOff(); }
//////////////////Static stuff for calling easily from outside////////////////////////////////// // //Call this from the cube when it is placed // public static void placedCube() { if (gameDriver.addPlayerPoints(StateMachine.currentTurn(), gameDriver.cubeSelected.GetComponent <UnitClass>().cost) == -1) { print("Something went wrong with the player point counts!"); } gameDriver.cubesInPlay.Add(gameDriver.cubeSelected); if (gameDriver.cubeSelected.GetComponent <UnitClass>().unitClass == className.King) { if (StateMachine.currentTurn() == 1) { StateMachine.p1KingPlaced(); } else if (StateMachine.currentTurn() == 2) { StateMachine.p2KingPlaced(); } else { print("That king was placed on no particular player's turn!"); } } gameDriver.cubeSelected = null; StateMachine.isPlacingCube = false; GameDriver.updatePointInterface(); StateMachine.passTurn(); }
//Constructor-MainPage public MainPage() { this.InitializeComponent(); _GameDriver = new GameDriver(CanvasPlayingArea, btnPauseGame, btnResumeGame, btnStartNewgame, btnSaveFile, btnLoadFile, _IsGameLoaded, GaneOverContentDialog, YouWinContentDialog, PauseContentDialog, txtLifesLeft); //Initialize GameDriver and pass OUR Canvas, and BUTTONS to it so we can use them in GameDriver.cs Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; //Register the KeyDown Event with a CoreWindow_KeyDown Method SetButtonsToNewGameState(); //Start button state }
//Dealing with Healer interactions public static void healerActivated() { gameDriver.healerPoints = 0; GameDriver.showHealerInterface(); StateMachine.healerPhase(); updateHealerInterface(); }
private void TidesOfMadnessForm_Load(object sender, EventArgs e) { driver = new GameDriver(); driver.InitializeGame(); UpdateGameLog(driver.GetGameLog()); UpdateScoreDisplays(); pbxCardImage.SizeMode = PictureBoxSizeMode.StretchImage; lbxHumanHand.DataSource = driver.GetHumanPlayer().GetCardsInHand(); lbxHumanHand.DisplayMember = "CardNameDisplay"; lbxHumanInPlay.DataSource = driver.GetHumanPlayer().GetCardsInPlay(); lbxHumanInPlay.DisplayMember = "CardNameDisplay"; lbxOppInPlay.DataSource = driver.GetAIPlayer().GetCardsInPlay(); lbxOppInPlay.DisplayMember = "CardNameDisplay"; lbxDiscardPile.DataSource = driver.GameState.DiscardPile.CardsInCollection; lbxDiscardPile.DisplayMember = "CardNameDisplay"; pbxCardImage.ImageLocation = SetArtFromListBox(lbxHumanHand, 0); UpdatePlayerInstructions(driver.GetCurrentGameState(), lblPlayerInstructions); UpdateUISettings(driver.GetCurrentGameState()); }
public static GameInterface Initialize(GameDriver driver) { Log.Message("Initializing: Game Interface"); var path = DataPath.Get("UI\\GameUI.json"); return(JsonData.DeserializeFromFile <GameInterface>(path)); }
//TODO: Add messages for each condition., rearrange conditions void OnMouseDown() { if ((StateMachine.turnState != Turn.pause) && (StateMachine.getPhase() == GamePhase.battle) && (playState == PlayState.idle) && (!StateMachine.isCubeLaunched) && (StateMachine.currentTurn() == unit.owner)) { //Check for special units if (unit.unitClass == className.Healer) { GameDriver.healerActivated(); GameDriver.removeCubeFromPlay(this.gameObject); } //Slect normal cube to flick else if ((flick == false) && (stun == false)) { hitPos = this.gameObject.transform.position; launcherY = this.gameObject.transform.position.y; maxHitPosY = hitPos.y + this.gameObject.GetComponent <Renderer> ().bounds.extents.y; minHitPosY = hitPos.y - this.gameObject.GetComponent <Renderer> ().bounds.extents.y; maxlauncherY = maxHitPosY + this.gameObject.GetComponent <Renderer> ().bounds.extents.y; minlauncherY = minHitPosY - this.gameObject.GetComponent <Renderer> ().bounds.extents.y; isKinematic = true; UpdatelaunchVelocity(); LaunchLine.launchLine.Enabled(true); GameDriver.selectLightOn(this.gameObject); changeToAiming = true; //playState = PlayState.aiming; } } }
void OnCollisionEnter(Collision other) { if (unit.unitClass == className.Paralyze) { if (other.gameObject.GetComponent <Cube>() != null) { if (other.gameObject.GetComponent <UnitClass> ().owningPlayer != unit.owningPlayer && unit.unitClass != className.Paralyze) { other.gameObject.GetComponent <Cube>().stunned = true; } } } else if (unit.unitClass == className.Bomb && StateMachine.gamePhase == GamePhase.battle) { Collider[] explosionHit = Physics.OverlapSphere(this.gameObject.transform.position, GetComponent <UnitClass>().attack); foreach (Collider hit in explosionHit) { if (hit.gameObject.GetComponent <Rigidbody>() != null) { hit.gameObject.GetComponent <Rigidbody>().AddExplosionForce(GetComponent <UnitClass>().attack *250, this.gameObject.transform.position, GetComponent <UnitClass>().attack); } } GameDriver.checkCubeMovement(); GameDriver.removeCubeFromPlay(this.gameObject); } }
public static void Initialize(GameDriver driver) { _driver = driver; _font = driver.Content.Load <SpriteFont>("Fonts/DebugFont"); _spriteBatch = new SpriteBatch(driver.GraphicsDevice); _driver.Window.Title = "The Toymaker"; }
public static void Perform(GameDriver driver) { if (KeyInput.JustPressed(Keys.Escape)) { driver.Exit(); } }
protected override void OnConnected(Client client) { var state = new GameState(); var me = new InteractivePlayer(Name, state); var driver= new GameDriver(me, state, client); while (driver.Dispatch(client.ReadLine())) ; }
public static PaintingKit Perform(GameDriver driver) { Log.Debug("Loading: Painting Kit"); var elementsFolder = DataPath.Get("Elements"); var path = Path.Combine(elementsFolder, "PaintingKit.json"); return(JsonData.DeserializeFromFile <PaintingKit>(path)); }
public static DeskClock Perform(GameDriver driver) { Log.Debug("Loading: Desk Clock"); var elementsFolder = DataPath.Get("Elements"); var path = Path.Combine(elementsFolder, "DeskClock.json"); return(JsonData.DeserializeFromFile <DeskClock>(path)); }
public static void endSetup() { foreach (GameObject obj in gameDriver.setupInterfaceObjects) { obj.SetActive(false); } GameDriver.startBattle(); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag.Equals("Cube")) { GameDriver.removeCubeFromPlay(collision.gameObject); GameDriver.checkCubeMovement(); } }
public static void initiateTurns() { if (state == GameState.active) { turnState = Turn.player1; GameDriver.updateTurnInterface(); } }
public static void endSetup() { GameDriver.hidePointHider(); GameDriver.hideSetupHider(); GameDriver.hideSetupInterface(); GameDriver.hidePointInterface(); GameDriver.startBattle(); }
public void TestInvalidInputException() { var file = "InvalidInput.txt"; string[] inputs = inputReader.ReadInput(file); GameDriver gameDriver = new GameDriver(logger); gameDriver.ValidateInputs(inputs); }
public static void Perform(GameDriver driver) { if (!KeyInput.JustPressed(Keys.F1)) { return; } driver.GameInterface = GameInterface.Initialize(driver); }
public void Play_WontPlayIfAlreadyFinished() { var game = new Mock<IDartsGame>(); game.Setup(g => g.Finished).Returns(true); var gameDriver = new GameDriver(game.Object); gameDriver.Play(); game.Verify(g => g.PlayNextTurn(), Times.Never); }
public SysDriver(FantasyConsole fc) { _fc = fc; _drivers = new List <Driver>(); _drivers.Add(FS = new FileSystemDriver()); _drivers.Add(Input = new InputDriver(_fc.Mem.InputBuffer)); _drivers.Add(Console = new ConsoleDriver(_fc.Mem.TextBuffer)); _drivers.Add(Graphics = new GraphicsDriver(_fc.Mem)); _drivers.Add(Menu = new MenuDriver(Input, Console)); _drivers.Add(Game = new GameDriver(this, _fc.Mem)); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag.Equals("Cube")) { if (collision.gameObject.GetComponent <Cube> ().playState == PlayState.launch && collision.gameObject.GetComponent <UnitClass>().unitClass != className.King) { GameDriver.checkCubeMovement(); } GameDriver.removeCubeFromPlay(collision.gameObject); } }
private void Awake() { DontDestroyOnLoad(this.gameObject); if (gd == null) { gd = this; } else if (gd != this) { Destroy(this.gameObject); } }
protected override void OnConnected(Client client) { var state = new GameState(); var me = new RandomPlayer(Name, state); var driver= new GameDriver(me, state, client); while (driver.Dispatch(client.ReadLine())) ; Console.WriteLine(); Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); }
public static void Perform(GameDriver driver) { var currentToy = driver.CurrentToy; if (!currentToy.IsFixed) { return; } HandleHotspotInteraction.SendCurrentToolToStart(); driver.ChangeState(GameState.ClientPayment); }
public override void AddStatsAsBonus(GameDriver driver, TileType statsType, float amount, TileType primaryType) { if (primaryType == TileType.None) { return; // this was an cascading or auto-match, ignore it } float now = driver.GetTime(); if (lastMatch != Mathf.Infinity && now - lastMatch < bonusThreshold) { driver.AddBonus(type, bonusAmount); } lastMatch = now; return; }
public void TestGameDraw() { var file = "Input3.txt"; string[] input = inputReader.ReadInput(file); GameDriver gameDriver = new GameDriver(logger); gameDriver.Start(input); string winner = "None"; Assert.AreEqual(winner, gameDriver.Winner); }
public static DeskClock Initialize(GameDriver driver) { var path = DataPath.Get("Elements\\DeskClock.json"); var clock = JsonData.DeserializeFromFile <DeskClock>(path); clock.Hour = 8; clock.Minute = 0; clock.MinuteHandTransform.Angle = 0.0f; clock.HourHandTransform.Angle = 240.0f; clock._minuteAngle = 0.0f; return(clock); }
public GameEntry() : base() { m_DriverObject = new GameObject("GameDriver"); GameObject.DontDestroyOnLoad(m_DriverObject); GameDriver driverComp = m_DriverObject.AddComponent <GameDriver>(); driverComp.Init(this); m_FrameWorkEntry = new FrameWorkEntry(); IsEditor = true; Init(); }
public override void UpdateAsBonus(GameDriver driver) { // each second after a match, has bonusChance to automatch if (driver.board.IsNewIdleSecond && Random.Range(0, 100) < bonusChance) { PairInt position, direction; if (driver.board.FindMatch(out position, out direction)) { driver.board.SwapTile(position, direction, false); driver.board.CreateHintOneShot(position, direction, hintArrowRobot); driver.AddBonus(type); } } }
public void Play_KeepsPlayingTurnUntilGameIsFinished() { var game = new Mock<IDartsGame>(); game.SetupSequence(g => g.Finished) .Returns(false) .Returns(false) .Returns(true); var gameDriver = new GameDriver(game.Object); gameDriver.Play(); game.Verify(g => g.PlayNextTurn(), Times.Exactly(2)); }
public static void battlePhase() { if (state == GameState.active) { gamePhase = GamePhase.battle; GameDriver.gameDriver.p1Side.SetActive(false); GameDriver.gameDriver.p2Side.SetActive(false); if ((flickableCubesAvailable(1) == 0) && (flickableCubesAvailable(2) == 0)) { GameDriver.resolveStalemate(); } } }
//场景功能 #region #endregion GameCtrl() { //CenceCtroler = new CenceCtrl(); GameObject modelCtrler = Resources.Load("Prefab\\Base\\GameControler") as GameObject; if (modelCtrler != null) { GameObject driverObj = GameObject.Instantiate(modelCtrler); _GameDriver = driverObj.GetComponent <GameDriver>(); _Pool = driverObj.GetComponent <SpawnPool>(); } //_SceneMgr = SceneMgr.Mgr; }
private static void SearchForGrabbed(GameDriver driver) { if (!MouseInput.LeftButtonJustPressed) { return; } foreach (var hotspot in driver.HotSpots) { var transform = hotspot.Transform; if (!IsGrabbed(transform)) { continue; } Grab(transform, null, $"Hotspot: {hotspot.Name}"); return; } foreach (var toy in driver.Toys) { foreach (var damagePoint in toy.DamagePoints) { var transform = damagePoint.Transform; if (!IsGrabbed(damagePoint.GetGlobalTransform())) { continue; } Grab(transform, GameDriver.Instance.GameInterface.ToyLocationInFront, $"DamagePoint: {damagePoint.Type}"); return; } } if (IsGrabbed(driver.Clock.HourHandTransform)) { Grab(driver.Clock.HourHandTransform, null, "Clock: Hour Hand"); } else if (IsGrabbed(driver.Clock.MinuteHandTransform)) { Grab(driver.Clock.MinuteHandTransform, null, "Clock: Minute Hand"); } else if (IsGrabbed(driver.SewingKit.Transform)) { Grab(driver.SewingKit.Transform, null, "SewingKit"); } else if (IsGrabbed(driver.PaintingKit.Transform)) { Grab(driver.PaintingKit.Transform, null, "PaintingKit"); } }
public void ADarts301GameCanBePlayed() { var playerAMockThrower = new Mock<IDartsThrower>(); playerAMockThrower.SetupSequence(dt => dt.ThrowDart()).Returns(60).Returns(60).Returns(60).Returns(60).Returns(60).Returns(1); var playerBMockThrower = new Mock<IDartsThrower>(); playerBMockThrower.Setup(dt => dt.ThrowDart()).Returns(20); var game = new Darts301Game( new DartsPlayer(playerAMockThrower.Object), new DartsPlayer(playerBMockThrower.Object)); var gameDriver = new GameDriver(game); gameDriver.Play(); Assert.True(game.Finished); Assert.Equal(game.Winner, game.Players.First()); }
public override void MatchedTilesAsBonus(GameDriver driver, TileType matchedType) { if (driver.GetCurrentAntiStreak() >= 4) { driver.AddBonus(type, bonusAmount); } }
int load_datafile_text(GameDriver drv, ref string buffer, int bufsize, tDatafileIndex[] idx, string tag) { throw new Exception(); }
public virtual void UpdateAsBonus(GameDriver driver) { }
void Start() { if(instance != null) { Destroy(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); if(currentLevel == null) { currentLevel = GameConfig.instance.levels[0]; } InitLevel(); }
public virtual void AddStatsAsBonus(GameDriver driver, TileType statsType, float amount, TileType primaryType) { }
public virtual void MatchedTilesAsBonus(GameDriver driver, TileType matchedType) { }
// Use this for initialization void Start() { health = maxHealth; beats = new List<GameObject>(); markPosition = transform.Find("PulseMark").transform.localPosition.x; bgMat = transform.Find("PulseBackground").GetComponent<LineRenderer>().material; gameState = GameObject.Find("GameState").GetComponent<GameState>(); gameDriver = GameObject.Find("GameDriver").GetComponent<GameDriver>(); tm = GameObject.Find("TypeMaster").GetComponent<TypeMaster>(); heart = GameObject.Find("Heart"); if (gameState.gameConfig != null) beatDelay = 60f / gameState.gameConfig.rate; }
public override void UpdateAsBonus(GameDriver driver) { if (driver.board.HandleHint(hintCooldown, hintArrowHoly)) { driver.AddBonus(type); } }
bool load_driver_history(GameDriver drv, ref string buffer) { bool history = false, mameinfo = false; int err; buffer = ""; if (history_filename == null) history_filename = "history.dat"; /* try to open history datafile */ if (ParseOpen(history_filename)) { /* create index if necessary */ if (hist_idx != null) history = true; else history = (index_datafile(ref hist_idx) != 0); /* load history text */ if (hist_idx != null) { GameDriver gdrv = drv; do { err = load_datafile_text(gdrv, ref buffer, bufsize, hist_idx, DATAFILE_TAG_BIO); gdrv = gdrv.clone_of; } while (err != 0 && gdrv != null); if (err != 0) history = false; } ParseClose(); } if (mameinfo_filename == null) mameinfo_filename = "mameinfo.dat"; /* try to open mameinfo datafile */ if (ParseOpen(mameinfo_filename)) { /* create index if necessary */ if (mame_idx != null) mameinfo = true; else mameinfo = (index_datafile(ref mame_idx) != 0); /* load informational text (append) */ if (mame_idx != null) { int len = buffer.Length; GameDriver gdrv = drv; gdrv = drv; do { err = load_datafile_text(gdrv, ref buffer, bufsize - len, mame_idx, DATAFILE_TAG_MAME); gdrv = gdrv.clone_of; } while (err != 0 && gdrv != null); if (err != 0) mameinfo = false; } ParseClose(); } return (history == false && mameinfo == false); }
// Use this for initialization void Start() { driver = GameObject.Find("GameDriver").GetComponent<GameDriver>(); squareMask = 1 << LayerMask.NameToLayer("Square"); selection = transform.FindChild("Selection").gameObject; selection.SetActive(false); InitBoard(); }
int run_game(string game) { int err; Machine.gamedrv = gamedrv = GetDriver(game); Machine.drv = drv = gamedrv.drv; /* copy configuration */ if (options.color_depth == 16 || (options.color_depth != 8 && (Machine.gamedrv.flags & GAME_REQUIRES_16BIT) != 0)) Machine.color_depth = 16; else Machine.color_depth = 8; Machine.sample_rate = options.samplerate; /* get orientation right */ Machine.orientation = (int)(gamedrv.flags & ORIENTATION_MASK); Machine.ui_orientation = ROT0; if (options.norotate) Machine.orientation = ROT0; if (options.ror) { /* if only one of the components is inverted, switch them */ if ((Machine.orientation & ROT180) == ORIENTATION_FLIP_X || (Machine.orientation & ROT180) == ORIENTATION_FLIP_Y) Machine.orientation ^= ROT180; Machine.orientation ^= ROT90; /* if only one of the components is inverted, switch them */ if ((Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_X || (Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_Y) Machine.ui_orientation ^= ROT180; Machine.ui_orientation ^= ROT90; } if (options.rol) { /* if only one of the components is inverted, switch them */ if ((Machine.orientation & ROT180) == ORIENTATION_FLIP_X || (Machine.orientation & ROT180) == ORIENTATION_FLIP_Y) Machine.orientation ^= ROT180; Machine.orientation ^= ROT270; /* if only one of the components is inverted, switch them */ if ((Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_X || (Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_Y) Machine.ui_orientation ^= ROT180; Machine.ui_orientation ^= ROT270; } if (options.flipx) { Machine.orientation ^= ORIENTATION_FLIP_X; Machine.ui_orientation ^= ORIENTATION_FLIP_X; } if (options.flipy) { Machine.orientation ^= ORIENTATION_FLIP_Y; Machine.ui_orientation ^= ORIENTATION_FLIP_Y; } set_pixel_functions(); /* Do the work*/ err = 1; bailing = 0; if (osd_init() == 0) { if (init_machine() == 0) { if (run_machine() == 0) err = 0; else if (bailing == 0) { bailing = 1; printf("Unable to start machine emulation\n"); } shutdown_machine(); } else if (bailing == 0) { bailing = 1; printf("Unable to initialize machine emulation\n"); } osd_exit(); } else if (bailing == 0) { bailing = 1; printf("Unable to initialize system\n"); } return err; }