private void SetBuySlot(Button buySlot, eCharacter name) { buySlot.gameObject.SetActive(true); //이미지 세팅 GameObject imageObject = buySlot.gameObject.transform.Find("Image").gameObject; Image image = imageObject.GetComponent <Image>(); image.sprite = Resources.Load <Sprite>("BuySlotImages/" + name.ToString()); Debug.Log(name.ToString()); ResizeImage(image, imageObject); //이름 세팅 GameObject nameTextObject = buySlot.gameObject.transform.Find("Text").gameObject; Text nameText = nameTextObject.GetComponent <Text>(); nameText.text = name.ToString(); buySlot.onClick.RemoveAllListeners(); buySlot.onClick.AddListener(() => { bool success = BuyWaitCharacter("Prefabs/WaitCharacter/Wait" + name, "WaitCharacter_" + name, name); if (success) { buySlot.gameObject.SetActive(false); } }); }
private bool BuyWaitCharacter(string path, string name, eCharacter characterType) { int waitPositionX = 0; while (waitPositionX < 8) { ChessTile chessTile = tilemap.GetTile <ChessTile>(new Vector3Int(waitPositionX, -1, 0)); if (chessTile != null) { if (chessTile.gameObject == null) { GameObject character = Instantiate(Resources.Load(path)) as GameObject; character.name = name; ChessCharacter cCharacter = character.GetComponent <ChessWaitCharacter>(); character.transform.SetParent(tilemap.transform); cCharacter.SetTilePosition(new Vector3Int(waitPositionX, -1, 0)); cCharacter.SetCharacterType(ChessCharacter.eCharacterType.WAIT); cCharacter.SetChessCharacterType(characterType); chessTile.gameObject = character; return(true); } } waitPositionX++; } return(false); }
private eCharacter GetRandomCharacter() { string name = ""; eCharacter enumCharacter = (eCharacter)Random.Range(0, (int)eCharacter.MAX); return(enumCharacter); }
//Returns false if can't save private bool SaveCharacter() { //White spaces of all TextBoxes are eliminated ControlsTrimTextBoxes(); if (txtName.Text == "") { MessageBox.Show("Character must have a name.", "Character has no name", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (_selectedCharacter == null) { /*If trying to make a new character*/ _bCharacter.CharacterCreate(this.txtName.Text); /*Now this Form references the new character*/ this._selectedCharacter = _bCharacter.GetCharacterNewest(); } CharacterUpdateInformation(); if (_bCharacter.CharacterUpdate(_selectedCharacter) == 0) { MessageBox.Show("Character could not be saved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this._frmParent.UpdateGrid(); UpdateFormText(); MessageBox.Show("Character has been saved.", "Character Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); ControlsSetReadOnly(true); _changesNotSaved = false; return(true); }
public void SpawnCharacter(string path, string name, int tileX, int tileY, eCharacter chessCharacterType, ChessCharacter.eCharacterType characterType) { GameObject character = Instantiate(Resources.Load(path)) as GameObject; character.name = name; ChessCharacter cCharacter = character.GetComponent <ChessCharacter>(); cCharacter.SetTilePosition(new Vector3Int(tileX, tileY, 0)); cCharacter.SetCharacterType(characterType); cCharacter.SetChessCharacterType(chessCharacterType); Debug.Log("Spawn in GameManager"); character.transform.SetParent(tilemap.transform); ChessTile chessTile = tilemap.GetTile <ChessTile>(new Vector3Int(tileX, tileY, 0)); if (chessTile != null) { chessTile.gameObject = character; } GameObject canvas = GameObject.Find("Canvas"); RectTransform canvasRect = canvas.GetComponent <RectTransform>(); //slider transform 세팅 GameObject sliderObject = Instantiate(Resources.Load("Prefabs/UI/HpBar"), hpbarPanel.transform) as GameObject; //sliderObject.transform.SetParent(canvas.transform, false); Slider slider = sliderObject.GetComponent <Slider>(); cCharacter.SetHpBar(slider); }
public string GetCharacterName(eCharacter enumCharacter) { switch (enumCharacter) { case eCharacter.BLOBMINION: name = "BlobMinion"; break; case eCharacter.CYCLOPS: name = "Cyclops"; break; case eCharacter.DETECTIVE: name = "Detective"; break; case eCharacter.DWARF: name = "Dwarf"; break; case eCharacter.IMP: name = "Imp"; break; case eCharacter.PLASMADRONE: name = "PlasmaDrone"; break; case eCharacter.ROYALKNIGHT: name = "RoyalKnight"; break; case eCharacter.SANTA: name = "Santa"; break; case eCharacter.SKELETON: name = "Skeleton"; break; case eCharacter.TAURUS: name = "Taurus"; break; case eCharacter.SPACECADET: name = "SpaceCadet"; break; case eCharacter.WORM: name = "Worm"; break; case eCharacter.DARKKNIGHT: name = "DarkKnight"; break; } return(name); }
private sSpawnCharacter GetSpawnCharacterInfo(eCharacter character, int tileX, int tileY) { sSpawnCharacter sCharacter; sCharacter.character = character; sCharacter.tileX = tileX; sCharacter.tileY = tileY; return(sCharacter); }
public int CharacterDelete(int characterId) { eCharacter characterToDelete = (from character in _charactersList where character.CharacterId == characterId select character).FirstOrDefault(); _charactersList.Remove(characterToDelete); SaveCharactersList(); RetrieveCharactersList(); return(1); }
public int CharacterUpdate(eCharacter characterToUpdate) { eCharacter oldCharacter = (from character in _charactersList where character.CharacterId == characterToUpdate.CharacterId select character).FirstOrDefault(); oldCharacter = characterToUpdate; SaveCharactersList(); RetrieveCharactersList(); return(1); }
public int CharacterUpdateImageDirectories(eCharacter characterToUpdate) { eCharacter oldCharacter = (from character in _charactersList where character.CharacterId == characterToUpdate.CharacterId select character).FirstOrDefault(); oldCharacter.MainPictureDirectory = characterToUpdate.MainPictureDirectory; oldCharacter.ChibiPictureDirectory = characterToUpdate.ChibiPictureDirectory; SaveCharactersList(); RetrieveCharactersList(); return(1); }
public frmCharacter(frmCharactersList frmParent, int characterId) { InitializeComponent(); this._frmParent = frmParent; this._selectedCharacter = _bCharacter.GetCharacters(characterId); if (_selectedCharacter == null) { MessageBox.Show("Could not retrieve character information", "Character not found", MessageBoxButtons.OK, MessageBoxIcon.Error); } ControlsSetReadOnly(true); ControlsUpdateInformation(); _changesNotSaved = false; }
public eCharacter CharacterNewest() { if (_charactersList.Count == 0) { return(null); } int newestCharacterId = _charactersList.Max(character => character.CharacterId); eCharacter newestCharacter = (from character in _charactersList where character.CharacterId == newestCharacterId select character).FirstOrDefault(); return(newestCharacter); }
public int CharacterCreate(string characterName) { eCharacter latestCharacter = CharacterNewest(); int newCharacterId; if (latestCharacter == null) { newCharacterId = 1; } else { newCharacterId = latestCharacter.CharacterId + 1; } eCharacter newCharacter = new eCharacter(newCharacterId, characterName); _charactersList.Add(newCharacter); SaveCharactersList(); RetrieveCharactersList(); return(1); }
/// <summary> /// Updates the selected character's MainPictureDirectory and /// ChibiPictureDirectory in the database. /// </summary> /// <param name="character"> /// Character whose information will be updated. /// </param> /// <returns></returns> public int CharacterUpdateImageDirectories(eCharacter character) { return(_data.CharacterUpdateImageDirectories(character)); }
public string SavePictureFile(bool changeMainPicture, string selectedImageFilePath, eCharacter character) { return(_dataImageFiles.SavePictureFile(changeMainPicture, selectedImageFilePath, character)); }
/// <summary> /// Saves a picture file in proper directory. /// Returns string with short path to that file. /// </summary> /// <param name="saveMainPicture"> /// If true, the file will be saved in Main Picture /// directory. If false, it will be saved in Chibi Picture /// directory. /// </param> /// <param name="selectedImageFilePath"> /// Path to the original image file. /// </param> /// <param name="characterId"> /// CharacterId property of the character whose /// picture file will be updated. /// </param> /// <returns></returns> public string SavePictureFile(bool saveMainPicture, string selectedImageFilePath, eCharacter character) { string selectedImagePath = selectedImageFilePath; string pictureDirectoryShortPath; if (saveMainPicture == true) { pictureDirectoryShortPath = "\\" + MainPictureDirectoryName + "\\" + character.CharacterId.ToString(); } else { pictureDirectoryShortPath = "\\" + ChibiPictureDirectoryName + "\\" + character.CharacterId.ToString(); } string pictureDirectoryFullPath = Directory.GetCurrentDirectory() + pictureDirectoryShortPath; try { if (Directory.Exists(pictureDirectoryFullPath)) { Directory.Delete(pictureDirectoryFullPath, true); } Directory.CreateDirectory(pictureDirectoryFullPath); string pictureFileShortPath = pictureDirectoryShortPath + "\\" + Path.GetFileName(selectedImagePath); string mainPictureFullFilePath = Directory.GetCurrentDirectory() + pictureFileShortPath; File.Copy(selectedImagePath, mainPictureFullFilePath, true); if (saveMainPicture == true) { character.MainPictureDirectory = pictureFileShortPath; } else { character.ChibiPictureDirectory = pictureFileShortPath; } return(pictureFileShortPath); } catch { return(null); } }
/// <summary> /// Updates the database with the provided /// eCharacter information. /// Returns null if fails. /// </summary> /// <param name="character"></param> /// <returns></returns> public int CharacterUpdate(eCharacter character) { return(_data.CharacterUpdate(character)); }