private void AddComponents() { SpriterReader reader = new SpriterReader(); SpriterImporter importer = new SpriterImporter(); var model = reader.Read(importer.Import(Path.Combine("Content\\Spriter", "player.scml")), null, game.Content, game.GraphicsDevice); Animator = new FarmPlayerAnimator(this, model, "player"); //Animator.AnimationEnded += Animator_AnimationEnded; Animator.Scale = 1.0f; animationComponent = new AnimationComponent(this, Animator, "idle_down"); Components.AddComponent(animationComponent); Components.AddComponent(new ExclamationMarkDrawer(game, this)); Components.AddComponent(new MessageBoxComponent(game, this)); Components.AddComponent(Inventory = new PlayerInventory(this)); Components.AddComponent(viewComponent = new ViewComponent(new Vector2(0, 1))); CreateTools(); WidgetManager widgets = new WidgetManager(game, this); widgets.AddWidget(new ItemWidget(game, this, widgets, "Tool widget")); widgets.AddWidget(new TimeWidget(game, this, widgets, "Time and date widget")); Components.AddComponent(widgets); }
public PlayerHUD(GameObject parent) { health = parent.GetComponent <Health>(); gun = parent.GetComponent <Gun>(); health.OnDamageTaken += HealthChanged; gun.OnAmmoChange += GunChange; gun.OnWeaponChange += GunChange; gun.OnReloadProgress += UpdateReloadBar; healthBarWidget.SetProgress(health.GetPercentage()); WidgetManager.AddWidget(healthBarWidget); WidgetManager.AddWidget(healthBarBackground); currentGunWidget = gunIcons[typeof(PistolBullet)]; var iconEnd = currentGunWidget.GetScreenEndPoint(); ammoDisplayWidget = new TextWidget(new Vector2(iconEnd.X + 0.01f, currentGunWidget.position.Y)); WidgetManager.AddWidget(ammoDisplayWidget); float barSize = iconEnd.X - currentGunWidget.position.X; reloadBarWidget = new ProgressBarWidget(new Vector2(currentGunWidget.position.X, iconEnd.Y + 0.01f), new Vector2(barSize, 0)) { Texture = SpriteContainer.Instance.GetImage("reloadTime"), SourceRectangle = new Rectangle(0, 0, 80, 4) }; reloadBarWidget.SetProgress(0); WidgetManager.AddWidget(reloadBarWidget); GunChange(gun); }
public void Load() { Console.WriteLine("dead monkey"); List <Rectangle> idle01 = new List <Rectangle>(); for (int i = 0; i < height; ++i) { idle01.Add(new Rectangle(i * size, 0, size, size)); } AddComponent(new Graphics.Sprite(this, "monkey", idle01)); AddComponent(new Graphics.StackAnimator(this)); //UMIERANIE List <Rectangle> dead01 = new List <Rectangle>(); for (int i = 0; i < height; ++i) { dead01.Add(new Rectangle(i * size, size * 8, size, size)); } List <Rectangle> dead02 = new List <Rectangle>(); for (int i = 0; i < height; ++i) { dead02.Add(new Rectangle(i * size, size * 9, size, size)); } GetComponent <Graphics.StackAnimator>().AddAnimation( new Graphics.StackAnimation("Dead", GetComponent <Graphics.Sprite>(), new List <List <Rectangle> > { idle01, dead01, dead02 }, 298, false)); Audio.AudioManager.Instance.PlayerTransform = transform; GetComponent <Graphics.StackAnimator>().SetAnimation("Dead"); DeadPrompt = new TextWidget(new Vector2(0.1f, 0.1f)) { DisplayString = "Monkey died.\nClick here to restart level", IsButton = true }; DeadPrompt.OnClick += Restart; WidgetManager.AddWidget(DeadPrompt); HealthFx = EffectContainer.Instance.GetEffect("HealthFX"); HealthFx.Parameters["healthLeft"].SetValue(0.0f); ViewManager.Instance.activeEffects.Add(HealthFx); }
private void GunChange(Gun gun) { AmmoInfo currentAmmo = gun.currentClip.GetAmmoInfo(); WidgetManager.RemoveWidget(currentGunWidget); currentGunWidget = gunIcons[currentAmmo.type]; WidgetManager.AddWidget(currentGunWidget); string ammoString = currentAmmo.loaded.ToString() + "/" + (currentAmmo.reservesLeft >= 0 ? currentAmmo.reservesLeft.ToString() : infSymbol); ammoDisplayWidget.DisplayString = ammoString; reloadBarWidget.SetProgress(gun.GetReloadLeft()); }
public JsonResult CodeGenerate(string entity, List <JPropertyInfo> props) { try { string templates = Config.Root + "Templates"; if (!Directory.Exists(templates)) { Directory.CreateDirectory(templates); } string component = Config.Root + "Templates\\Components"; if (!Directory.Exists(component)) { Directory.CreateDirectory(component); } //Generate scripts directories string script = Config.ScriptProject + "\\Scripts"; if (!Directory.Exists(script)) { Directory.CreateDirectory(script); } script = Config.ScriptProject + "\\Scripts\\Controllers"; if (!Directory.Exists(script)) { Directory.CreateDirectory(script); } script = Config.ScriptProject + "\\Scripts\\Services"; if (!Directory.Exists(script)) { Directory.CreateDirectory(script); } //services script = Config.ServiceProject + "\\Interfaces"; if (!Directory.Exists(script)) { Directory.CreateDirectory(script); } script = Config.ServiceProject + "\\Implementation"; if (!Directory.Exists(script)) { Directory.CreateDirectory(script); } ICode code = new TemplateCode(); System.IO.File.WriteAllText(component + "\\" + entity + ".html", code.CodeGenerate(entity, props)); code = new JSController(); code.Config = this.Config; System.IO.File.WriteAllText(Config.ScriptProject + "\\Scripts\\Controllers\\" + entity + "Ctrl.cs", code.CodeGenerate(entity, props)); code = new JSService(); code.Config = this.Config; System.IO.File.WriteAllText(Config.ScriptProject + "\\Scripts\\Services\\" + entity + "Service.cs", code.CodeGenerate(entity, props)); code = new CSController(); System.IO.File.WriteAllText(Config.Root + "Controllers\\" + entity + "Controller.cs", code.CodeGenerate(entity, props)); code = new CSServiceInterface(); System.IO.File.WriteAllText(Config.ServiceProject + "\\Interfaces\\I" + entity + "Service.cs", code.CodeGenerate(entity, props)); code = new CSServiceImplementation(); System.IO.File.WriteAllText(Config.ServiceProject + "\\Implementation\\" + entity + "Service.cs", code.CodeGenerate(entity, props)); WidgetManager widgetManager = new WidgetManager(); widgetManager.RootPath = Config.Root; widgetManager.AddWidget(new JwtWidget { Name = entity, PropertyList = props }); return(Json(new { message = "Successfully Generated." })); } catch (Exception ex) { return(Json(new { message = ex.ToString() })); } }