Exemple #1
0
    public override void OnTick()
    {
        if (interactors.Count > 0)
        {
            if (resources.getResourceType(ResourceType.happiness) < resources.getResourceMaxType(ResourceType.happiness))
            {
                spawn_time -= interactors.Count;

                if (spawn_time <= 0)
                {
                    spawn_time = max_spawn_time;
                    if (SFXHandler.GetInstance().CanPlaySpawnSFX)
                    {
                        SFXHandler.GetInstance().PlayRandomFX(spawnAudioClips);
                    }
                    resources.addResourceType(ResourceType.happiness, 1);
                    float      randomX     = Random.Range(0, randomXSpawnVariance) - randomXSpawnVariance / 2f;
                    GameObject instance    = Instantiate(dwarf, this.gameObject.transform.position, this.gameObject.transform.rotation) as GameObject;
                    var        dwarfParent = GameObject.FindGameObjectWithTag("DwarfHolder");
                    instance.transform.parent = dwarfParent.transform;
                    Vector3 newPosition = new Vector3(instance.transform.position.x + randomX, instance.transform.position.y, -1);
                    instance.transform.position = newPosition;
                    instance.GetComponent <Interactor>().Depth = gameObject.GetComponent <Interactable>().Depth;
                }
            }
        }
        if (Tracker != null)
        {
            Tracker.MaxValue     = max_spawn_time;
            Tracker.CurrentValue = max_spawn_time - spawn_time;
        }
    }
Exemple #2
0
    public override void OnTick()
    {
        if (HasFightingTarget && !IsFighting)
        {
            return;
        }

        if (IsFighting)
        {
            if (damageDealer.TickAndCheckIfWeShouldAttack())
            {
                if (FightingTarget == null)
                {
                    TargetChange();
                    return;
                }
                if (SFXHandler.GetInstance().CanPlayAttackSFX)
                {
                    SFXHandler.GetInstance().PlayFX("dwarf_attack");
                }
                FightingTarget.DamageReceiver.OnDamage(this.gameObject, damageDealer.AttackParameter);
            }
            return;
        }
    }
Exemple #3
0
 public override void Demolish()
 {
     if (IsDestructible)
     {
         InteractionResponder.StartDemolish();
         SFXHandler.GetInstance().PlayFX("building_collapse");
     }
 }
Exemple #4
0
 // Enemy AI Loop here
 public override void OnTick()
 {
     // Randomly make some noises
     if (GruntSFX.Length > 0)
     {
         if (SFXHandler.GetInstance().CanPlayEnemyGruntSFX)
         {
             SFXHandler.GetInstance().PlayRandomFX(GruntSFX);
         }
     }
     EnemyLogic.OnTick();
 }
Exemple #5
0
 public void OnStop()
 {
     SFXHandler.GetInstance().PlayFX("ui_click");
     if (consistencyHandler.CurrentInteractorSelection == null)
     {
         Debug.LogWarning("This shouldn't happen, stop was clicked but no interactor was selected");
         return;
     }
     consistencyHandler.CurrentInteractorSelection.OnStop();
     BuildPicker.SetActive(false);
     consistencyHandler.SetDirty();
 }
Exemple #6
0
    public void DisplayTutorial()
    {
        if (DataHandler.Handler.DepthReached < tutorials.Length)
        {
            if (tutorials[DataHandler.Handler.DepthReached] != "")
            {
                gameObject.SetActive(true);
                SFXHandler.GetInstance().PlayFX("ui_message");
                text_field.text = tutorials[DataHandler.Handler.DepthReached];

                Invoke("HideTutorial", DisplayTime);
            }
        }
    }
Exemple #7
0
 // Event called when the "use" button is clicked on the panel
 public void OnUse()
 {
     SFXHandler.GetInstance().PlayFX("ui_click");
     if (consistencyHandler.CurrentInteractorSelection == null)
     {
         Debug.LogWarning("This shouldn't happen, use was clicked but no interactor was selected");
         return;
     }
     if (consistencyHandler.CurrentInteractableSelection == null)
     {
         Debug.LogWarning("This shouldn't happen, use was clicked but no interactable was selected");
         return;
     }
     consistencyHandler.CurrentInteractorSelection.OnUse(consistencyHandler.CurrentInteractableSelection);
     consistencyHandler.SetDirty();
 }
Exemple #8
0
 public void OnDestroyButton()
 {
     SFXHandler.GetInstance().PlayFX("ui_click");
     if (consistencyHandler.CurrentInteractorSelection == null)
     {
         Debug.LogWarning("This shouldn't happen, use was clicked but no interactor was selected");
         return;
     }
     if (consistencyHandler.CurrentInteractableSelection == null)
     {
         Debug.LogWarning("This shouldn't happen, use was clicked but no interactable was selected");
         return;
     }
     // This is like normal OnUse but instead we try to destroy
     consistencyHandler.CurrentInteractorSelection.OnUse(consistencyHandler.CurrentInteractableSelection, true);
     consistencyHandler.SetDirty();
 }
Exemple #9
0
 public void OnSelect(GameObject obj)
 {
     SFXHandler.GetInstance().PlayFX("ui_click");
     if (BuildPicker.GetComponent <PickerStatus>().build_reference)
     {
         BuildPicker.GetComponent <PickerStatus>().Build(obj);
     }
     if (consistencyHandler.CurrentInteractorSelection == null)
     {
         Debug.LogWarning("This shouldn't happen, use was clicked but no interactor was selected");
         return;
     }
     if (consistencyHandler.CurrentInteractableSelection == null)
     {
         Debug.LogWarning("This shouldn't happen, use was clicked but no interactable was selected");
         return;
     }
     consistencyHandler.CurrentInteractorSelection.OnUse(consistencyHandler.CurrentInteractableSelection);
 }
Exemple #10
0
    public void addResourceMaxType(string type, int quantity)
    {
        // Play tavern sound
        if (type == "happiness")
        {
            SFXHandler.GetInstance().PlayFX("max_tavern");
            // Play mine sound
        }
        else
        {
            SFXHandler.GetInstance().PlayFX("max_ore");
        }
        switch (type)
        {
        case "stone":
            max_stone += quantity;
            break;

        case "iron":
            max_iron += quantity;
            break;

        case "gold":
            max_gold += quantity;
            break;

        case "diamond":
            max_diamond += quantity;
            break;

        case "mithril":
            max_mithril += quantity;
            break;

        case "happiness":
            max_happiness += quantity;
            break;
        }
    }
Exemple #11
0
 public override void StopAllWork()
 {
     base.StopAllWork();
     // TODO: temporary audio cue, gotta fix with the real one
     SFXHandler.GetInstance().PlayFX("sfx_build");
 }
Exemple #12
0
 public override void StopAllWork()
 {
     base.StopAllWork();
     SFXHandler.GetInstance().PlayFX("sfx_build");
 }