Beispiel #1
0
    /// <summary>
    /// Gets the combat by token. If no prefab matched comboCombat can be found, return default combat.
    /// For example : there are two combo combat defined in prefab: tap + tap + tap + slice (1110) , slice + tap + tap + slice (1001)
    ///               then parameter token = 111 = returned 1110
    ///               parameter token = 1001 = return 1001
    ///               parameter token = 101 = return default combat of gesture type = tap , because no prefab combat can be found
    /// </summary>
    /// <param name="playerComboToken">the player combo token</param>
    /// <param name="gestureType">gesture type</param>
    /// <param name="tokenMatched">output, indicate if the token matched to a prefab combat</param>
    /// <param name="IsLastCombat">output, indicated if the matched combat is the last combat in combo</param>
    /// <returns></returns>
    private PredatorCombatData GetComboCombatByToken(string playerComboToken, UserInputType gestureType, out bool tokenMatched, out bool IsLastCombat)
    {
        PredatorComboCombat comboCombat = null;

        IsLastCombat = false;
        //Search matched prefab combo combat, by playerCombatToken
        foreach (string prefabComboTokenKey in ComboCombatTokenDict.Keys)
        {
            if (prefabComboTokenKey.StartsWith(playerComboToken) && prefabComboTokenKey.Length >= playerComboToken.Length)
            {
                comboCombat  = ComboCombatTokenDict [prefabComboTokenKey];
                IsLastCombat = prefabComboTokenKey.Length == playerComboToken.Length;
                break;
            }
        }
        //If no matched combo combat is found, return the default combat
        if (comboCombat == null)
        {
            tokenMatched = false;
            return(GetDefaultCombat(gestureType));
        }
        else
        {
            tokenMatched = true;
            try{
                return(comboCombat.combat [playerComboToken.Length - 1]);
            }
            catch (Exception exc)
            {
                Debug.LogError(exc);
                return(null);
            }
        }
    }
Beispiel #2
0
    public static PredatorComboCombat[] EditComboCombatData(Predator3rdPersonalUnit Unit,
                                                            PredatorComboCombat[] ComboCombatArray)
    {
        if (GUILayout.Button("Add ComboCombat"))
        {
            PredatorComboCombat ComboCombat = new PredatorComboCombat();
            ComboCombatArray = Util.AddToArray <PredatorComboCombat> (ComboCombat, ComboCombatArray);
        }
        for (int i = 0; i < ComboCombatArray.Length; i++)
        {
            PredatorComboCombat ComboCombat = ComboCombatArray [i];

            if (DynamicEditingComboCombatSwitch.ContainsKey(ComboCombat) == false)
            {
                DynamicEditingComboCombatSwitch [ComboCombat] = false;
            }
            if (DynamicEditingComboCombatSwitch [ComboCombat] = EditorGUILayout.BeginToggleGroup(new GUIContent("------- Edit combo combat:" + ComboCombat.comboName, ""),
                                                                                                 DynamicEditingComboCombatSwitch [ComboCombat]))
            {
                ComboCombat.comboName = EditorGUILayout.TextField("Combo combat name:", ComboCombat.comboName);
                ComboCombat.combat    = EditCombatDataArray(Unit, ComboCombat.combat);

                if (GUILayout.Button("Delete combo combat:" + ComboCombat.comboName))
                {
                    ComboCombatArray = Util.CloneExcept <PredatorComboCombat> (ComboCombatArray, ComboCombat);
                }
            }
            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.Space();
        }
        return(ComboCombatArray);
    }
    public static PredatorComboCombat[] EditComboCombatData(Predator3rdPersonalUnit Unit, 
		                                          PredatorComboCombat[] ComboCombatArray)
    {
        if (GUILayout.Button ("Add ComboCombat")) {
            PredatorComboCombat ComboCombat = new PredatorComboCombat ();
            ComboCombatArray = Util.AddToArray<PredatorComboCombat> (ComboCombat, ComboCombatArray);
        }
        for (int i=0; i<ComboCombatArray.Length; i++) {
            PredatorComboCombat ComboCombat = ComboCombatArray [i];

            if (DynamicEditingComboCombatSwitch.ContainsKey (ComboCombat) == false) {
                DynamicEditingComboCombatSwitch [ComboCombat] = false;
            }
            if (DynamicEditingComboCombatSwitch [ComboCombat] = EditorGUILayout.BeginToggleGroup (new GUIContent ("------- Edit combo combat:" + ComboCombat.comboName, ""),
                       DynamicEditingComboCombatSwitch [ComboCombat])) {

                ComboCombat.comboName = EditorGUILayout.TextField ("Combo combat name:", ComboCombat.comboName);
                ComboCombat.combat = EditCombatDataArray (Unit, ComboCombat.combat);

                if (GUILayout.Button ("Delete combo combat:" + ComboCombat.comboName)) {
                    ComboCombatArray = Util.CloneExcept<PredatorComboCombat> (ComboCombatArray, ComboCombat);
                }
            }
            EditorGUILayout.EndToggleGroup ();
            EditorGUILayout.Space ();
        }
        return ComboCombatArray;
    }