예제 #1
0
    public void Fight()
    {
        ToggleMode(false);
        SetMainText(group.FightText);
        decimal diff = Global.Player.CombatProficiency - group.CombatProficiency;

        if (group.Name.Equals("band of dwarves") || group.Name.Equals("Swamp Settlers"))
        {
            Debug.Log(group.Name);
            GlobalSound.Play(SOUNDS.SWORDFIGHT);
        }
        if (group.Name.Equals("armored knight"))
        {
            GlobalSound.Play(SOUNDS.SWORDDRAW);
        }
        if ((decimal)Random.value < .5m + diff)
        {
            AbstractItem aItem = Catalog.RandomItem(Global.Level);
            Item         item  = new Item(aItem.Name, 1, 0);
            SetFollowUpText("You win the battle, and the " + group.Name + " offers you " + item.Name + ".");
            Global.Player.GiveItem(item);
        }
        else
        {
            int damage = Random.Range(damageRange.X, damageRange.Y + 1);
            SetFollowUpText("You lose the battle taking " + damage.ToString() + " damage.");
            Global.Player.TakeDamage((short)damage);
        }
    }
예제 #2
0
    public void PlayOnce(GlobalSound name)
    {
        Sound s = FindSound(name);

        if (s != null && !s.source.isPlaying)
        {
            s.source.Play();
        }
    }
예제 #3
0
    public void ResumeIfPaused(GlobalSound name)
    {
        Sound s = FindSound(name);

        if (s != null && PausedSounds.Contains(s))
        {
            s.source.Play();
            PausedSounds.Remove(s);
        }
    }
예제 #4
0
    public void PauseIfPlaying(GlobalSound name)
    {
        Sound s = FindSound(name);

        if (s != null && s.source.isPlaying)
        {
            s.source.Pause();
            PausedSounds.Add(s);
        }
    }
예제 #5
0
 public void TakeDamage(short damage)
 {
     currentHealth -= damage;
     Global.Health.ValueChanged(currentHealth);
     GlobalSound.Play(SOUNDS.LOSEHEALTH);
     if (currentHealth <= 0)
     {
         die();
     }
 }
예제 #6
0
    private Sound FindSound(GlobalSound name)
    {
        Sound s = System.Array.Find(GlobalSounds, sound => sound.name == name);

        if (s == null)
        {
            Debug.LogWarning("Sound '" + name + "' does not exist in GlobalSounds Array!");
            return(null);
        }
        return(s);
    }
예제 #7
0
 public void Sell()
 {
     if (Global.Player.Has(item))
     {
         Global.Player.Gold += parentWindow.SellAt(index);
         Global.Player.TakeItem(item);
     }
     else
     {
         Debug.Log("player doesnt have item");
         GlobalSound.Play(SOUNDS.NEGATIVE);
     }
 }
예제 #8
0
 public void Buy()
 {
     if (Global.Player.Gold >= item.Price)
     {
         Global.Player.GiveItem(parentWindow.BuyAt(index));
         updateText();
     }
     else
     {
         Debug.Log("not enough gold");
         GlobalSound.Play(SOUNDS.NEGATIVE);
     }
 }
예제 #9
0
 public void Start()
 {
     source   = GetComponent <AudioSource>();
     instance = this;
 }
예제 #10
0
 void Awake()
 {
     instance = this;
 }
예제 #11
0
 void Awake()
 {
     _audio   = GetComponent <AudioSource>();
     instance = this;
     PlayBGM();
 }
예제 #12
0
 void Awake()
 {
     _audio = GetComponent<AudioSource>();
     instance = this;
     PlayBGM();
 }
예제 #13
0
    public void Stop(GlobalSound name)
    {
        Sound s = FindSound(name);

        s?.source.Stop();
    }
예제 #14
0
    public void Play(GlobalSound name)
    {
        Sound s = FindSound(name);

        s?.source.Play();
    }
예제 #15
0
 void Awake()
 {
     instance = this;
 }
예제 #16
0
 public void Start()
 {
     source = GetComponent<AudioSource>();
     instance = this;
 }