void Gold_OnLiveTimeOut(Gold sender) { SetGoldNewPos(sender); }
private void SetGoldNewPos(Gold Sender) { if (PurviewMgr.IsMainHost) { while (true) { Vector2 pos = RandomHelper.GetRandomVector2(0, 1); pos.X *= mapRect.Width - 200; pos.Y *= mapRect.Height - 200; pos += new Vector2(100, 100); if (CanAddObjAtPos(pos)) { Sender.Born(pos); SyncCasheWriter.SubmitUserDefineInfo("GoldBorn", "", Sender, Sender.Pos); break; } } } }
private void InitializeScene() { sceneMgr = new SceneMgr(); sceneMgr.AddGroup("", new TypeGroup<WarShip>("warship")); sceneMgr.AddGroup("", new TypeGroup<WarShipShell>("shell")); sceneMgr.AddGroup("", new TypeGroup<SmartTank.PhiCol.Border>("border")); sceneMgr.AddGroup("", new TypeGroup<Gold>("gold")); sceneMgr.AddGroup("", new TypeGroup<Rock>("rock")); sceneMgr.PhiGroups.Add("warship"); sceneMgr.PhiGroups.Add("shell"); sceneMgr.PhiGroups.Add("rock"); sceneMgr.AddColMulGroups("warship", "shell", "border"); sceneMgr.AddColMulGroups("warship", "shell", "rock"); sceneMgr.ColSinGroups.Add("warship"); sceneMgr.ColSinGroups.Add("rock"); sceneMgr.AddLapMulGroups("warship", "gold"); ships = new WarShip[playerNames.Length]; for (int i = 0; i < playerNames.Length; i++) { bool openControl = false; if (i == controlIndex) openControl = true; ships[i] = new WarShip("ship" + i, new Vector2(400 + i * 800, 600), 0, openControl); ships[i].OnCollied += new OnCollidedEventHandler(WarShip_OnCollied); ships[i].OnOverLap += new OnCollidedEventHandler(Warship_OnOverLap); ships[i].OnShoot += new WarShip.WarShipShootEventHandler(WarShip_OnShoot); ships[i].OnDead += new WarShip.WarShipDeadEventHandler(Warship_OnDead); ships[i].PlayerName = playerNames[i]; sceneMgr.AddGameObj("warship", ships[i]); } gold = new Gold("gold", new Vector2(800, 600), 0); gold.OnOverLap += new OnCollidedEventHandler(Gold_OnOverLap); gold.OnLiveTimeOut += new Gold.GoldLiveTimeOutEventHandler(Gold_OnLiveTimeOut); sceneMgr.AddGameObj("border", new SmartTank.PhiCol.Border(mapRect)); sceneMgr.AddGameObj("gold", gold); GameManager.LoadScene(sceneMgr); camera.Focus(ships[controlIndex], false); }