예제 #1
0
    void PrintSOs()
    {
        string printString = "ScriptableObjects:\n--ContainerFillers--\n";

        ContainerFiller[] toListi = ContainerFiller.GetAll();
        foreach (ContainerFiller s in toListi)
        {
            printString += s.GetDebugString() + "\n";
        }

        printString += "--Effects--\n";
        SOEffect[] toListe = SOEffect.GetAll();
        foreach (SOEffect s in toListe)
        {
            printString += s.GetDebugString() + "\n";
        }

        printString += "--Items--\n";
        SOItem[] toListit = SOItem.GetAll();
        foreach (SOItem s in toListit)
        {
            printString += s.GetDebugString() + "\n";
        }

        printString += "--Recipes--\n";
        SORecipe[] toListre = SORecipe.GetAll();
        foreach (SORecipe s in toListre)
        {
            printString += s.GetDebugString() + "\n";
        }
        printString += "End of ScriptableObjects";

        Debug.Log(printString);
    }
예제 #2
0
    void TestSOs()
    {
        //test ContainerFiller
        {
            ContainerFiller[]        toCheck   = ContainerFiller.GetAll();
            Dictionary <int, string> potionIDs = new Dictionary <int, string>();
            foreach (ContainerFiller s in toCheck)
            {
                if (potionIDs.ContainsKey(s.ID))
                {
                    Debug.LogError("ERROR: ContainerFiller " + s.name + " has the same ID as " + potionIDs[s.ID] + " = " + s.ID);
                }
                else
                {
                    potionIDs.Add(s.ID, s.name);
                }
                // Check for null parameters
                if (s.color == null)
                {
                    Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL Color");
                }
                if (s.onConsumeEffect == null)
                {
                    Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL onConsumeEffect");
                }
                if (s.onGroundModel == null)
                {
                    Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL onGroundModel");
                }
                if (s.texture == null)
                {
                    Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL Texture");
                }
            }
        }

        {
            //test effects
            SOEffect[] toCheck = SOEffect.GetAll();
            Dictionary <int, string> effectIDs = new Dictionary <int, string>();
            foreach (SOEffect s in toCheck)
            {
                if (effectIDs.ContainsKey(s.ID))
                {
                    Debug.LogError("ERROR: SOEffect " + s.name + " has the same ID as " + effectIDs[s.ID] + " = " + s.ID);
                }
                else
                {
                    effectIDs.Add(s.ID, s.name);
                }
            }
        }

        {
            //test items
            SOItem[] toCheck = SOItem.GetAll();
            Dictionary <int, string> itemIDs = new Dictionary <int, string>();
            foreach (SOItem s in toCheck)
            {
                if (itemIDs.ContainsKey(s.ID))
                {
                    Debug.LogError("ERROR: SOItem " + s.name + " has the same ID as " + itemIDs[s.ID] + " = " + s.ID);
                }
                else
                {
                    itemIDs.Add(s.ID, s.name);
                }
                if (s.model == null)
                {
                    Debug.LogError("ERROR: SOItem " + s.name + " has a NULL model");
                }
            }
        }

        {
            //test Recipes
            SORecipe[] toCheck = SORecipe.GetAll();
            Dictionary <int, string> itemIDs = new Dictionary <int, string>();
            foreach (SORecipe s in toCheck)
            {
                if (itemIDs.ContainsKey(s.ID))
                {
                    Debug.LogError("ERROR: SORecipe " + s.name + " has the same ID as " + itemIDs[s.ID] + " = " + s.ID);
                }
                else
                {
                    itemIDs.Add(s.ID, s.name);
                }
                if (s.result == null)
                {
                    Debug.LogError("ERROR: SORecipe " + s.name + " has a NULL result");
                }
                if (s.ingredients == null)
                {
                    Debug.LogError("ERROR: SORecipe " + s.name + " has a NULL ingredients");
                }
                else if (s.ingredients.Length < 2)
                {
                    Debug.LogError("ERROR: SORecipe " + s.name + " has a less than 2 ingredients");
                }
                else
                {
                    foreach (ContainerFiller c in s.ingredients)
                    {
                        if (c == null)
                        {
                            Debug.LogError("ERROR: SORecipe " + s.name + " contains a NULL ingredient in it's list.");
                            break;
                        }
                    }
                }
            }
        }
    }
예제 #3
0
    private void Awake()
    {
        gc = GetComponent <GameController>();
        DeveloperConsole.instance.RegisterCommand("applyeffect", "[ID] Applies a given effect to the player.", DevCommandAddEffect);
        DeveloperConsole.instance.RegisterCommand("removeeffect", "[ID] Removes a given effect from the player.", DevCommandRemoveEffect);

        //sets up the effects below
        SOEffect[] AllEffects = SOEffect.GetAll();
        for (int i = 0; i < AllEffects.Length; i++)
        {
            switch (AllEffects[i].ID)
            {
            case CONSTANTS.EFFECT_NOTHING:
                //nothing
                AllEffects[i].onEffect = Nothing;
                break;

            case CONSTANTS.EFFECT_DEATH:
                // death
                AllEffects[i].onEffect = KillEntity;
                break;

            case CONSTANTS.EFFECT_HEAL:
                // heal
                AllEffects[i].onEffect = HealEntity;
                break;

            case CONSTANTS.EFFECT_CURE:
                AllEffects[i].onEffect = CureEntity;
                break;

            case CONSTANTS.EFFECT_POISON:
                AllEffects[i].onEffect = PoisonEntity;
                break;

            case CONSTANTS.EFFECT_REGEN:
                AllEffects[i].onEffect = HealOverTime;
                break;

            case CONSTANTS.EFFECT_ENLARGE:
                //nothing
                AllEffects[i].onEffect = EnlargeEntity;
                break;

            case CONSTANTS.EFFECT_SHRINK:
                // death
                AllEffects[i].onEffect = ShrinkEntity;
                break;

            case CONSTANTS.EFFECT_LOW_GRAV:
                // heal
                AllEffects[i].onEffect = LowGravEntity;
                break;

            case CONSTANTS.EFFECT_HIGH_GRAV:
                AllEffects[i].onEffect = HighGravEntity;
                break;

            case CONSTANTS.EFFECT_SLOW:
                AllEffects[i].onEffect = SlowEntity;
                break;

            case CONSTANTS.EFFECT_SPEED:
                AllEffects[i].onEffect = SpeedEntity;
                break;

            default:
                Debug.LogError("Effect runner is unable to handle effect " + AllEffects[i].GetDebugString());
                break;
            }
        }
    }