private void sendCmd4(int src) { var dat = game.net.CreateStoryCode.NoonEnd(src); dat.src = src; { var o = new Noon(); o.run(dat); } }
private void sendCmd3(int src, int item, PLAYER_STATE s1) { var dat = game.net.CreateStoryCode.NoonItem(src, item); dat.src = src; { var o = new Noon(); o.run(dat); } Assert.AreEqual(GameFactory.getGame().shareData.players.getPlayer(src).state, s1); }
//----------------------------------------------------------------------------------------------- private void sendCmd(int src, int dest, PLAYER_STATE s1, PLAYER_STATE s2) { var dat = game.net.CreateStoryCode.NoonRequest(src, dest); { var o = new Noon(); o.run(dat); } Assert.AreEqual(GameFactory.getGame().shareData.players.getPlayer(src).state, s1); Assert.AreEqual(GameFactory.getGame().shareData.players.getPlayer(dest).state, s2); }
public NextTurn() { Logger.info("story.NextTurn():run."); AStory story = null; AStory story2 = null; if (GameFactory.getGame().shareData.field.state == FIELD_STATE.EARLY_MORNING) { story = new EarlyMorning(); story2 = new Morning(); } else if (GameFactory.getGame().shareData.field.state == FIELD_STATE.MORNING) { story = new Morning(); story2 = new Noon(); } else if (GameFactory.getGame().shareData.field.state == FIELD_STATE.NOON) { story = new Noon(); story2 = new Night(); } else if (GameFactory.getGame().shareData.field.state == FIELD_STATE.NIGHT) { story = new Night(); story2 = new MidNight(); } else if (GameFactory.getGame().shareData.field.state == FIELD_STATE.MIDNIGHT) { story = new MidNight(); story2 = new EarlyMorning(); } // 次のターンを実施 if (story.end()) { if (GameFactory.getGame().shareData.field.state == FIELD_STATE.MIDNIGHT) { GameFactory.getGame().shareData.field.state = FIELD_STATE.EARLY_MORNING; } else { GameFactory.getGame().shareData.field.state += 1; } story2.init(); } // send if (!GameFactory.debug) { // update view GameFactory.getUnityManager().updateDraw(true); } }
public void SwitchNoon(Noon _noon) { if (_noon == Noon.AM) { SwitchToAM(); } else if (_noon == Noon.PM) { SwitchToPM(); } }
private void sendCmd2(int src, int dest, bool fyes, PLAYER_STATE s1, PLAYER_STATE s2) { if (fyes) { var dat = game.net.CreateStoryCode.NoonYes(src); dat.src = src; dat.dest = dest; { var o = new Noon(); o.run(dat); } } else { var dat = game.net.CreateStoryCode.NoonNo(src); dat.src = src; dat.dest = dest; { var o = new Noon(); o.run(dat); } } Assert.AreEqual(GameFactory.getGame().shareData.players.getPlayer(src).state, s1); Assert.AreEqual(GameFactory.getGame().shareData.players.getPlayer(dest).state, s2); }
public void NoonTest() { Game gm = GameTest.createGame(); { var o = new Noon(); o.init(); } GameTest.setItem(gm, "p1", ITEM.MURDERE_KNIFE, ITEM.KNIFE, ITEM.KNIFE, ITEM.KNIFE); GameTest.setItem(gm, "p2", ITEM.CHEAN_LOCK, ITEM.CHEAN_LOCK, ITEM.CHEAN_LOCK, ITEM.CHEAN_LOCK); GameTest.setItem(gm, "p3", ITEM.KENSIKIT, ITEM.KENSIKIT, ITEM.KENSIKIT, ITEM.KENSIKIT); sendCmd(1, 2, PLAYER_STATE.NOON_WAIT_ACK, PLAYER_STATE.NOON_REQUEST_RETURN); sendCmd2(2, 1, true, PLAYER_STATE.NOON_ITEM, PLAYER_STATE.NOON_ITEM); sendCmd3(1, 1, PLAYER_STATE.NOON_ITEM_OK); Assert.AreEqual(gm.shareData.players.getPlayer("p2").state, db.PLAYER_STATE.NOON_ITEM); sendCmd3(2, 1, PLAYER_STATE.NONE); Assert.AreEqual(gm.shareData.players.getPlayer("p2").state, db.PLAYER_STATE.NONE); Assert.AreEqual(gm.shareData.players.getPlayer("p1").items[0], ITEM.MURDERE_KNIFE); Assert.AreEqual(gm.shareData.players.getPlayer("p1").items[1], ITEM.CHEAN_LOCK); Assert.AreEqual(gm.shareData.players.getPlayer("p1").items[2], ITEM.KNIFE); Assert.AreEqual(gm.shareData.players.getPlayer("p1").items[3], ITEM.KNIFE); Assert.AreEqual(gm.shareData.players.getPlayer("p2").items[0], ITEM.CHEAN_LOCK); Assert.AreEqual(gm.shareData.players.getPlayer("p2").items[1], ITEM.KNIFE); Assert.AreEqual(gm.shareData.players.getPlayer("p2").items[2], ITEM.CHEAN_LOCK); Assert.AreEqual(gm.shareData.players.getPlayer("p2").items[3], ITEM.CHEAN_LOCK); Assert.AreEqual(gm.shareData.players.getPlayer("p3").items[0], ITEM.KENSIKIT); Assert.AreEqual(gm.shareData.players.getPlayer("p3").items[1], ITEM.KENSIKIT); Assert.AreEqual(gm.shareData.players.getPlayer("p3").items[2], ITEM.KENSIKIT); Assert.AreEqual(gm.shareData.players.getPlayer("p3").items[3], ITEM.KENSIKIT); // end sendCmd4(1); sendCmd4(2); sendCmd4(3); sendCmd4(4); Assert.IsTrue(gm.shareData.players.isAllPlayerState(PLAYER_STATE.NOON_END)); }
public Sun(DateTime date, double latitude, double longitude, TimeZoneInfo timezone) { //Date = new DateTime(date.Year,date.Month,date.Day) + GetTimeEquation(date); Date = date; EclipLon = -1; double[] rises = new double[] { 0, 0, 0, 0 }; double[] sets = new double[] { 0, 0, 0, 0 }; bool[] isrises = new bool[] { false, false, false, false }; bool[] issets = new bool[] { false, false, false, false }; double[] h_correct = new double[] { Astro.Rad(-50 / 60.0), Astro.Rad(-6), Astro.Rad(-12), Astro.Rad(-18) }; double hour = 1.0; double y_minus, y_0, y_plus; double xe = 0, ye = 0, root1 = 0, root2 = 0; int nRoot = 0; double MJD0h = Astro.Mjd(date) - timezone.GetUtcOffset(date).TotalHours / 24.0; for (int i = 0; i < 4; i++) { hour = 1.0; y_minus = SinAlt(MJD0h, hour - 1.0, latitude, longitude) - Math.Sin(h_correct[i]); // loop over search intervals from [0h-2h] to [22h-24h] do { y_0 = SinAlt(MJD0h, hour, latitude, longitude) - Math.Sin(h_correct[i]); y_plus = SinAlt(MJD0h, hour + 1.0, latitude, longitude) - Math.Sin(h_correct[i]); // find parabola through three values y_minus,y_0,y_plus Astro.Quad(y_minus, y_0, y_plus, out xe, out ye, out root1, out root2, out nRoot); if (nRoot == 1) { if (y_minus < 0.0) { rises[i] = hour + root1; isrises[i] = true; } else { sets[i] = hour + root1; issets[i] = true; } } if (nRoot == 2) { if (ye < 0.0) { rises[i] = hour + root2; sets[i] = hour + root1; } else { rises[i] = hour + root1; sets[i] = hour + root2; } isrises[i] = true; issets[i] = true; } y_minus = y_plus; // prepare for next interval hour += 2.0; }while (!((hour == 25.0) || (isrises[i] && issets[i]))); } Dawn = Date.AddHours(rises[0]); Dusk = Date.AddHours(sets[0]); Noon = Dawn.AddHours((sets[0] - rises[0]) / 2); if (Dusk.Day != Dawn.Day) { Noon = Noon.AddHours(12); } CivilDawn = Date.AddHours(rises[1]); CivilDusk = Date.AddHours(sets[1]); NauticalDawn = Date.AddHours(rises[2]); NauticalDusk = Date.AddHours(sets[2]); AstronomicalDawn = Date.AddHours(rises[3]); AstronomicalDusk = Date.AddHours(sets[3]); Result = new SunResult { NoDawnDusk = !isrises[0] || !issets[0], NoCivil = !isrises[1] || !issets[1], NoNautical = !isrises[2] | !issets[2], NoAstronomical = !isrises[3] | !issets[3], }; }