public static void SetObjPos(GameObject obj, Vector3 pos) { InGameBaseObj ingameobj = obj.GetComponent <InGameBaseObj>(); if (ingameobj == null) { return; } if (ingameobj.GetObjType() != InGameBaseObj.enObjType.map) { return; } Vector2 mappos = GameCommon.GetMapPos(pos); obj.transform.position = GameCommon.GetWorldPos(mappos); MapObjConf conf = ConfigManager.GetEditorMapObjConfManager().map[ingameobj.confid]; if (conf == null) { return; } GameCommon.SetObjZIndex(obj, conf.depth); return; //MapEditor me = GameObject.Find("levelOption").transform.GetComponent<MapEditor>(); //if (me == null) //{ // EditorUtility.DisplayDialog("ERROR", "Cant't find the 'levelOption' !!", "ENTRY"); // return; //} }
//�������������Ϣ��ť private void OnTrumpetSendBtn(EventTriggerType eventtype, object param, PointerEventData eventData) { if (eventtype == EventTriggerType.PointerClick) { CustomAudio.GetInstance().PlayCustomAudio(1002); PlayerData playerdata = GameMain.hall_.GetPlayerData(); if (playerdata.GetDiamond() < 5) { CRollTextUI.Instance.AddVerticalRollText(1501); return; } InputField content = TrumpetMessageSendUIObj.transform.Find("ImageInputBG/Inputcontent").gameObject.GetComponent <InputField>(); string sendtext = content.text; if (sendtext.Length == 0) { CRollTextUI.Instance.AddVerticalRollText(1506); return; } if (sendtext.Length > 30) { CRollTextUI.Instance.AddVerticalRollText(1503); return; } UMessage trumpetMsg = new UMessage((uint)GameCity.EMSG_ENUM.CrazyCityMsg_CM_SENDHORNTOALL); trumpetMsg.Add(GameMain.hall_.GetPlayerId()); GameCommon.CheckForbiddenWord(ref sendtext, true); trumpetMsg.Add(sendtext); NetWorkClient.GetInstance().SendMsg(trumpetMsg); OpenOrCloseTrumpetUI(false); } }
/// <summary> /// 把Dictionary序列化为byte数据 /// Saves the table data. /// </summary> /// <param name="dic">Dic.</param> /// <param name="tablename">Tablename.</param> public static void SaveTableData(List <object> list, string tablename) { byte[] data = GameCommon.SerializeObject(list); byte[] gzipData = GameCommon.CompressGZip(data); //WriteByteToFile(gzipData,tablename); GameCommon.WriteByteToFile(gzipData, GameConst.SaveConfigFilePath(tablename)); }
public override void HandleEvent(EventData resp) { if (InGameManager.GetInstance().gameState != enGameState.playing) { return; } if (bullet == null) { return; } switch (resp.eid) { case EventID.EVENT_TOUCH_DOWN: EventTouch eve = (EventTouch)resp; //TouchToPlane(eve.pos); //Fire(GameCommon.ScreenPositionToWorld(eve.pos)); Vector3 pos = GameCommon.ScreenPositionToWorld(InGameManager.GetInstance().gamecamera, eve.pos); if (pos.y > InGameManager.GetInstance().inGameUIManager.gamePadManager.comboLabelPos.y - 1) { return; } bullet.Fire(); AudioManager.Instance.Play("sound/btn"); bullet = null; break; } }
public override void HandleEvent(EventData resp) { base.HandleEvent(resp); switch (resp.eid) { case EventID.EVENT_GAME_CHARACTER_BORN: InGameBaseCharacter bornobj = (InGameBaseCharacter)resp.sUserData[0]; EnemyInfo info = new EnemyInfo(); info.character = bornobj; enemyInfoList.Add(info); break; case EventID.EVENT_GAME_CHARACTER_DIE: InGameBaseCharacter dieobj = (InGameBaseCharacter)resp.sUserData[0]; for (int i = 0; i < enemyInfoList.Count; i++) { if (enemyInfoList[i].character.instanceId == dieobj.instanceId) { Vector2 mapPos = GameCommon.GetMapPos(dieobj.transform.position); SetPixel((int)mapPos.x, (int)mapPos.y, dataArray[(int)mapPos.x, (int)mapPos.y]); enemyInfoList.RemoveAt(i); return; } } break; } }
public static int GetPlayer_側面Sub() { bool touchSide_L = Game.I.Map.GetCell(GameCommon.ToTablePoint(Game.I.Player.X - GameConsts.PLAYER_側面判定Pt_X, Game.I.Player.Y)).Tile.IsWall(); bool touchSide_R = Game.I.Map.GetCell(GameCommon.ToTablePoint(Game.I.Player.X + GameConsts.PLAYER_側面判定Pt_X, Game.I.Player.Y)).Tile.IsWall(); return((touchSide_L ? 1 : 0) | (touchSide_R ? 2 : 0)); }
void MoveAction() { Vector3 tp = GameCommon.GetWorldPos(path[0]); float dis = Vector2.Distance(parent.transform.position, tp); if (dis <= parent.GetMoveSpeed() * Time.deltaTime) { SetPathPos(); if (path.Count <= 0) { parent.StopAction(); } else { parent.Move(path[0]); } return; } else { parent.Move(path[0]); parent.SetAnimatorState(InGameBaseCharacter.AnimatorState.Run, parent.GetMoveSpeed() * 0.6f); } }
public override void MUpdate() { base.MUpdate(); //更新小地图位置 Vector3 rolePos = InGameManager.GetInstance().inGamePlayerManager.GetRolePos(); Vector2 arrPos = GameCommon.GetMapPos(rolePos); float x = (float)arrPos.x / (float)uitexture.mainTexture.width; float y = (float)arrPos.y / (float)uitexture.mainTexture.height; uitexture.transform.localPosition = -1 * new Vector2(x * uitexture.width, y * uitexture.height); //update life if (Mathf.Abs(lifeTargetVal - lifeLine.fillAmount) > 0.01f) { lifeLine.fillAmount = lifeLine.fillAmount + (lifeTargetVal - lifeLine.fillAmount) * 0.1f; if (Mathf.Abs(lifeTargetVal - lifeLine.fillAmount) <= 0.01f) { lifeLine.fillAmount = lifeTargetVal; } } //update mana //update exp if (Mathf.Abs(expTargetVal - expLine.fillAmount) > 0.01f) { expLine.fillAmount = expLine.fillAmount + (expTargetVal - expLine.fillAmount) * 0.1f; if (Mathf.Abs(expTargetVal - expLine.fillAmount) <= 0.01f) { expLine.fillAmount = expTargetVal; } } }
IEnumerator ReadConfigFile(string filename) { //GameConst.GetStoryLevelFilePath(mapid+".lmd") string filepath;//= GameConst.GetConfigFilePath(filename); filepath = GameConst.GetLevelDataFilePath2(filename); Debug.Log(filepath); filepath += ".lmd"; WWW www = new WWW(filepath); yield return(www); while (www.isDone == false) { yield return(null); } if (www.error == null) { byte[] gzipdata = www.bytes; byte[] levelData = GameCommon.UnGZip(gzipdata); DataStream datastream = new DataStream(levelData, true); md.Deserialize(datastream); InitGame(); } else { //GameLogTools.SetText("wwwError<<" + www.error + "<<" + filepath); Debug.Log("wwwError<<" + www.error + "<<" + filepath); (new EventChangeScene(GameSceneManager.SceneTag.Menu)).Send(); } }
public virtual void StartAction(InGameBaseObj target, Vector3 targetPos, int dis) { astarDis = dis; Vector3 _targetMapPos = GameCommon.GetMapPos(targetPos); if (_targetMapPos == targetMapPos) { return; } Vector2 startPos = GameCommon.GetMapPos(parent.transform.position); MazeMapManager gameMap = InGameManager.GetInstance().inGameLevelManager.gameMap; List <Vector2> _path = astar.StratAStar( gameMap.astarArray, startPos, GameCommon.GetMapPos(targetPos), dis); if (_path.Count <= 0) { return; } HandlePath(startPos, _path); path = _path; isaction = true; this.target = target; this.targetPos = targetPos; targetMapPos = _targetMapPos; atkTime = 0; state = ActionState.move; }
public override void HandleEvent(EventData resp) { if (InGameManager.GetInstance().gameState != enGameState.playing) { return; } switch (resp.eid) { case EventID.EVENT_TOUCH_DOWN: EventTouch eve = (EventTouch)resp; //TouchToPlane(eve.pos); //Fire(GameCommon.ScreenPositionToWorld(eve.pos)); Vector3 pos = GameCommon.ScreenPositionToWorld(InGameManager.GetInstance().gamecamera, eve.pos); if (pos.x > 0) { KillObj(); } else { if (GetMyState() == GameObjState.red) { return; } SetState(GetMyState() == GameObjState.black ? GameObjState.white:GameObjState.black); } break; } }
public void ShowBegin() { InitGame(); PlayUITfm.gameObject.SetActive(true); m_PauseBtn.gameObject.SetActive(true); m_ContinueBtn.gameObject.SetActive(false); for (int i = 0; i < m_SpeedBtns.Length; i++) { m_SpeedBtns[i].gameObject.SetActive(i == 1); } m_LastBtn.interactable = false; m_NextBtn.interactable = true; m_nCurStep = 0; m_fTimer = StepInterval; m_bPause = m_bEnd = false; Transform tfm = PlayUITfm.Find("Top"); Text t = tfm.Find("TextRule").GetComponent <Text>(); t.text = m_CurData.gamerule; t = tfm.Find("TextTime").GetComponent <Text>(); System.DateTime sdt = GameCommon.ConvertLongToDateTime(m_CurData.timeseconds); t.text = sdt.ToString("yyyy年MM月dd日HH:mm"); }
private void Start() { instance = this; gamecamera = Camera.main; rapidBlurEffectManager = gamecamera.gameObject.AddComponent <RapidBlurEffectManager>(); Vector3 screenLeftDown = new Vector3(0, 0, 0); Vector3 screenRightTop = new Vector3(Screen.width, Screen.height, 0); Vector3 gameLeftDown = GameCommon.ScreenPositionToWorld(gamecamera, screenLeftDown); Vector3 gameRightTop = GameCommon.ScreenPositionToWorld(gamecamera, screenRightTop); gameRect = new Rect(gameLeftDown, gameRightTop - gameLeftDown); gameState = enGameState.ready; if (UserDataManager.selLevel == null) { InitGame(); } else { StartCoroutine(ReadConfigFile(UserDataManager.selLevel.file_path)); } // }
public override void Update() { for (int i = 0; i < enemyPoints.Count; i++) { enemyPoints[i].ObjUpdate(); } for (int i = enemyList.Count - 1; i >= 0; i--) { if (enemyList[i] == null) { enemyList.RemoveAt(i); } } List <CharacterConf> roleList = ConfigManager.characterConfManager.dicByType[(int)CharacterConf.enCharacterType.enemy]; while (enemyList.Count < 5) { //InGameBaseCharacter enemy = InGameManager.GetInstance().inGameObjManager.AddObj(roleList[Random.Range(0, roleList.Count)].id, enMSCamp.en_camp_enemy) as InGameBaseCharacter; InGameBaseCharacter enemy = InGameManager.GetInstance().inGameObjManager.AddObj(100008, enMSCamp.en_camp_enemy) as InGameBaseCharacter; //100011 enemy.AddAI(); Vector3 pos = InGameManager.GetInstance().inGameLevelManager.gameMap.GetRandomWay(); enemy.transform.position = GameCommon.GetWorldPos(pos); enemy.SetZPos(); enemyList.Add(enemy); } }
public void AddScores(Vector3 worldPos, int scores, int sumscores, bool iscombo, bool createLabel = true) { if (createLabel) { GameObject labelObj; Vector3 pos = GameCommon.WorldPosToNGUIPos(Camera.main, UICamera.currentCamera, worldPos); if (iscombo) { labelObj = NGUITools.AddChild(uiroot, addScoresComboLabelRes); AddScoresComboLabel label = labelObj.GetComponent <AddScoresComboLabel>(); label.Init(pos, scores); label.transform.position = pos; } else { labelObj = NGUITools.AddChild(uiroot, addScoresLabelRes); AddScoresLabel label = labelObj.GetComponent <AddScoresLabel>(); label.Init(pos, scores); label.transform.position = pos; } //GameObject labelObj = MonoBehaviour.Instantiate(addScoresLabelRes); } gamePadManager.SetScores(sumscores, iscombo); }
protected override IEnumerable <bool> E_Draw() { for (; ;) { if (DDUtils.GetDistance(new D2Point(Game.I.Player.X, Game.I.Player.Y), new D2Point(this.X, this.Y)) < 30.0) { GameCommon.SaveGame(); break; } if (!DDUtils.IsOutOfCamera(new D2Point(this.X, this.Y), 50.0)) { DDDraw.DrawBegin(Ground.I.Picture.Dummy, this.X - DDGround.ICamera.X, this.Y - DDGround.ICamera.Y); DDDraw.DrawRotate(DDEngine.ProcFrame / 30.0); DDDraw.DrawEnd(); DDPrint.SetPrint((int)this.X - DDGround.ICamera.X, (int)this.Y - DDGround.ICamera.Y); DDPrint.SetBorder(new I3Color(0, 0, 0)); DDPrint.PrintLine("セーブ地点"); DDPrint.Reset(); // 当たり判定無し } yield return(true); } }
protected override IEnumerable <bool> E_Draw() { double ySpeed = 0.0; const double GRAVITY = 1.0; const double SPEED_Y_MAX = 8.0; for (; ;) { this.Y += ySpeed; ySpeed += GRAVITY; ySpeed = Math.Min(ySpeed, SPEED_Y_MAX); if (Game.I.Map.GetCell(GameCommon.ToTablePoint(new D2Point(this.X, this.Y))).Tile.IsGround()) // ? 地面に落ちた。 { break; } DDDraw.DrawCenter(Ground.I.Picture.Teki_a01_Shit01, this.X - DDGround.ICamera.X, this.Y - DDGround.ICamera.Y); this.Crash = DDCrashUtils.Point(new D2Point(this.X, this.Y)); yield return(true); } }
public SelfContestRule() { playernumber = llrplayerNumberList[0]; precontest = llrprecontestList[0]; finalcontest = llrprecontestList[0]; cost = costList[0]; timeseconds = (uint)GameCommon.ConvertDataTimeToLong(System.DateTime.Now.Date) + 3600; }
public static bool IsPlayer_脳天() { bool touchCeiling = Game.I.Map.GetCell(GameCommon.ToTablePoint(Game.I.Player.X - GameConsts.PLAYER_脳天判定Pt_X, Game.I.Player.Y - GameConsts.PLAYER_脳天判定Pt_Y)).Tile.IsWall() || Game.I.Map.GetCell(GameCommon.ToTablePoint(Game.I.Player.X + GameConsts.PLAYER_脳天判定Pt_X, Game.I.Player.Y - GameConsts.PLAYER_脳天判定Pt_Y)).Tile.IsWall(); return(touchCeiling); }
public static bool IsPlayer_接地() { bool touchGround = Game.I.Map.GetCell(GameCommon.ToTablePoint(Game.I.Player.X - GameConsts.PLAYER_接地判定Pt_X, Game.I.Player.Y + GameConsts.PLAYER_接地判定Pt_Y)).Tile.IsWall() || Game.I.Map.GetCell(GameCommon.ToTablePoint(Game.I.Player.X + GameConsts.PLAYER_接地判定Pt_X, Game.I.Player.Y + GameConsts.PLAYER_接地判定Pt_Y)).Tile.IsWall(); return(touchGround); }
private void Start() { weaponList = GameCommon.GetChildList(this.transform); foreach (Transform t in weaponList) { t.gameObject.SetActive(false); } }
// 1 - wink, player just wake up private void InitWinkAnimation() { this.player.IsControllable = false; this.mouseLook.sensitivityX = 0; this.mouseLook.sensitivityY = 0; GameCommon.SetTween(this.winkSpriteUp.gameObject, TweenType.TweenPosition, true); GameCommon.SetTween(this.winkSpriteDown.gameObject, TweenType.TweenPosition, true); Invoke("OnWinkFnished", timeWink); }
public void LoadLevel(string fileName) { byte[] levelGzipData = GameCommon.ReadByteToFile(GameConst.GetLevelDataFilePath(fileName + ".lmd")); byte[] levelData = GameCommon.UnGZip(levelGzipData); DataStream datastream = new DataStream(levelData, true); ReloadScene(datastream); Closeed(); }
public static void GZipTest() { string testdata = "aaaa11233GZip压缩和解压"; byte[] gzipdata = GameCommon.CompressGZip(Encoding.UTF8.GetBytes(testdata)); byte[] undata = GameCommon.UnGZip(gzipdata); Debuger.Log("[GZipTest] : data" + Encoding.UTF8.GetString(undata)); }
void EnemySpawn() { List <Transform> list = GameCommon.GetChildList(transform); foreach (Transform t in list) { GameObject.Instantiate(enemyPrefab, t.position, Quaternion.identity); } }
public static void Base64Test() { string base64string = GameCommon.ToBase64String("aaaa11233Base64编码和解码"); string unbase64string = GameCommon.UnBase64String(base64string); Debug.Log("base64string : " + base64string); Debug.Log("unbase64string : " + unbase64string); }
public override void Update() { base.Update(); addTime -= Time.deltaTime; if (addTime > 0f) { return; } addTime = Random.Range(1f, 3f); //随机出生点 float x = gameMapRect.x * 2f + Random.Range(1, gameMapRect.width * 2f); float y = gameMapRect.y + gameMapRect.height + 1f; float targetx = 0f; if (x < 0f) { targetx = gameMapRect.x + Random.Range(1f, gameMapRect.width * 1.5f); } else { targetx = gameMapRect.x + gameMapRect.width - Random.Range(1f, gameMapRect.width * 1.5f); } float targety = gameMapRect.y - 1f; //移动轨迹不能与y轴平行,如果平行手动+1 if (Mathf.Abs(targetx - x) <= 0.1f) { targetx += 1f; } //保证出生点在屏幕边缘 if (x < gameMapRect.x - 1f) { y = GameCommon.GetLineY(new Vector3(x, y), new Vector3(targetx, targety), gameMapRect.x - 1); x = gameMapRect.x - 1f; } else if (x > gameMapRect.x + gameMapRect.width + 1f) { y = GameCommon.GetLineY(new Vector3(x, y), new Vector3(targetx, targety), gameMapRect.x + gameMapRect.width + 1f); x = gameMapRect.x + gameMapRect.width + 1f; } Vector3 startPos = new Vector3(x, y); Vector3 targetPos = new Vector3(targetx, targety); HitCubeEnemy enemy = InGameManager.GetInstance().inGameObjManager.AddObj(BaseHitCubeObj.enHitCubeObjId.enemy) as HitCubeEnemy; enemy.Init(startPos, targetPos, Random.Range(0.5f, 3f), Random.Range(0.3f, 0.6f)); }
void AddRangeEnemy() { if (enemyPointList.Count <= 0) { return; } List <int> objidList = new List <int>(); //将所有敌人随机插入到队列中 for (int i = 0; i < enemyPointList.Count; i++) { MapEnemyPointEnemy point = enemyPointList[i]; int enemycount = Random.Range(point.rangeMinCount, point.rangeMaxCount); for (int j = 0; j < enemycount; j++) { if (objidList.Count <= 0) { objidList.Add(point.rangeObjIdList[Random.Range(0, point.rangeObjIdList.Count)]); } else { objidList.Insert(Random.Range(0, objidList.Count), point.rangeObjIdList[Random.Range(0, point.rangeObjIdList.Count)]); } } } //向周围扩散加入敌人 int count = objidList.Count; int size = 1; Vector2 basepos = GameCommon.GetMapPos(transform.position); while (count >= 0) { for (int i = 0; i < size; i++) { count--; if (count < 0) { break; } Vector2 _pos = basepos + new Vector2(i, size - 1); AddObj(objidList[count], GameCommon.GetWorldPos(_pos)); count--; if (count < 0) { break; } _pos = basepos + new Vector2(size - 1, i); AddObj(objidList[count], GameCommon.GetWorldPos(_pos)); } size++; } }
public void SaveData() { UserDataMode userdatamode = new UserDataMode(); userdatamode.SetData(userData); byte[] data = GameCommon.SerializeObject(userdatamode); byte[] gzipData = GameCommon.CompressGZip(data); GameCommon.WriteByteToFile(gzipData, GameConst.GetPersistentDataPath(GameConst.userDataFileName)); }
void CreateRocks(Vector3 v) { GameObject column = (GameObject)Resources.Load("Prefabs/MapObj/rocks_" + Random.Range(0, 8)); column = MonoBehaviour.Instantiate(column); column.transform.position = GameCommon.GetWorldPos(v) * mapscale; column.transform.position += new Vector3(0, 0, v.y); column.transform.localScale = new Vector3(mapscale, mapscale, mapscale); }