private IEntityInfo GenerateEntityInfo(EntityRace race, EntityOccupation occupation) { if (occupation == EntityOccupation.None) { occupation = GetRandomOccupation(); } if (race == EntityRace.None) { race = GetRandomRace(); } string firstName = ""; string lastName = ""; if (race.HasFlag(EntityRace.Male)) { int nameIndex = GameGlobal.RandomInt(0, Names[EntityRace.Human | EntityRace.Male].Length); firstName = Names[EntityRace.Human | EntityRace.Male][nameIndex]; nameIndex = GameGlobal.RandomInt(0, Names[EntityRace.Human | EntityRace.Family].Length); lastName = Names[EntityRace.Human | EntityRace.Family][nameIndex]; } else if (race.HasFlag(EntityRace.Female)) { int nameIndex = GameGlobal.RandomInt(0, Names[EntityRace.Human | EntityRace.Female].Length); firstName = Names[EntityRace.Human | EntityRace.Male][nameIndex]; nameIndex = GameGlobal.RandomInt(0, Names[EntityRace.Human | EntityRace.Family].Length); lastName = Names[EntityRace.Human | EntityRace.Family][nameIndex]; } return(new EntityInfo(race, occupation, 25 * 365, firstName, lastName)); }
public static int AttackDistance(UnitBase from, UnitBase to) //计算攻击需要的距离 { if (from == null || to == null) { return(-1); } int cnt = 0; int fromY = from.GetPosition().Position.y; int toY = to.GetPosition().Position.y; if (fromY > toY) { TheGameCommon.Common.Swap(ref fromY, ref toY); } //foreach (var i in GameGlobal.Getinstance().GameMain.GridSystem.RowCounter) // Debug.Log(i); for (int i = fromY; i <= toY; i++) { if (GameGlobal.Get().GameMain.GridSystem.RowCounter[i] > 0) { cnt++; } } return(cnt); }
public override void Initialise() { // Initialise and fade in GameGlobal.InitialiseAssets(); GameGlobal.Fader.RunFunction("FadeIn"); // DebugText DebugText = new Entity(entity => { entity.Position = new Vector2(-55, 20); entity.AddComponent(new Text()).Run <Text>(text => { string temp = ""; foreach (var item in DebugData) { temp += item.Key + ": " + item.Value + "\n"; } text.String = temp; CoroutineHelper.Always(() => { //text.Visible = (OptionSelector.SelectedOption.ID == "debug"); }); }); }); MainMenu(); }
/// <summary> /// Supply a game object who's tree table this VMEntity can use. /// See: TSO.Files.formats.iff.chunks.TTAB /// </summary> /// <param name="obj">GameObject instance with a tree table to use.</param> public void UseTreeTableOf(GameObject obj) //manually set the tree table for an object. Used for multitile objects, which inherit this from the master. { if (TreeTable != null) { return; } var GLOBChunks = obj.Resource.List <GLOB>(); GameGlobal SemiGlobal = null; if (GLOBChunks != null && GLOBChunks[0].Name != "") { SemiGlobal = FSO.Content.Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name); } TreeTable = obj.Resource.Get <TTAB>(obj.OBJ.TreeTableID); if (TreeTable != null) { TreeTableStrings = obj.Resource.Get <TTAs>(obj.OBJ.TreeTableID); } if (TreeTable == null && SemiGlobal != null) { TreeTable = SemiGlobal.Resource.Get <TTAB>(obj.OBJ.TreeTableID); //tree not in local, try semiglobal TreeTableStrings = SemiGlobal.Resource.Get <TTAs>(obj.OBJ.TreeTableID); } }
// Start is called before the first frame update void Start() { panel.SetActive(false); testLog.GetComponent <Text>().text = "test input"; testLog.GetComponent <Text>().text = GameGlobal.getInstance().getTest(); gameModel = GameGlobal.getInstance().getGameModel(); if (gameModel != null) { //Summon players players = gameModel.getPlayers(); //player 1 controller1 = loadInstance(players[0].getCharacter(), StartOne.transform.position, false).GetComponent <NewPlayerController>(); controller1.setItem(players[0].getItemName()); controller1.tag = "Player"; //player 2 controller2 = loadInstance(players[1].getCharacter(), StartTwo.transform.position, false).GetComponent <NewPlayerController>(); controller2.setItem(players[1].getItemName()); controller2.tag = "Player 2"; //Setting controller1.playerOne = true; controller2.playerOne = false; controller2.Flip(); controller1.setName(players[0].getName()); controller2.setName(players[1].getName()); } }
public static GameGlobal Instance() { if (instance == null) { instance = new GameGlobal(); } return(instance); }
public EntityRace GetRandomRace() { int randomGender = GameGlobal.RandomInt(1, 2); int randomRace = (int)EntityRace.Human; // only do human for now //int randomRace = GameGlobal.RandomInt(GameGlobal.MinRaceCode, GameGlobal.MaxRaceCode); return((EntityRace)(randomGender | randomRace)); }
void Start() { // set id SetID((int)EntityID.GameManager); m_StateMachine = new StateMachine <GameManager>(this); m_StateMachine.SetCurrentState(GameStart.Instance()); m_StateMachine.SetGlobalStateState(GameGlobal.Instance()); }
// Start is called before the first frame update void Start() { globalData = GameObject.Find("GameManager").GetComponent <GameGlobal>(); rb = GetComponent <Rigidbody>(); rb.detectCollisions = false; rb.AddRelativeForce(Vector3.forward * (launchForce + globalData.velocity), ForceMode.Impulse); StartCoroutine(enableCollisions()); StartCoroutine(live()); }
protected void Start() { globalData = GameObject.Find("GameManager").GetComponent <GameGlobal>(); player = GameObject.FindGameObjectWithTag("Player"); rb = GetComponent <Rigidbody>(); initialRotation = transform.rotation; varySpeed(); elapsedLevelTime = Time.deltaTime - (globalData.levelDuration * (globalData.level - 1)); }
void OnBorn() { //行计数器加1 GameGlobal.Get().GameMain.GridSystem.RowCounter[GetPosition().Position.y]++; //添加事件 EventAdd(); EventManager.Get().EventTrigger(EventTypes.Unit_OnBorn, gameObject); //向回合系统列表添加单位 RoundSystem.Get().AddUnit(this); }
private int RandomWeightedIndex(codeProbability[] array) { float value = GameGlobal.RandomFloat(0.0f, 1.0f); int index = 0; while (array.Length > index + 1 && value > array[index + 1].probability) { value -= array[index++].probability; } return(array[index].type); }
public void TestRandomInt() { // I like this method because of it's ability to be deterministic random // the server can reseed it at any point and keep both -random- generators synced accross // computers GameGlobal.SeedRandomInt(1212, 3434, 42); int rnd1 = GameGlobal.NextRandomInt(100); int rnd2 = GameGlobal.NextRandomInt(100); int rnd3 = GameGlobal.NextRandomInt(100); int rnd4 = GameGlobal.NextRandomInt(100); int rnd5 = GameGlobal.NextRandomInt(100); }
public void AddSkillPoints(SkillType skill, float addedSkillPoints) { float currentLevel = this.Get(skill); this.skillStats[(int)skill] += addedSkillPoints; float newLevel = this.Get(skill); if (newLevel > currentLevel) { this.skillPoints += GameGlobal.CalculateSkillPointsMadeFromLevelingUpSkill(skill, newLevel); } }
// Start is called before the first frame update void Start() { globalData = GameObject.Find("GameManager").GetComponent <GameGlobal>(); originalRotation = Quaternion.identity; rb = GetComponent <Rigidbody>(); rb_mass = rb.mass; Physics.gravity = new Vector3(0f, -1f, 0f); fan = GameObject.Find("SpinController"); recepticle = GameObject.Find("Recepticle"); thirdPersonCamera = GameObject.FindGameObjectWithTag("MainCamera"); AssignCameraToPlayer(); respawn += globalData.respawn; particlesBubbles = GetComponent <ParticleSystem>(); }
/// <summary> /// 添加Unity对象 /// </summary> public T AddManager <T>(string typeName) where T : Component { object result = null; m_Managers.TryGetValue(typeName, out result); if (result != null) { return((T)result); } Component c = GameGlobal.AddComponent <T>(); m_Managers.Add(typeName, c); return(default(T)); }
public void UseSemiGlobalTTAB(string sgFile,ushort id) { GameGlobal obj = FSO.Content.Content.Get().WorldObjectGlobals.Get(sgFile); if (obj == null) { return; } TreeTable = obj.Resource.Get <TTAB>(id); if (TreeTable != null) { TreeTableStrings = obj.Resource.Get <TTAs>(id); } }
private float[] GetRandomDistribution() { float[] result = new float[Globals.StatTypeCount]; float total = 0; for (int i = 0; i < Globals.StatTypeCount; i++) { result[i] = GameGlobal.RandomFloat(0.0f, 10.0f); total += result[i]; } for (int i = 0; i < Globals.StatTypeCount; i++) { result[i] = result[i] / total; } return(result); }
void OnDeath() { //播放死亡音效 AudioManager.Get().PlaySound(SoundsList.Unit_OnDeath, 0.2f); //广播死亡消息 UIManager.Get().MsgOnScreen(UnitName + "已死亡!"); //行计数器扣除 GameGlobal.Get().GameMain.GridSystem.RowCounter[GetPosition().Position.y]--; //触发单位死亡事件(Unit_OnUnitDeath) EventManager.Get().EventTrigger(EventTypes.Unit_OnDeath, gameObject); //事件移除 EventRemove(); //解引用 GetPosition().CurrentUnit = null; //移除回合系统列表 RoundSystem.Get().RemoveUnit(this); }
void AddHolyWaterPerRound(object info) { AddHolyWater(3); int cnt = 0; foreach (var i in GameGlobal.Get().GameMain.GridSystem.CubeCells) { if (i.CurrentUnit != null) { cnt++; } } if (cnt == 0) { AddHolyWater(1); } }
public int HandlePacket(ClientBase client, GamePacket packet) { int clientID = packet.ReadInt(); LoginInfo info = new LoginInfo(); info.PlayerID = packet.PlayerID; GamePlayer player = new GamePlayer(info, client as GameClient); player.ClientID = clientID; player.Logined(); GameGlobal.PlayerMgr.Add(player.PlayerID, player); GameGlobal.CheckMaxClientCount(); return(0); }
public void onClickStart() { GameGlobal.getInstance().setTest(player1Name.text + " VS " + player2Name.text); List <Player> players = new List <Player>(); List <String> characterNames = gameLoader.getCharacterList(); List <String> itemsNames = gameLoader.getItemsList(); players.Add(new Player( player1Name.text, characterNames[player1Select.getCurrCharacter()], itemsNames[player1ItemsSelect.getCurrItem()] )); players.Add(new Player( player2Name.text, characterNames[player2Select.getCurrCharacter()], itemsNames[player2ItemsSelect.getCurrItem()] )); GameGlobal.getInstance().setGameModel(gameLoader.createGame(players)); SceneManager.LoadScene(1); }
//添加物品 bool IBackPackService.addItem(string ItemID) { BackPack backPack = GameGlobal.backPack; if (backPack.Items.ContainsKey(ItemID)) { backPack.Items[ItemID] += 1; } else { if (backPack.Items.Count < backPack.capacity) { backPack.Items.Add(ItemID, 1); } else { return(false); } } // 更新存档 GameGlobal.save(); return(true); }
/// <summary> /// Constructs a new VMEntity instance. /// </summary> /// <param name="obj">A GameObject instance.</param> public VMEntity(GameObject obj) { this.Object = obj; /** * For some reason, in the aquarium object (maybe others) the numAttributes is set to 0 * but it should be 4. There are 4 entries in the label table. Go figure? */ ObjectData = new short[80]; MeToObject = new Dictionary<ushort, Dictionary<short, short>>(); SoundThreads = new List<VMSoundEntry>(); RTTI = new VMEntityRTTI(); var numAttributes = obj.OBJ.NumAttributes; if (obj.OBJ.UsesFnTable == 0) EntryPoints = GenerateFunctionTable(obj.OBJ); else { var OBJfChunk = obj.Resource.Get<OBJf>(obj.OBJ.ChunkID); //objf has same id as objd if (OBJfChunk != null) EntryPoints = OBJfChunk.functions; } var test = obj.Resource.List<OBJf>(); var GLOBChunks = obj.Resource.List<GLOB>(); if (GLOBChunks != null) { SemiGlobal = TSO.Content.Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name); Object.Resource.SemiGlobal = SemiGlobal.Resource; //used for tuning constant fetching. } Slots = obj.Resource.Get<SLOT>(obj.OBJ.SlotID); //containment slots are dealt with in the avatar and object classes respectively. var attributeTable = obj.Resource.Get<STR>(256); if (attributeTable != null) { numAttributes = (ushort)Math.Max(numAttributes, attributeTable.Length); RTTI.AttributeLabels = new string[numAttributes]; for (var i = 0; i < numAttributes; i++) { RTTI.AttributeLabels[i] = attributeTable.GetString(i); } } TreeTable = obj.Resource.Get<TTAB>(obj.OBJ.TreeTableID); if (TreeTable != null) TreeTableStrings = obj.Resource.Get<TTAs>(obj.OBJ.TreeTableID); if (TreeTable == null && SemiGlobal != null) { TreeTable = SemiGlobal.Resource.Get<TTAB>(obj.OBJ.TreeTableID); //tree not in local, try semiglobal TreeTableStrings = SemiGlobal.Resource.Get<TTAs>(obj.OBJ.TreeTableID); } //no you cannot get global tree tables don't even ask this.Attributes = new short[numAttributes]; SetFlag(VMEntityFlags.ChairFacing, true); }
void OnMouseUpAsButton() { GameGlobal.Play(level); }
public override void Initialise() { // Initialise and GameGlobal.InitialiseAssets(); // DEBUGGING #region Debugging // Debug text new Entity(entity => { entity.SortingLayer = 1; entity.LayerName = "Fade"; entity.Position = -(Global.Resolution.ToVector2() / 2); entity.AddComponent(new Text()).Run <Text>(component => { component.SetSpriteFont("HeartbitXX"); component.Color = Color.Yellow; entity.UpdateAction = e => { component.String = ""; //component.String = "Entities: " + Global.CountEntities().ToString() + ", Coroutines: " + Coroutines.Count.ToString() + ", FPS: " + Global.FPS.ToString(); //component.String = String.Join(", ", GameGlobal.Player.GetComponent<MainCollider>().PrevCollidingTriggers.Select(x => x.Name).ToArray()); component.String += (GameGlobal.DebugString.Length > 0) ? " | " + GameGlobal.DebugString : ""; GameGlobal.DebugString = ""; }; }); }); // Hotspot tester hotspotTest = new Entity(entity => { entity.AddComponent(new Sprite()).Run <Sprite>(d => { d.BuildRectangle(new Point(4, 4), Color.Orange); }); entity.SortingLayer = 10; }); CoroutineHelper.Always(() => { //hotspotTest.Position = new Vector2(textTest.BoundingBox.Left + textTest.Size.X / 2, textTest.BoundingBox.Bottom); }); #endregion // Backgrounds #region Backgrounds /* * new Entity(entity => { * entity.LayerName = "Background"; * entity.Position += new Vector2(0, 80); * entity.AddComponent(new Drawable() { Texture2D = Global.Content.Load<Texture2D>("WaterTest") }).Run<Drawable>(component => { * Color[] colorArr = component.Texture2D.To1DArray(); * CoroutineHelper.Always(() => { * component.Texture2D.ManipulateColors1D(colors => { * colors = (Color[])colorArr.Clone(); * for (int y = 0; y < 100; y++) * colors.Shift(new Point(256, 100), new Rectangle(0, 1 * y, 256, 1), new Point(-(int)(Global.Camera.Position.X * (y + 1) * 0.005f), 1 * y)); * return colors; * }); * }); * }); * });*/ #endregion // Player entity GameGlobal.Player = new Entity(); GameGlobal.Player.AddComponent(new PlayerController()); Global.AudioController.MusicSetThisFrame = false; // Temp RenderBlender = new RenderBlender( Color.Black * 0f, new List <RenderBlender.DrawableTexture>() { } ); // Load level LevelLoader levelLoader = new LevelLoader(); levelLoader.Load(GameData.Get("Level"), (tileset, tiles, entities) => { // Create tilemap TileMap tileMap = new TileMap(new Point(16, 16), "Tilesets/" + tileset.Substring(0, tileset.LastIndexOf('.')), tiles); tileMap.Build(new Point(32, 32)); // Map collision foreach (var tgroup in tileMap.TileGroupEntities) { if (tgroup.SortingLayer == GameGlobal.Player.SortingLayer) { tgroup.AddComponent(new Collider()).Run <Collider>(c => { c.ColliderType = Collider.ColliderTypes.Pixel; }); } //if (tgroup.SortingLayer == GameGlobal.Player.SortingLayer - 1) // tgroup.IsPlatform = true; } // Entities new EntityInfoInterpreter(entities); }); // Camera CameraController = new CameraController { Target = GameGlobal.PlayerGraphicEntity, Easing = 0.08f, MaxStep = 1000 }; CameraController.SnapOnce(); CameraController.Mode = CameraController.Modes.LerpToTarget; // Level script LevelScripts levelScripts = new LevelScripts(); Type type = levelScripts.GetType(); MethodInfo method = type.GetMethod(GameData.Get("Level")); if (method != null) { method.Invoke(levelScripts, new object[0]); } if (!Global.AudioController.MusicSetThisFrame) { Global.AudioController.MusicFadeOut(); } if (GameGlobal.Fader.Data["Cancel"] != "true") { // This delay is currently for the camera repositioning if min / max are applied CoroutineHelper.WaitRun(0.5f, () => { GameGlobal.Fader.RunFunction("FadeIn"); }); } }
void OnMouseUpAsButton() { GameGlobal.MainMenu(); }
public float GetStatWithAppliedSkill(SkillType i, StatType type, IEntityStats stats) { return(GameGlobal.CalculateSkillEffect(i, type, (float)Math.Floor(skillStats[(int)i]), stats.Get(type))); }
void Awake() { s_Inst = this; DOTween.Init(); }
//manually set the tree table for an object. Used for multitile objects, which inherit this from the master. /// <summary> /// Supply a game object who's tree table this VMEntity can use. /// See: TSO.Files.formats.iff.chunks.TTAB /// </summary> /// <param name="obj">GameObject instance with a tree table to use.</param> public void UseTreeTableOf(GameObject obj) { if (TreeTable != null) return; var GLOBChunks = obj.Resource.List<GLOB>(); GameGlobal SemiGlobal = null; if (GLOBChunks != null) SemiGlobal = TSO.Content.Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name); TreeTable = obj.Resource.Get<TTAB>(obj.OBJ.TreeTableID); if (TreeTable != null) TreeTableStrings = obj.Resource.Get<TTAs>(obj.OBJ.TreeTableID); if (TreeTable == null && SemiGlobal != null) { TreeTable = SemiGlobal.Resource.Get<TTAB>(obj.OBJ.TreeTableID); //tree not in local, try semiglobal TreeTableStrings = SemiGlobal.Resource.Get<TTAs>(obj.OBJ.TreeTableID); } }
public EntityOccupation GetRandomOccupation() { return((EntityOccupation)GameGlobal.RandomInt(1, Globals.OccupationTypeCount)); }
public VMEntity(GameObject obj) { this.Object = obj; /** * For some reason, in the aquarium object (maybe others) the numAttributes is set to 0 * but it should be 4. There are 4 entries in the label table. Go figure? */ ObjectData = new short[80]; RTTI = new VMEntityRTTI(); var numAttributes = obj.OBJ.NumAttributes; if (obj.OBJ.UsesInTable == 0) EntryPoints = GenerateFunctionTable(obj.OBJ); else { var OBJfChunks = obj.Resource.List<OBJf>(); if (OBJfChunks != null) EntryPoints = OBJfChunks[0].functions; } var GLOBChunks = obj.Resource.List<GLOB>(); if (GLOBChunks != null) { SemiGlobal = Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name); } var attributeTable = obj.Resource.Get<STR>(256); if (attributeTable != null) { numAttributes = (ushort)Math.Max(numAttributes, attributeTable.Length); RTTI.AttributeLabels = new string[numAttributes]; for (var i = 0; i < numAttributes; i++) { RTTI.AttributeLabels[i] = attributeTable.GetString(i); } } TreeTable = obj.Resource.Get<TTAB>(obj.OBJ.TreeTableID); if (TreeTable != null) TreeTableStrings = obj.Resource.Get<TTAs>(obj.OBJ.TreeTableID); if (TreeTable == null && SemiGlobal != null) { TreeTable = SemiGlobal.Resource.Get<TTAB>(obj.OBJ.TreeTableID); //tree not in local, try semiglobal TreeTableStrings = SemiGlobal.Resource.Get<TTAs>(obj.OBJ.TreeTableID); } //no you cannot get global tree tables don't even ask this.Attributes = new short[numAttributes]; if (obj.OBJ.GUID == 0x98E0F8BD) { this.Attributes[0] = 2; } }
void OnMouseUpAsButton() { GameGlobal.WorldMap(); }