//public static IEnumerable<NetInfo> Build(this INetInfoBuilder builder, ICollection<Action> lateOperations) //{ // // Ground versions // var groundInfo = builder.BuildVersion(NetInfoVersion.Ground, lateOperations); // var groundGrassInfo = builder.BuildVersion(NetInfoVersion.GroundGrass, lateOperations); // var groundTreesInfo = builder.BuildVersion(NetInfoVersion.GroundTrees, lateOperations); // var groundInfos = new[] { groundInfo, groundGrassInfo, groundTreesInfo }; // groundInfos = groundInfos.Where(gi => gi != null).ToArray(); // if (!groundInfos.Any()) // { // yield break; // } // // Other versions // var elevatedInfo = builder.BuildVersion(NetInfoVersion.Elevated, lateOperations); // var bridgeInfo = builder.BuildVersion(NetInfoVersion.Bridge, lateOperations); // var tunnelInfo = builder.BuildVersion(NetInfoVersion.Tunnel, lateOperations); // var slopeInfo = builder.BuildVersion(NetInfoVersion.Slope, lateOperations); // // Setup MenuItems // var swMb = new Stopwatch(); // swMb.Start(); // if (builder is IMenuItemBuilder) // { // if (groundInfos.Count() > 1) // { // throw new Exception("Multiple netinfo menuitem cannot be build with the IMenuItemBuilder, use the IMenuItemBuildersProvider"); // } // var mib = builder as IMenuItemBuilder; // groundInfos[0].SetMenuItemConfig(mib); // } // else if (builder is IMenuItemBuildersProvider) // { // var mibp = builder as IMenuItemBuildersProvider; // var mibs = mibp.MenuItemBuilders.ToDictionary(x => x.Name, StringComparer.InvariantCultureIgnoreCase); // foreach (var mainInfo in groundInfos) // { // if (mibs.ContainsKey(mainInfo.name)) // { // var mib = mibs[mainInfo.name]; // mainInfo.SetMenuItemConfig(mib); // } // } // } // else // { // throw new Exception("Cannot set the menuitem on netinfo, either implement IMenuItemBuilder or IMenuItemBuildersProvider"); // } // swMb.Stop(); // Debug.Log($"{builder.Name} menu item built in {swMb.ElapsedMilliseconds}"); // // Setup AI // foreach (var mainInfo in groundInfos) // { // var ai = mainInfo.GetComponent<RoadAI>(); // ai.m_elevatedInfo = elevatedInfo; // ai.m_bridgeInfo = bridgeInfo; // ai.m_tunnelInfo = tunnelInfo; // ai.m_slopeInfo = slopeInfo; // } // // Returning // foreach (var mainInfo in groundInfos) // { // yield return mainInfo; // } // if (elevatedInfo != null) yield return elevatedInfo; // if (bridgeInfo != null) yield return bridgeInfo; // if (tunnelInfo != null) yield return tunnelInfo; // if (slopeInfo != null) yield return slopeInfo; //} public static NetInfo BuildVersion(this INetInfoBuilder builder, NetInfoVersion version, ICollection <Action> lateOperations) { if (builder.SupportedVersions.HasFlag(version)) { var sw = new Stopwatch(); var basedPrefabName = builder.GetBasedPrefabName(version); var builtPrefabName = builder.GetBuiltPrefabName(version); sw.Start(); var info = Prefabs .Find <NetInfo>(basedPrefabName) .Clone(builtPrefabName); sw.Stop(); Debug.Log($"cloned {builder.BasedPrefabName} as {builder.Name} in {sw.ElapsedMilliseconds}"); builder.BuildUp(info, version); var lateBuilder = builder as INetInfoLateBuilder; if (lateBuilder != null) { var swl = new Stopwatch(); swl.Start(); lateOperations.Add(() => lateBuilder.LateBuildUp(info, version)); swl.Stop(); Debug.Log($"cloned {builder.BasedPrefabName} in {swl.ElapsedMilliseconds}"); } return(info); } else { return(null); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { base.LoadContent(); Background = new Background(this); Background.ChangeBackground("BackgroundTextureOne"); SpriteManager.Add(Background); TextureManager = new Managers.ContentManager(this); /* Top Wall */ SpriteManager.Add(new WallSprite(this, new Vector2(0, -HUD.Height / 2f), HUD.Width, 30)); /* Left Wall */ SpriteManager.Add(new WallSprite(this, new Vector2(-HUD.Width / 2f, 0), 30, HUD.Height)); /* Right Wall */ SpriteManager.Add(new WallSprite(this, new Vector2(HUD.Width / 2f - 15, 0), 30, HUD.Height)); /* Bottom Wall */ SpriteManager.Add(new WallSprite(this, new Vector2(0, HUD.Height / 2f - 15), HUD.Width, 30)); ToolBox = new Display.ToolBox(this); HUD.HUDObjects.Add(ToolBox); Player = new Player(this); Prefabs.CreatePrefabs(this); SetupDebug(); }
public void DropLoot() { if (dropped) { return; } var coins = Random.Range(config.MinCoins, config.MaxCoins + 1); for (var i = 0; i < coins; i++) { var coin = Prefabs.Get <Coin>(); coin.transform.position = transform.position; } var hearts = Random.Range(config.MinHearts, config.MaxHearts + 1); for (var i = 0; i < hearts; i++) { var heart = Prefabs.Get <Heart>(); heart.transform.position = transform.position; } dropped = true; }
public override async Task DoActionAsync() { for (int i = 0; i < Amount; i++) { GameObject ins = Prefabs.Instantiate(Identify, GameArgs.World.transform); CoreBase[] targets = (from a in GameArgs.World.GetComponentsInChildren <TroopCore>() where a.Team == AgentTeam.Ally && a.Type == AgentType.Troop select a).ToArray(); if (targets.Length == 0) { targets = (from a in GameArgs.World.GetComponentsInChildren <BuildingCore>() where a.Team == AgentTeam.Ally && a.Identify != 20001 select a).ToArray(); } if (targets.Length == 0) { targets = (from a in GameArgs.World.GetComponentsInChildren <BuildingCore>() where a.Team == AgentTeam.Ally select a).ToArray(); } float posX = Naukri.Random.Objects(targets).transform.position.x + Random.Range(-5f, 0); if (posX < -35) { posX = -35 + +Random.Range(5f, 0); } ins.transform.position = new Vector3(posX, Random.Range(-1f, 10f), 0); ins.GetComponent <CoreBase>().SetTeam(AgentTeam.Enemy); await Awaiters.Seconds(0.1f); } await Awaiters.Seconds(2f); }
void OnEnable() { contentGrid.DeleteAllChild(); ShopItem = new List <ItemData>(); if (GameCtrl.firstbuy) { Init(); GameCtrl.firstbuy = false; } else { string data = PlayerPrefs.GetString("SellItem"); ShopItem = JsonMapper.ToObject <List <ItemData> >(data); } isBuy = new bool[ShopItem.Count]; for (int i = 0; i < ShopItem.Count; i++) { GameObject go = Prefabs.Load("Prefabs/SHop/SellCell", contentGrid); go.GetComponent <SellCellView>().DisPlay(ShopItem[i]); isBuy[i] = false; } SelecteItem = ShopItem[0]; SellItem = ShopItem; desview.DisPlay(SelecteItem); }
// --- void Start() { rigidbody = GetComponent <Rigidbody>(); collider = GetComponent <CapsuleCollider>(); animator = GetComponent <Animator>(); liver = GetComponent <Liver>(); trigger = GetComponentInChildren <Trigger>(); trigger.OnStay = OnChildTriggerStay; camera = Camera.main.transform; startGravity = Gravity; liver.Health = Game.PlayerHealth ?? liver.Health; potionCount = Game.PotionCount ?? potionCount; if (SceneManager.GetActiveScene().name != "OutsideCave") { var ui = Instantiate(Prefabs.Get("PlayerUi"), GameObject.FindGameObjectWithTag("Canvas").transform); liver.SetUi(GameObject.FindGameObjectWithTag("PlayerUiPanel").GetComponent <RectTransform>()); potionCountUi = GameObject.FindGameObjectWithTag("PotionUiText").GetComponent <TextMeshProUGUI>(); } start = NormalStart; update = NormalUpdate; exit = NormalExit; if (Game.spawnPosition != null) { transform.position = Game.spawnPosition.Value; Game.spawnPosition = null; } }
private static GameObject GetEffect(string effectName, string spellId = "", bool isMoveable = false) { GameObject result; if (isMoveable) { result = Instances.GetMoveableSpell(spellId, effectName); if (result == null) { Log.Error($"Moveable spell {spellId}.{effectName} not found!"); } else { Log.Warning($"Moveable spell {spellId}.{effectName} FOUND!"); return(result); } } string prefabName = Effects.GetIndividualEffectName(EffectParameters.GetEffectNameOnly(effectName)); Log.Debug($"GetEffect() - prefabName = \"{prefabName}\""); if (Prefabs.Has(prefabName)) { Log.Debug($"Cloning..."); result = Prefabs.Clone(effectName); } else { Log.Debug($"CompositeEffect.CreateKnownEffect(\"{effectName}\")"); result = CompositeEffect.CreateKnownEffect(effectName); } PrepareEffect(result); return(result); }
// Use this for initialization void Start() { myPrefabs = prefabs.GetComponent <Prefabs>(); myCam = mainCamera.GetComponent <Camera>(); MakeMap(); RenderWholeMap(); }
private async Task CallbackEntity(Nuid id, EntityEvent entity_event, NList args) { string entity_type = Global.NULL_STRING; Entity entity = EntityManager.Get(id); if (entity != null) { entity_type = entity.Type; } else { entity_type = await GetCacheType(id); } EntityPrefab entity_prefab = Prefabs.GetEntity(entity_type); if (entity_prefab == null) { return; } if (entity_prefab.ancestors != null && entity_prefab.ancestors.Count > 0) { for (int i = entity_prefab.ancestors.Count - 1; i >= 0; i--) { string parent_type = entity_prefab.ancestors[i]; await NModule.CallbackEntity(this, id, parent_type, entity_event, args); } } await NModule.CallbackEntity(this, id, entity_type, entity_event, args); }
public override GameObject GeneralInstant() { GameObject newCard = Object.Instantiate(Prefabs.GetInstance().SpellCardPrefab); return(newCard); //throw new System.NotImplementedException(); }
public void Shoot() { shootTime = shootDuration; List <Vector3> directions = !Diagonol ? new List <Vector3>() { new Vector3(1, 0, 0), new Vector3(-1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1), } : new List <Vector3>() { new Vector3(1, 0, 1), new Vector3(1, 0, -1), new Vector3(-1, 0, 1), new Vector3(-1, 0, -1), }; Sounds.Play("Cough", transform.position); foreach (Vector3 direction in directions) { Rigidbody instance = Instantiate(Prefabs.Get("Bullet"), transform.position, Quaternion.identity).GetComponent <Rigidbody>(); instance.velocity = direction * 10; } }
public static void SetBusLaneProps(this NetInfo.Lane lane) { var prop = Prefabs.Find <PropInfo>("BusLaneText", false); if (prop == null) { return; } if (lane.m_laneProps == null) { lane.m_laneProps = ScriptableObject.CreateInstance <NetLaneProps>(); lane.m_laneProps.m_props = new NetLaneProps.Prop[] { }; } else { lane.m_laneProps = lane.m_laneProps.Clone(); } lane.m_laneProps.m_props = lane .m_laneProps .m_props .Union(new NetLaneProps.Prop { m_prop = prop, m_position = new Vector3(0f, 0f, 7.5f), m_angle = 180f, m_segmentOffset = -1f, m_minLength = 8f, m_startFlagsRequired = NetNode.Flags.Junction }) .ToArray(); }
async void Update() { tick += Time.deltaTime; if (tick > tickDestination) { currentLetter = alphabet.Random(); tick = 0; tickDestination = new FloatRange(1.25f, 5f).RandomValue(); hex = ColorUtility.ToHtmlStringRGBA(new Color( new FloatRange(0.5f, 1).RandomValue(), new FloatRange(0.5f, 1).RandomValue(), new FloatRange(0.5f, 1).RandomValue(), 1 )); } pleasePress.text = $"Please press <color=#{hex}>\"{currentLetter}\"</color> to start this experience."; foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode))) { if (Input.GetKey(vKey) && vKey.ToString() == currentLetter && !Game.IsTransitioning) { await Game.LoadAsync("InsideHome", Prefabs.Get <SceneTransition>("WipeSceneTransition"), 1); Instantiate(Prefabs.Get("Camera")); } } }
// Update is called once per frame public void DisPlay(List <ItemData> EquipItemList) { if (SpendIcon == null) { SpendIcon = new Transform[5]; for (int i = 0; i < transform.Find("SpendGroup").childCount; i++) { SpendIcon[i] = transform.Find("SpendGroup").GetChild(i); } } Gird.DeleteAllChild(); for (int i = 0; i < 5; i++) { SpendIcon[i].gameObject.GetComponent <Image>().color = Color.white; } spendnum = 0; for (int i = 0; i < EquipItemList.Count; i++) { GameObject go = Prefabs.Load("Prefabs/Bag/ItemIcon", Gird); go.GetComponent <ItemIcon>().Display(EquipItemList[i]); spendnum += EquipItemList[i].Spend; } for (int i = 0; i < spendnum; i++) { SpendIcon[i].gameObject.GetComponent <Image>().color = Color.red; } }
private void OnTriggerStay(Collider other) { if (liver == null || liver.IsInvincible) { return; } if (other.CompareTag("HurtEnvironment") || other.CompareTag("HurtPlayer")) { scene.fight = true; Player player = other.GetComponentInParent <Player>(); if (player != null) { player.LandedHit(gameObject); } else { IHurter hurter = other.GetComponent <IHurter>(); if (hurter != null) { hurter.LandedHit(gameObject); } } animator.SetInteger("State", 2); liver.TakeDamage(1); Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity); Vector3 direction = other.transform.position - transform.position; direction.Normalize(); } }
//private AsyncOperation asy = null; public void Change() { Time.timeScale = 1; Prefabs.SceneSwitch( "Main", null ); }
public SceneViewModel(SceneListViewModel vm, Scene scene) { parentVM = vm; EditSceneCommand = new RelayCommand(new Action <object>(EditScene)); MoveSceneUpCommand = new RelayCommand(new Action <object>(MoveSceneUp)); MoveSceneDownCommand = new RelayCommand(new Action <object>(MoveSceneDown)); DeleteCommand = new RelayCommand(new Action <object>(DeleteScene)); EditStepsCommand = new RelayCommand(new Action <object>(EditSteps)); SaveChangesCommand = new RelayCommand(new Action <object>(SaveChanges)); if (scene == null) { this.scene = new Scene(); } else { this.scene = scene; } while (this.scene.prefabs.Count < 4) { AddPrefab(); } foreach (PrefabInfo prefabInfo in this.scene.prefabs) { Prefabs.Add(prefabInfo.modelName); PrefabPositions.Add(prefabInfo.position); } }
void Update() { animator.SetInteger("State", animationState); if (animationState == 1) { shootTime -= Time.deltaTime; if (shootTime <= 0) { shootTime = shootDuration; animationState = 2; } } if (liver != null && liver.Health <= 0) { Instantiate(Prefabs.Get("HitEffect"), transform.transform.position, Quaternion.identity); if (healthUi != null) { Destroy(healthUi); } Destroy(gameObject); } }
public void ModifyExistingNetInfo() { var highwayRampInfo = Prefabs.Find <NetInfo>(NetInfos.Vanilla.HIGHWAY_RAMP, false); if (highwayRampInfo != null) { highwayRampInfo.m_UIPriority = 5; var thumbnails = AssetManager.instance.GetThumbnails(NetInfos.Vanilla.HIGHWAY_RAMP, @"Roads\Highways\HighwayRamp\thumbnails.png"); highwayRampInfo.m_Atlas = thumbnails; highwayRampInfo.m_Thumbnail = thumbnails.name; } var highway3L = Prefabs.Find <NetInfo>(NetInfos.Vanilla.HIGHWAY_3L, false); if (highway3L != null) { highway3L.m_UIPriority = 30; var thumbnails = AssetManager.instance.GetThumbnails(NetInfos.Vanilla.HIGHWAY_3L, @"Roads\Highways\Highway3L\thumbnails.png"); highway3L.m_Atlas = thumbnails; highway3L.m_Thumbnail = thumbnails.name; highway3L.ModifyTitle("Three-Lane Highway"); } var highway3LBarrier = Prefabs.Find <NetInfo>(NetInfos.Vanilla.HIGHWAY_3L_BARRIER, false); if (highway3LBarrier != null) { highway3LBarrier.m_UIPriority = 35; var thumbnails = AssetManager.instance.GetThumbnails(NetInfos.Vanilla.HIGHWAY_3L_BARRIER, @"Roads\Highways\Highway3LBarrier\thumbnails.png"); highway3LBarrier.m_Atlas = thumbnails; highway3LBarrier.m_Thumbnail = thumbnails.name; highway3LBarrier.ModifyTitle("Three-Lane Highway with Sound Barrier"); } }
public static T BuildEmergencyFallback <T>(this IPrefabBuilder <T> builder) where T : PrefabInfo { return(Prefabs .Find <T>(builder.BasedPrefabName) .Clone(builder.Name)); }
void Start() { Sounds.Play("Wind", null, true); Camera.main.transform.position = target1.transform.position; Camera.main.transform.eulerAngles = target1.transform.eulerAngles; texts = startUi.GetComponentsInChildren <TextMeshProUGUI>().ToList(); player = FindObjectOfType <Player>(); player.gameObject.SetActive(false); signTrigger.Execute = (_) => { Note.SetActive(true); noteCooldown = 0.25f; }; signTrigger.OnExit = (_) => { Note.SetActive(false); }; EntranceTrigger.OnEnter = (Collider other) => { if (other.CompareTag("Player")) { _ = Game.LoadAsync("Cave", Prefabs.Get <SceneTransition>("FadeSceneTransition")); } }; }
private void OnEnable() { CharacterEquipItem = new List <ItemData>(); AllItem.DeleteAllChild(); string Equipdata = PlayerPrefs.GetString("CharacterItem"); CharacterEquipItem = JsonMapper.ToObject <List <ItemData> >(Equipdata); // CharacterItem = ReadAllItemJson.readallItemJson(); string Buydata = PlayerPrefs.GetString("BuyenItem"); CharacterItem = JsonMapper.ToObject <List <ItemData> >(Buydata); for (int i = 0; i < CharacterItem.Count; i++) { GameObject go = Prefabs.Load("Prefabs/Bag/ItemIcon", Gird); go.GetComponent <ItemIcon>().Display(CharacterItem[i]); } ChoosenItem = CharacterItem[0]; Debug.Log(ChoosenItem); ItemDetailsView.DisPlay(ChoosenItem); }
//public static PlayerData StrLevelUp(RowEquipment data) //{ // PlayerData player = ReadData(); // if (data.strLevel >= 10) { // Prefabs.Alert("强化已满!", null); // return player; // } // if (player.gold < data.price) { // Prefabs.Alert("金币不足!", null); // return player; // } // for (int i = 0; i < player.equips.Count; i++) // { // if (player.equips[i].equipmentID == data.equipmentID && player.equips[i].strLevel == data.strLevel) // { // player.equips[i].count -= 1; // player.gold -= 200; // if (player.equips[i].count == 0) // { // player.equips.RemoveAt(i); // } // break; // } // } // bool isAdd = false; // for (int i = 0; i < player.equips.Count; i++) // { // if (player.equips[i].equipmentID == data.equipmentID && player.equips[i].strLevel == data.strLevel + 1) // { // player.equips[i].count += 1; // isAdd = true; // break; // } // } // if (!isAdd) // { // Equip equip = new Equip(); // equip.equipmentID = data.equipmentID; // equip.count = 1; // equip.strLevel = data.strLevel + 1; // player.equips.Add(equip); // } // Prefabs.Alert("强化成功,消耗200物资", null); // PlayerPrefs.SetString(key, JsonMapper.ToJson(player)); // return player; //} public static PlayerData StrLevelUp(RowEquipment data) { PlayerData player = DynamicDataModel.ReadData(); if (data.strLevel >= 10) { Prefabs.Alert("强化已满!", null); return(player); } if (player.gold < data.price) { Prefabs.Alert("金币不足!", null); return(player); } for (int i = 0; i < player.equips.Count; i++) { if (player.equips[i].equipmentID == data.equipmentID) { player.gold -= 200; player.equips[i].strLevel += 1; break; } } Prefabs.Alert("强化成功,消耗200物资", null); PlayerPrefs.SetString(key, JsonMapper.ToJson(player)); return(player); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); UserInterface.sB = _spriteBatch; Graphics.Start(); HardwareRendering.Start(); ParticleRendering.Start(); //start other big components Input.Start(); //load prefabs and scene Prefabs.Start(); UserInterface.Start(); GameMode.Start(); SceneManager.Start(); SceneManager.LoadScene(loadMenu ? "LevelMenu" : "LevelGame"); Audio.Start(); PostProcessingManager.Instance.Start(_spriteBatch); if (ShowFps) { _font = File.Load <SpriteFont>("Other/font/debug"); } // add skybox //Skybox.Start(); }
// We don't have to fiddle with a 'Hand' instance in this case since this is the enemy. // We just trust and render whatever the master client sends us. void UpdateEnemyCards(int ammount) { // Only makes sense if this is the enemy's hand Assert.IsTrue(side.owner == Owner.ENEMY); int numberOfCardsInEnemyHand = transform.childCount; // No work needed if the total cards remain the same. if (numberOfCardsInEnemyHand == ammount) { return; } // We have to remove cards if (numberOfCardsInEnemyHand > ammount) { for (int i = numberOfCardsInEnemyHand - 1; i >= ammount; i--) { Destroy(myTransform.GetChild(i).gameObject); } } else { // We have to add cards int add = ammount - numberOfCardsInEnemyHand; CardGUI_canvas cardGUIPrefab = Prefabs.Get("cardGUI_canvas").GetComponent <CardGUI_canvas>(); for (int i = 0; i < add; i++) { CardGUI_canvas cardCpy = Instantiate(cardGUIPrefab, myTransform); cardCpy.Location = CardLocation.ENEMY_HAND; } } }
public static NetInfo BuildVersion(this INetInfoBuilder builder, NetInfoVersion version, ICollection <Action> lateOperations) { if (builder.SupportedVersions.HasFlag(version)) { var basedPrefabName = builder.GetBasedPrefabName(version); var builtPrefabName = builder.GetBuiltPrefabName(version); var info = Prefabs .Find <NetInfo>(basedPrefabName) .Clone(builtPrefabName); builder.BuildUp(info, version); var lateBuilder = builder as INetInfoLateBuilder; if (lateBuilder != null) { lateOperations.Add(() => lateBuilder.LateBuildUp(info, version)); } return(info); } else { return(null); } }
void Start() { BaseTower baseTower = Prefabs.Instantiate <BaseTower>(); baseTower.transform.position = Vector3.zero; Energy energy = Prefabs.Instantiate <Energy>(); energy.transform.position = new Vector3(0f, 0f, 5f); Tower tower = Prefabs.Instantiate <Tower>(); tower.transform.position = new Vector3(5f, 0f, 5f); Tower tower2 = Prefabs.Instantiate <Tower>(); tower2.transform.position = new Vector3(7f, 0f, 7f); GameObject goblin = Prefabs.Get <Goblin>(); for (int i = 0; i < 10; i += 1) { GameObject newGoblin = Instantiate(goblin, tower.transform.position, Quaternion.identity); Vector2 rnd = Random.insideUnitCircle.normalized * 5f; newGoblin.transform.Translate(new Vector3(rnd.x, 0f, rnd.y), Space.World); } }
public IReadOnlyList <Entity> GetEntities() { List <Entity> list = _EntityDic.Values.ToList(); list.Sort((x, y) => { EntityPrefab entity_x = Prefabs.GetEntity(x.Type); EntityPrefab entity_y = Prefabs.GetEntity(y.Type); if (entity_x.priority > entity_y.priority) { return(-1); } else if (entity_x.priority == entity_y.priority) { return(0); } else { return(1); } }); return(list); }
private async void ExitTriggered(object source, TriggerEnterEventArgs args) { if (args.Other.CompareTag("Player")) { Game.LoadAsync("Exit", Prefabs.Get <SceneTransition>("FadeSceneTransition")); } }
// Use this for initialization void Awake() { prefabs = GetComponent <Prefabs>(); charHandler = GetComponent <CharacterHandler>(); depthFirst = GetComponent <DepthFirst>(); charFactory = GetComponent <CharacterFactory>(); uiHandler = GetComponent <UIHandler>(); turnHandler = GetComponent <TurnHandler>(); MapGenerator mapGen = GetComponent <MapGenerator>(); mapGen.CreateMap(); depthFirst.Init(); charHandler.Init(); charFactory.Init(); uiHandler.Init(); turnHandler.Init(); GameObject startRoom = GameObject.Find("Room0"); Vector3 pos = startRoom.GetComponent <Room>().GetCenter(); GameObject player = charFactory.CreateCharacter(prefabs.player, pos.x, pos.z); charHandler.SelectUnit(player.GetComponent <Character>()); Camera.main.transform.position = new Vector3(player.transform.position.x, Camera.main.transform.position.y, player.transform.position.z - 4); Vector3 goblinRoom = GameObject.Find("Room1").GetComponent <Room>().GetCenter(); GameObject goblin = charFactory.CreateCharacter(prefabs.goblin, goblinRoom.x, goblinRoom.z); charHandler.characters.Add(player.GetComponent <Character>()); charHandler.enemies.Add(goblin.GetComponent <Character>()); player.AddComponent <MeleeAttack>(); uiHandler.PopulatePanel(player.GetComponent <Character>()); turnHandler.FirstTurn(); }
public static Decal Generate(Prefabs prefab, Point position) { IEnumerable<Decal> q; q = from decal in Area.Current.Decals where decal.Position == position select decal; List<Decal> matches = q.ToList<Decal>(); if (matches.Count == 1) { if (prefab == Prefabs.BloodDrops || prefab == Prefabs.BloodSplatter || prefab == Prefabs.BloodPool) { matches[0].Density++; matches[0].Life = 0; switch (matches[0].Type) { case Types.BloodDrops: if (matches[0].Density < 3) return null; Area.Current.Decals.Remove(matches[0]); return Generate(Prefabs.BloodSplatter, position); case Types.BloodSplatter: if (matches[0].Density < 8) return null; Area.Current.Decals.Remove(matches[0]); return Generate(Prefabs.BloodPool, position); case Types.BloodPool: return null; } } } if (matches.Count > 1) throw new Exception("OMG!"); Decal d = new Decal(); switch (prefab) { case Prefabs.BloodDrops: d.Type = Types.BloodDrops; d.DrawMode = DrawModes.OnlyForegroundColor; d.ForegroundColor = TCODColor.Interpolate(TCODColor.red, new TCODColor(58, 5, 14), 0f); d.Description = "There is some blood on the ground here."; break; case Prefabs.BloodSplatter: d.Type = Types.BloodSplatter; d.DrawMode = DrawModes.Normal; d.Symbol = (char)7; d.ForegroundColor = TCODColor.desaturatedCrimson; d.Description = "There is a splatter of blood here."; break; case Prefabs.BloodPool: d.Type = Types.BloodPool; d.DrawMode = DrawModes.OnlyBackgroundColor; d.BackgroundColor = TCODColor.desaturatedCrimson; d.Description = "A pool of blood covers the ground here."; break; } d.Area = Area.Current; d.Position = position; Area.Current.Decals.Add(d); return d; }
public GameObject GetPrefab(Prefabs pPrefabs) { switch (pPrefabs) { case Prefabs.Card: return CardPrefab; case Prefabs.Pile: return PilePrefab; case Prefabs.CardDummy: return CardDummyPrefab; } return null; System.Diagnostics.Debug.Assert(false, "The prefab does not exist"); }
void Awake() { if(_instance == null) { //If I am the first instance, make me the Singleton _instance = this; DontDestroyOnLoad(this); } else { //If a Singleton already exists and you find //another reference in scene, destroy it! if(this != _instance) Destroy(this.gameObject); } }
void Awake() { m_Colors = Colors; m_Game = Game; m_Music = Music; m_Particles = Particles; m_Prefabs = Prefabs; m_Sprites = Sprites; m_Score = Score; m_SoundFX = SoundFX; m_Timer = Timer; if (!MainMenu) m_Camera = Camera; m_Strings = TextStrings; m_Input = InputHandler; if (MainMenu) m_interMain = MainMenu; else if(HUD) m_interGame = HUD; else if (CreateMode) m_interCreate = CreateMode; }