UpdateAnimation() public method

public UpdateAnimation ( ) : void
return void
    //Turns item at index 995 in britannia castle into a class specific item.

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        ObjectInteraction obj = ObjectLoader.getObjectIntAt(995);

        if (obj == null)
        {
            return;
        }
        Destroy(obj.GetComponent <object_base>());
        switch (UWCharacter.Instance.CharClass)
        {
        //Gloves
        case UWCharacter.CharClassFighter:                //fighter
            obj.item_id           = 38;
            obj.WorldDisplayIndex = 38;
            obj.InvDisplayIndex   = 38;
            obj.gameObject.AddComponent <Gloves>();
            break;

        //Mani stone
        case  UWCharacter.CharClassMage:                //mage
        case  UWCharacter.CharClassBard:                //bard
        case  UWCharacter.CharClassDruid:               //Druid
        case  UWCharacter.CharClassShepard:             //shepherd
            obj.item_id           = 244;
            obj.WorldDisplayIndex = 224;
            obj.InvDisplayIndex   = 244;
            obj.gameObject.AddComponent <RuneStone>();
            break;

        //Shortsword
        case  UWCharacter.CharClassTinker:                //tinker
        case  UWCharacter.CharClassPaladin:               //paladin
            obj.item_id           = 4;
            obj.WorldDisplayIndex = 4;
            obj.InvDisplayIndex   = 4;
            obj.gameObject.AddComponent <WeaponMelee>();
            break;

        //Shield
        case  UWCharacter.CharClassRanger:                //ranger
            obj.item_id           = 60;
            obj.WorldDisplayIndex = 60;
            obj.InvDisplayIndex   = 60;
            obj.gameObject.AddComponent <Shield>();
            break;
        }
        obj.UpdateAnimation();
    }
    /// <summary>
    /// Fishing Code.
    /// </summary>
    private void GoFish()
    {
        int tileX = (int)(UWCharacter.Instance.transform.position.x / 1.2f);
        int tileY = (int)(UWCharacter.Instance.transform.position.z / 1.2f);


        for (int x = -1; x <= 1; x++)
        {        //test the tile and it's neighbours for water.
            for (int y = -1; y <= 1; y++)
            {
                if (GameWorldController.instance.currentTileMap().Tiles[tileX + x, tileY + y].isWater)
                {
                    if (Random.Range(0, 10) >= 7)
                    {                    //catch something or test for encumerance
                        //000~001~099~You catch a lovely fish.
                        if ((GameWorldController.instance.commonObject.properties[182].mass * 0.1f) <= UWCharacter.Instance.playerInventory.getEncumberance())
                        {
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_catch_a_lovely_fish_));
                            GameObject fishy = CreateFish();
                            UWCharacter.Instance.playerInventory.ObjectInHand = fishy.name;
                            ObjectInteraction FishobjInt = fishy.GetComponent <ObjectInteraction>();
                            if (FishobjInt != null)
                            {
                                FishobjInt.UpdateAnimation();
                                //UWHUD.instance.CursorIcon= //FishobjInt.InventoryDisplay.texture;
                                UWHUD.instance.CursorIcon = FishobjInt.GetInventoryDisplay().texture;                                //FishobjInt.InventoryDisplay.texture;
                                FishobjInt.isquant        = 1;
                            }

                            UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
                            InteractionModeControl.UpdateNow = true;
                        }
                        else
                        {                        //000~001~102~You feel a nibble, but the fish gets away.
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_feel_a_nibble_but_the_fish_gets_away_));
                        }
                    }
                    else
                    {                    //000~001~100~No luck this time.
                        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_no_luck_this_time_));
                    }
                    return;
                }
            }
        }
        //000~001~101~You cannot fish there.  Perhaps somewhere else.
        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_cannot_fish_there__perhaps_somewhere_else_));
    }
    private void GoFish()
    {
        int tileX = (int)(playerUW.transform.position.x / 1.2f);
        int tileY = (int)(playerUW.transform.position.z / 1.2f);


        for (int x = -1; x <= 1; x++)
        {        //test the tile and it's neighbours for water.
            for (int y = -1; y <= 1; y++)
            {
                if (GameWorldController.instance.Tilemap.isWater[tileX + x, tileY + y])
                {
                    if (Random.Range(0, 10) >= 7)
                    {                    //catch something or test for encumerance
                        //000~001~099~You catch a lovely fish.
                        if ((ObjectInteraction.Weight[182] * 0.1f) <= playerUW.playerInventory.getEncumberance())
                        {
                            ml.Add(playerUW.StringControl.GetString(1, 99));
                            GameObject fishy = CreateFish();
                            playerUW.playerInventory.ObjectInHand = fishy.name;
                            ObjectInteraction FishobjInt = fishy.GetComponent <ObjectInteraction>();
                            if (FishobjInt != null)
                            {
                                FishobjInt.UpdateAnimation();
                                playerUW.CursorIcon = FishobjInt.InventoryDisplay.texture;
                            }

                            UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
                            InteractionModeControl.UpdateNow = true;
                        }
                        else
                        {                        //000~001~102~You feel a nibble, but the fish gets away.
                            ml.Add(playerUW.StringControl.GetString(1, 102));
                        }
                    }
                    else
                    {                    //000~001~100~No luck this time.
                        ml.Add(playerUW.StringControl.GetString(1, 100));
                    }
                    return;
                }
            }
        }
        //000~001~101~You cannot fish there.  Perhaps somewhere else.
        ml.Add(playerUW.StringControl.GetString(1, 101));
    }
    public bool CombineObject(GameObject InputObject1, GameObject InputObject2)
    {    //Combines two objects per the UW1/UW2 cmb.dat lists
        int[] lstInput1   = new int[8];
        int[] lstInput2   = new int[8];
        int[] lstOutput   = new int[8];
        int[] lstDestroy1 = new int[8];
        int[] lstDestroy2 = new int[8];
        int   ItemID1     = InputObject1.GetComponent <ObjectInteraction>().item_id;
        int   ItemID2     = InputObject2.GetComponent <ObjectInteraction>().item_id;
        bool  Destroyed1  = false;
        bool  Destroyed2  = false;

        //UW1 List
        // a_lit_torch(149)(d:0) + a_block_of_incense_blocks_of_incense(278)(d:1) = a_block_of_burning_incense_blocks_of_burning_incense(277)
        // the_Key_of_Truth(225)(d:1) + the_Key_of_Love(226)(d:1) = a_two_part_key(230)
        // the_Key_of_Truth(225)(d:1) + the_Key_of_Courage(227)(d:1) = a_two_part_key(228)
        // the_Key_of_Love(226)(d:1) + the_Key_of_Courage(227)(d:1) = a_two_part_key(229)
        // the_Key_of_Truth(225)(d:1) + a_two_part_key(229)(d:1) = the_Key_of_Infinity(231)
        // the_Key_of_Love(226)(d:1) + a_two_part_key(228)(d:1) = the_Key_of_Infinity(231)
        // the_Key_of_Courage(227)(d:1) + a_two_part_key(230)(d:1) = the_Key_of_Infinity(231)
        // a_lit_torch(149)(d:0) + an_ear_of_corn_ears_of_corn(180)(d:1) = some_popcorn_bunches_of_popcorn(183)
        // some_strong_thread_pieces_of_strong_thread(284)(d:1) + a_pole(216)(d:1) = a_fishing_pole(299)

        //UW2 List
        //a_pole(216)(d:1) + some_thread&pieces_of_thread(300)(d:1) = a_fishing_pole(299)
        //some_thread&pieces_of_thread(300)(d:1) + a_lump_of_wax&lumps_of_wax(210)(d:1) = a_candle(146)
        //a_lit_torch(149)(d:0) + an_ear_of_corn&ears_of_corn(180)(d:1) = some_popcorn&bunches_of_popcorn(183)
        //a_lit_torch(149)(d:0) + a_honeycomb(186)(d:1) = a_lump_of_wax&lumps_of_wax(210)
        //a_nutritious_wafer(191)(d:1) + a_bottle_of_water&bottles_of_water(188)(d:1) = a_bottle_of_ale&bottles_of_ale(187)

        //Debug.Log ("combining" +ItemID1 + " and " + ItemID2 + " in game " + playerUW.game);
        switch (playerUW.game)
        {
        case 1:        //uw1
        {
            lstInput1 = new int[9] {
                149, 225, 225, 226, 225, 226, 227, 149, 284
            };
            lstDestroy1 = new int[9] {
                0, 1, 1, 1, 1, 1, 1, 0, 1
            };
            lstInput2 = new int[9] {
                278, 226, 227, 227, 229, 228, 230, 180, 216
            };
            lstDestroy2 = new int[9] {
                1, 1, 1, 1, 1, 1, 1, 1, 1
            };
            lstOutput = new int[9] {
                277, 230, 228, 229, 231, 231, 231, 183, 299
            };
        }
        break;

        case 2:        //uw2
            lstInput1 = new int[5] {
                216, 300, 149, 149, 191
            };
            lstDestroy1 = new int[5] {
                1, 1, 0, 0, 1
            };
            lstInput2 = new int[5] {
                300, 300, 180, 186, 188
            };
            lstDestroy2 = new int[5] {
                1, 1, 1, 1, 1
            };
            lstOutput = new int[5] {
                299, 146, 183, 210, 187
            };
            break;
        }

        for (int i = 0; i <= lstInput1.GetUpperBound(0); i++)
        {
            //Debug.Log (i + " is " + lstInput1[i] + " and " + lstInput2[i]);
            if
            (                    //Check both input lists for the two items
                ((ItemID1 == lstInput1[i]) && (ItemID2 == lstInput2[i]))
                ||
                ((ItemID2 == lstInput1[i]) && (ItemID1 == lstInput2[i]))
            )
            {                    //Matching combination.
                Debug.Log("Creating a " + lstOutput[i]);
                if ((lstInput1[i] == ItemID1) && (lstDestroy1[i] == 1) && (Destroyed1 == false))
                {
                    Debug.Log("Destroying " + InputObject1.name);
                    Destroyed1 = true;
                }
                if ((lstInput1[i] == ItemID2) && (lstDestroy1[i] == 1) && (Destroyed2 == false))
                {
                    Debug.Log("Destroying " + InputObject2.name);
                    Destroyed2 = true;
                }
                if ((lstInput2[i] == ItemID1) && (lstDestroy2[i] == 1) && (Destroyed1 == false))
                {
                    Debug.Log("Destroying " + InputObject1.name);
                    Destroyed1 = true;
                }
                if ((lstInput2[i] == ItemID2) && (lstDestroy2[i] == 1) && (Destroyed2 == false))
                {
                    Debug.Log("Destroying " + InputObject2.name);
                    Destroyed2 = true;
                }

                if (Destroyed1 == true)
                {
                    InputObject1.GetComponent <ObjectInteraction>().consumeObject();
                }
                if (Destroyed2 == true)
                {
                    InputObject2.GetComponent <ObjectInteraction>().consumeObject();
                }

                //Create the new object
                GameObject myObj = new GameObject("SummonedObject_" + playerUW.PlayerMagic.SummonCount++);
                myObj.layer = LayerMask.NameToLayer("UWObjects");
                myObj.transform.position = playerUW.playerInventory.InventoryMarker.transform.position;
                myObj.transform.parent   = playerUW.playerInventory.InventoryMarker.transform;
                ObjectInteraction.CreateObjectGraphics(myObj, "Sprites/OBJECTS_" + lstOutput[i], true);

                switch (lstOutput[i])
                {
                case 299:                //Fishing pole
                    ObjectInteraction.CreateObjectInteraction(myObj, 0.5f, 0.5f, 0.5f, 0.5f, "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), ObjectInteraction.FISHING_POLE, lstOutput[i], 1, 40, 0, 1, 1, 0, 1, 1, 0, 0, 1);
                    myObj.AddComponent <FishingPole>(); break;

                case 183:                //Popcorn
                    ObjectInteraction.CreateObjectInteraction(myObj, 0.5f, 0.5f, 0.5f, 0.5f, "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), ObjectInteraction.FOOD, lstOutput[i], 1, 40, 0, 1, 1, 0, 1, 1, 0, 0, 1);
                    Food fd = myObj.AddComponent <Food>();
                    fd.Nutrition = 5;
                    break;

                default:
                    ObjectInteraction.CreateObjectInteraction(myObj, 0.5f, 0.5f, 0.5f, 0.5f, "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), "Sprites/OBJECTS_" + lstOutput[i].ToString("000"), 23, lstOutput[i], 1, 40, 0, 1, 1, 0, 1, 1, 0, 0, 1);
                    myObj.AddComponent <object_base>(); break;
                }
                playerUW.playerInventory.ObjectInHand = myObj.name;
                ObjectInteraction CreatedObjectInt = myObj.GetComponent <ObjectInteraction>();
                if (CreatedObjectInt != null)
                {
                    CreatedObjectInt.UpdateAnimation();
                    playerUW.CursorIcon = CreatedObjectInt.InventoryDisplay.texture;
                }

                UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
                InteractionModeControl.UpdateNow = true;
                return(true);
            }
        }

        return(false);
    }
    //Turns the item at index 995 in britannia castle into a specific item based on the skills of the player


    //TODO: disassembly has shown this is actually based on skills not class. FIX
    //Also probably the next item rather than specifically 995


    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        if (this.next == 0)
        {
            Debug.Log("Hack Trap Class Item has no next!");
            return;
        }
        ObjectInteraction obj = ObjectLoader.getObjectIntAt(this.next);

        if (obj == null)
        {
            Debug.Log("Next item for hack trap item has no instance @" + this.next);
            return;
        }
        Destroy(obj.GetComponent <object_base>());//Remove object base from the existing item so it can be changed further on.


        //Get max magic skill score
        int MaxMagicSkillScore = Mathf.Max(UWCharacter.Instance.PlayerSkills.Casting, UWCharacter.Instance.PlayerSkills.ManaSkill);

        int  MaxCombatSkillScore = 0;
        byte CombatSkillType     = 0; //0=none, 1=sword, 2=axe, 3=mace; 4=missile, 5=unarmed.

        if (UWCharacter.Instance.PlayerSkills.Sword > MaxCombatSkillScore)
        {
            MaxCombatSkillScore = UWCharacter.Instance.PlayerSkills.Sword;
            CombatSkillType     = 1;
        }
        if (UWCharacter.Instance.PlayerSkills.Axe > MaxCombatSkillScore)
        {
            MaxCombatSkillScore = UWCharacter.Instance.PlayerSkills.Axe;
            CombatSkillType     = 2;
        }
        if (UWCharacter.Instance.PlayerSkills.Mace > MaxCombatSkillScore)
        {
            MaxCombatSkillScore = UWCharacter.Instance.PlayerSkills.Mace;
            CombatSkillType     = 3;
        }
        if (UWCharacter.Instance.PlayerSkills.Missile > MaxCombatSkillScore)
        {
            MaxCombatSkillScore = UWCharacter.Instance.PlayerSkills.Missile;
            CombatSkillType     = 4;
        }
        if (UWCharacter.Instance.PlayerSkills.Unarmed > MaxCombatSkillScore)
        {
            MaxCombatSkillScore = UWCharacter.Instance.PlayerSkills.Unarmed;
            CombatSkillType     = 5;
        }

        if ((MaxMagicSkillScore == 0) && (MaxCombatSkillScore == 0))
        {//Both scores are zero. Give a shield - they will need it!
            obj.item_id           = 60;
            obj.WorldDisplayIndex = 60;
            obj.InvDisplayIndex   = 60;
            obj.gameObject.AddComponent <Shield>();
        }
        else
        {
            if (MaxMagicSkillScore > MaxCombatSkillScore)
            {//magic is higher. Give a mani stone
                obj.item_id           = 244;
                obj.WorldDisplayIndex = 224;
                obj.InvDisplayIndex   = 244;
                obj.gameObject.AddComponent <RuneStone>();
            }
            else
            {//combat is higher give a item based on the skill type.
                switch (CombatSkillType)
                {
                case 1:     //shortsword
                    obj.item_id           = 4;
                    obj.WorldDisplayIndex = 4;
                    obj.InvDisplayIndex   = 4;
                    obj.gameObject.AddComponent <WeaponMelee>();
                    break;

                case 2:     //hand axe/
                    obj.item_id           = 0;
                    obj.WorldDisplayIndex = 0;
                    obj.InvDisplayIndex   = 0;
                    obj.gameObject.AddComponent <WeaponMelee>();
                    break;

                case 3:     //cudgel
                    obj.item_id           = 7;
                    obj.WorldDisplayIndex = 7;
                    obj.InvDisplayIndex   = 7;
                    obj.gameObject.AddComponent <WeaponMelee>();
                    break;

                case 4:     // supply of slingstones
                    obj.item_id           = 16;
                    obj.WorldDisplayIndex = 16;
                    obj.InvDisplayIndex   = 16;
                    obj.isquant           = 1;
                    obj.link = 10;
                    obj.gameObject.AddComponent <object_base>();
                    break;

                default:     //unarmed/gloves
                    obj.item_id           = 38;
                    obj.WorldDisplayIndex = 38;
                    obj.InvDisplayIndex   = 38;
                    obj.gameObject.AddComponent <Gloves>();
                    break;
                }
            }
        }

        obj.gameObject.name = ObjectLoader.UniqueObjectName(obj.BaseObjectData);
        obj.UpdateAnimation();

        //switch (UWCharacter.Instance.CharClass)
        //{
        //    //Gloves
        //    case UWCharacter.CharClassFighter://fighter
        //        obj.item_id = 38;
        //        obj.WorldDisplayIndex = 38;
        //        obj.InvDisplayIndex = 38;
        //        obj.gameObject.AddComponent<Gloves>();
        //        break;
        //    //Mani stone
        //    case UWCharacter.CharClassMage://mage
        //    case UWCharacter.CharClassBard://bard
        //    case UWCharacter.CharClassDruid://Druid
        //    case UWCharacter.CharClassShepard://shepherd
        //        obj.item_id = 244;
        //        obj.WorldDisplayIndex = 224;
        //        obj.InvDisplayIndex = 244;
        //        obj.gameObject.AddComponent<RuneStone>();
        //        break;
        //    //Shortsword
        //    case UWCharacter.CharClassTinker://tinker
        //    case UWCharacter.CharClassPaladin://paladin
        //        obj.item_id = 4;
        //        obj.WorldDisplayIndex = 4;
        //        obj.InvDisplayIndex = 4;
        //        obj.gameObject.AddComponent<WeaponMelee>();
        //        break;
        //    //Shield
        //    case UWCharacter.CharClassRanger://ranger
        //        obj.item_id = 60;
        //        obj.WorldDisplayIndex = 60;
        //        obj.InvDisplayIndex = 60;
        //        obj.gameObject.AddComponent<Shield>();
        //        break;
        //}
    }