void OnTriggerEnter(Collider other) { CharacterHP hp = other.GetComponent <CharacterHP>(); if (!hp) { return; } if (SoundManager.Instance && collectSFX) { SoundManager.Instance.PlayGlobalSFX(collectSFX); } if (collectVFX) { GameObject vfxInstance = Instantiate(collectVFX, this.transform.position, Quaternion.identity); } if (mt == MeType.HP) { hp.RecoverHP(recoverAmount); } else if (mt == MeType.MP) { hp.RecoverMP(recoverAmount); } Destroy(this.gameObject); }
/* * Set all the Label.Text variables to its assosiated element. * Param Nothing. * Returns Nothing. */ private void InitializeStats() { Character.Text = dungeon.user.Character; CharacterName.Text = dungeon.user.Username; CharacterHealth.Text = CharacterHP.ToString(); CharacterMana.Text = CharacterMP.ToString(); Boss.Text = dungeon.CurrentBoss; BossName.Text = dungeon.CurrentName; BossHealth.Text = BossHP.ToString(); }
void Awake() { Debug.Log("Character Awake!"); rb = GetComponent <Rigidbody>(); cpc = GetComponent <CapsuleCollider>(); spr = GetComponentInChildren <SpriteRenderer>(); ads = GetComponent <AudioSource>(); chp = GetComponent <CharacterHP>(); cmm = GetComponent <CharacterMovement>(); csc = GetComponentInChildren <CharacterSkillController>(); cbc = GetComponentInChildren <CharacterBuffController>(); mcData = Instantiate(dataDefault); ResetAllCharacterData(); }
void Start() { audioSource = GetComponent <AudioSource>(); player = FPSCharacterController.Instance.GetComponent <CharacterHP>(); if (fireFlarePrefab != null) { fireFlare = Instantiate(fireFlarePrefab, muzzlePos); fireFlare.transform.localPosition = Vector3.zero; fireFlare.gameObject.SetActive(false); } wait.Initialize(this); move.Initialize(this); attack.Initialize(this); currentState = wait; }
void OnTriggerEnter(Collider other) { ShootableObjectHP shp = other.GetComponent <ShootableObjectHP>(); if (shp != null) { shp.TakeDamageAsBlock(this.transform.position); this.gameObject.SetActive(false); return; } CharacterHP chp = other.GetComponent <CharacterHP>(); if (chp != null) { chp.TakeDamage(damage); } }
private void CreateItemDisplay(ItemModel item, List <ItemModel> list) { var frame = new Frame(); frame.CornerRadius = 5; frame.Padding = new Thickness(15, 15, 5, 15); var layout = new StackLayout(); layout.Orientation = StackOrientation.Horizontal; var Name = new Label(); Name.Text = item.item; Name.VerticalTextAlignment = TextAlignment.Center; Name.Margin = new Thickness(0, 0, 10, 0); Name.FontAttributes = FontAttributes.Bold; if (item.item.Contains("HealthPotion")) { Name.TextColor = Color.FromHex("#F44336"); frame.BorderColor = Color.FromHex("#F44336"); Name.FontAttributes = FontAttributes.Bold; } else { Name.TextColor = Color.DarkTurquoise; frame.BorderColor = Color.DarkTurquoise; Name.FontAttributes = FontAttributes.Bold; } var extras = new Label(); extras.FontSize = 10; extras.TextColor = Color.Black; extras.Text = string.Format("{0}: {1} - {2} {3}", ItemInfoModel.ObtainItemString(item.item, true), ItemInfoModel.ObtainItemInfo(item.item, true), ItemInfoModel.ObtainItemInfo(item.item, false), ItemInfoModel.ObtainItemString(item.item, false)); extras.HorizontalTextAlignment = TextAlignment.Center; extras.HorizontalOptions = LayoutOptions.CenterAndExpand; extras.VerticalTextAlignment = TextAlignment.Center; var button = new Button(); button.HorizontalOptions = LayoutOptions.EndAndExpand; button.Text = "USE"; button.CornerRadius = 5; button.BackgroundColor = Color.White; button.TextColor = Color.Accent; button.Clicked += async(s, e) => { if (battlesequence) { battlesequence = false; await Task.Run(async() => { Animations.CloseStackLayout(layout, "closing", 30, 500); }); Items.Children.Remove(frame); pots.Remove(item); // Remove off list string invetory = ""; foreach (ItemModel itemInv in pots) { if (!String.IsNullOrEmpty(itemInv.item)) { invetory += itemInv.item + ","; // Create string for file } } UserModel.Rewrite("Items:", invetory, dungeon.items.Localfile); try { dungeon.items.Invfile.Object.Items = invetory; await dungeon.items.UpdateInv(); } catch { } dungeon.itemInv.pots = this.pots; await ItemAbility.FadeTo(0, 200); DisableorEnableFrameLayouts(false, ItemAbility); if (item.item.Contains("HealthPotion")) { int buff = Obtainbuff(item.item); CharacterHP += buff; await Announcer(string.Format("Healed for {0}", buff.ToString()), true); CharacterHealth.Text = CharacterHP.ToString(); CharacterHealth.RelRotateTo(360, 500); await CharacterHealth.ScaleTo(5, 300); await CharacterHealth.ScaleTo(1, 300); } else if (item.item.Contains("MagicPotion")) { int buff = Obtainbuff(item.item); CharacterMP += buff; await Announcer(string.Format("Restored {0} Mana", buff.ToString()), true); CharacterMana.Text = CharacterMP.ToString(); CharacterMana.RelRotateTo(360, 500); await CharacterMana.ScaleTo(5, 300); await CharacterMana.ScaleTo(1, 300); } await Announcer("BOSS TURN", false); BossAttack(); } }; layout.Children.Add(Name); layout.Children.Add(extras); layout.Children.Add(button); frame.Content = layout; Items.Children.Add(frame); }