public bool Save() { ImageFormat imgF = Source == Sources.Game ? ImageFormat.Jpeg : ImageFormat.Png; Blocks.UpdateBlocksGroups(); try { Dictionary <string, string> dict = new Dictionary <string, string> { { "Title", Title } }; if (Source == Sources.Workshop) { dict.Add("Creator", Author.ToString()); dict.Add("WorkhopID", WorkshopID.ToString()); } dict.Add("IsAdvanced", Advanced.ToString()); dict.Add("Solved", Solved.ToString()); dict.Add("AllowedBlockTypes", String.Join(",", AllowedBlocks.Select <int, string>(i => i.ToString()))); dict.Add("AdvEnvironment", ((int)Environment).ToString()); dict.Add("AdvInputRate", InputDelay.ToString()); dict.Add("AdvForceConstantInputRatio", ConstantInputRatio.ToString()); dict.Add("AdvCreateInputTops", InputTops.ToString()); dict.Add("AdvNoTopsForOneBlockInputs", NoOneBlockTops.ToString()); dict.Add("Inputs", Blocks.ToBase64(Block.Roles.In)); dict.Add("Outputs", Blocks.ToBase64(Block.Roles.Out)); dict.Add("WorldBlocks", Blocks.ToBase64(Block.Roles.World)); if (keyVals.ContainsKey("PreviewImage")) { dict.Add("PreviewImage", BitmapToBase64(Preview, imgF)); } if (keyVals.ContainsKey("AdvPreviewImage")) { dict.Add("AdvPreviewImage", BitmapToBase64(Screenshot, imgF)); } using (StreamWriter sr = new StreamWriter(Path, false)) { foreach (KeyValuePair <string, string> keyval in dict) { sr.WriteLine(keyval.Key + " = " + keyval.Value); } } } catch { return(false); } Saved = true; return(true); }
protected void Init() { myPosition = gameObject.transform; circleCollider = gameObject.GetComponent <CircleCollider2D>(); rb2D = gameObject.GetComponent <Rigidbody2D>(); inputDelay = new InputDelay(); combatActive = GameState.combatState; if (GameState.GameMovementStopped()) { movementStopped = true; } destinationSetter = gameObject.GetComponent <AIDestinationSetter>(); aIPath = gameObject.GetComponent <AIPath>(); meleeAttack = gameObject.GetComponentInChildren <MeleeAttackSprite>(); audioSource = gameObject.GetComponent <AudioSource>(); sprite = gameObject.GetComponent <SpriteRenderer>(); dyingBreath = gameObject.GetComponent <DyingBreath>(); loot = gameObject.GetComponent <LootPool>(); SetHealth(); SetCombat(); SetVision(); SetAI(); }
// Using Start instead of Awake to ensure Player is initialized first public void Start() { inputDelay = new InputDelay(); playerMovement = player.GetComponent <PlayerController>().GetMovement(); playerCombat = player.GetComponent <PlayerController>().Combat(); }