Ejemplo n.º 1
0
    private void expandArray()
    {
        LootPieceIndividual[] newArray         = new LootPieceIndividual[lootTailArray.Length * 2];
        GameObject[]          newArray_chains  = new GameObject[lootTailArray.Length * 2];
        GameObject[]          newArray_selling = new GameObject[lootTailArray.Length * 2];

        for (int index = 0; index < firstOpenSlotInArray; index++)
        {
            newArray[index]         = lootTailArray[index];
            newArray_chains[index]  = lootTailArray_chains[index];
            newArray_selling[index] = lootTailArray_selling[index];
        }

        lootTailArray         = newArray;
        lootTailArray_chains  = newArray_chains;
        lootTailArray_selling = newArray_selling;
    }
Ejemplo n.º 2
0
    public void addLootToEndOfTail(GameObject lootObject, GameObject newChain, byte lootID, Vector3 BoatPos)
    {
        if (firstOpenSlotInArray >= lootTailArray.Length)
        {
            expandArray();
        }

        if (firstOpenSlotInArray != 0)
        {
            // Debug.Log("Loot tail has items: "+firstOpenSlotInArray);
            lootTailArray[firstOpenSlotInArray] = new LootPieceIndividual(lootObject, lootID,
                                                                          lootTailArray[firstOpenSlotInArray - 1].getLootID(),
                                                                          lootTailArray[firstOpenSlotInArray - 1].getCurrentPosition(),
                                                                          lootTailArray[firstOpenSlotInArray - 1].getCurrentEulerAngles());
        }
        else
        {
            // Debug.Log("Loot tail is empty: "+firstOpenSlotInArray);

            GameObject temp_obj = new GameObject("invisiLoot");
            temp_obj.SetActive(false);

            lootTailArray[0] = new LootPieceIndividual(temp_obj, Constants.interactableID_none,
                                                       Constants.interactableID_none,
                                                       BoatPos,
                                                       temp_obj.transform.eulerAngles);

            lootTailArray[1] = new LootPieceIndividual(lootObject, lootID,
                                                       Constants.interactableID_treasureSmall,
                                                       BoatPos,
                                                       lootObject.transform.eulerAngles);

            temp_obj = Instantiate(newChain, Vector3.zero, Quaternion.identity);
            lootTailArray_chains[0] = temp_obj;
            lootTailArray_chains[0].transform.localScale = Vector3.zero;

            firstOpenSlotInArray = 1;
        }

        lootTailArray_chains[firstOpenSlotInArray] = newChain;
        lootTailArray_chains[firstOpenSlotInArray].transform.localScale = Vector3.zero;

        firstOpenSlotInArray++;
    }