Esempio n. 1
0
 public static bool IsFinite(UsableType usable)
 {
     if (usable == UsableType.Balloon)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
 public static UsableType[] GetUsableTypesFromVariableArray(Variable[] variables)
 {
     UsableType[] usableTypes = new UsableType[variables.Length];
     for (int i = 0; i < usableTypes.Length; i++)
     {
         usableTypes[i] = variables[i].usableType;
     }
     return(usableTypes);
 }
Esempio n. 3
0
    static void Init()
    {
        Type[] componentTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).Where(t => typeof(Component).IsAssignableFrom(t)).Where(t => t.IsPublic).ToArray();

        UsableType gameObjectUsableType = new UsableType(typeof(GameObject));

        UsableType[] defaultUsableTypes = UsableType.GetUsableTypeArray(componentTypes, gameObjectUsableType);

        List <UsableType> exposedRefTypeList = defaultUsableTypes.ToList();

        exposedRefTypeList.Sort();
        s_ExposedReferenceTypes = exposedRefTypeList.ToArray();
    }
Esempio n. 4
0
        public override IUsable GetUsableFactory(UsableType usableType)
        {
            switch (usableType)
            {
            case UsableType.Shield:
                IUsable shield = new Shield();
                return(shield);

            case UsableType.Sword:
                IUsable sword = new Sword();
                return(sword);
            }
            return(null);
        }
    public void FindClosestUsable(UsableType usableType)
    {
        GameObject bestTarget         = null;
        float      closestDistanceSqr = Mathf.Infinity;
        Vector3    currentPosition    = transform.position;

        List <GameObject> listToCheck;

        if (usableType == UsableType.Bush)
        {
            listToCheck = GameObject.Find("GameController").GetComponent <Usables>().Bush;
        }
        else if (usableType == UsableType.House)
        {
            listToCheck = GameObject.Find("GameController").GetComponent <Usables>().House;
        }
        else
        {
            listToCheck = GameObject.Find("GameController").GetComponent <Usables>().Tree;
        }


        foreach (GameObject potentialTarget in listToCheck)
        {
            Vector3 directionToTarget = potentialTarget.transform.position - currentPosition;
            float   dSqrToTarget      = directionToTarget.sqrMagnitude;
            if (dSqrToTarget < closestDistanceSqr)
            {
                closestDistanceSqr = dSqrToTarget;
                bestTarget         = potentialTarget;
            }
        }

        if (usableType == UsableType.Bush)
        {
            Survive.NeirbyBush = bestTarget;
        }
        else if (usableType == UsableType.House)
        {
            Survive.NeirbyHouse = bestTarget;
        }
        else
        {
            Survive.NeirbyTree = bestTarget;
        }

        destinationToObjectif = bestTarget;
    }
Esempio n. 6
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            UsableType other = (UsableType)obj;

            if (other == null)
            {
                throw new ArgumentException("This object is not a Variable.");
            }

            return(name.ToLower().CompareTo(other.name.ToLower()));
        }
Esempio n. 7
0
        public bool GUI(UsableType[] usableTypes)
        {
            bool removeThis = false;

            EditorGUILayout.BeginHorizontal();
            name        = EditorGUILayout.TextField(name);
            m_TypeIndex = EditorGUILayout.Popup(m_TypeIndex, UsableType.GetNamewithSortingArray(usableTypes));
            usableType  = usableTypes[m_TypeIndex];
            value       = EditorGUILayout.ObjectField(value, usableType.type, true);
            if (GUILayout.Button("Remove", GUILayout.Width(60f)))
            {
                removeThis = true;
            }
            EditorGUILayout.EndHorizontal();

            return(removeThis);
        }
Esempio n. 8
0
    string AdditionalNamespacesToString()
    {
        UsableType[] exposedReferenceTypes = Variable.GetUsableTypesFromVariableArray(exposedReferences.ToArray());
        UsableType[] allUsedTypes          = new UsableType[exposedReferenceTypes.Length /*+ behaviourVariableTypes.Length */];
        for (int i = 0; i < exposedReferenceTypes.Length; i++)
        {
            allUsedTypes[i] = exposedReferenceTypes[i];
        }

        string[] distinctNamespaces = UsableType.GetDistinctAdditionalNamespaces(allUsedTypes).Where(x => !string.IsNullOrEmpty(x)).ToArray();
        string   returnVal          = "";

        for (int i = 0; i < distinctNamespaces.Length; i++)
        {
            returnVal += "using " + distinctNamespaces[i] + ";\n";
        }
        return(returnVal);
    }
Esempio n. 9
0
        public Usable(UsableType type, GridSheet sheet)
        {
            this.type = type;
            GSheet    = sheet;

            switch (this.type)
            {
            case UsableType.HealthPot:
                Value = 10;
                break;

            case UsableType.ManaPot:
                Value  = 5;
                Column = 1;
                break;
            }

            Type = ItemType.Usable;
        }
 public abstract IUsable GetUsableFactory(UsableType usableType);
Esempio n. 11
0
 public override IUsable GetUsableFactory(UsableType usableType)
 {
     return(null);
 }
Esempio n. 12
0
 public Variable(string name, UsableType usableType)
 {
     this.name       = name;
     this.usableType = usableType;
 }
Esempio n. 13
0
 public static int GetAmmo(UsableType usable)
 {
     return(data.usableAmmo[(int)usable]);
 }
Esempio n. 14
0
 public static void ModAmmo(UsableType usable, int amount)
 {
     data.usableAmmo[(int)usable] += amount;
 }
Esempio n. 15
0
 public static int GetUsableLevel(UsableType type)
 {
     return(data.usableLevels[(int)type]);
 }
Esempio n. 16
0
 public static void UpgradeUsable(UsableType type)
 {
     data.usableLevels[(int)type]++;
 }