Пример #1
0
 public void CheckAdviceNeeded()
 {
     if (!GadgetNeedsAdvice())
     {
         Inventory.inst.HideBottomText();
     }
     else
     {
         if (state == GadgetLoadingState.Loading)
         {
             Inventory.inst.DisplayBottomText("Select a belt position 1-9 to load that item.");
             adviceTimer = 20f;
         }
         else if (state == GadgetLoadingState.Ready && this.GetAmmo().Count == 0 && Inventory.inst.BeltContainsANumber())
         {
             state = GadgetLoadingState.Hinting;
             Inventory.inst.DisplayBottomText("Press L to load " + userEditableObjectRef.myName);
             adviceTimer = 20f;
         }
         else
         {
             Inventory.inst.HideBottomText();
             state = GadgetLoadingState.Ready;
         }
     }
 }
Пример #2
0
 void StopLoadingGadget()
 {
     state = GadgetLoadingState.Ready;
     foreach (GameObject o in highlightCopies)
     {
         Destroy(o);
     }
     highlightCopies.Clear();
 }
Пример #3
0
    public virtual void GadgetUpdate()
    {
        if (MouseLockCursor.mouseShows > 0)
        {
//			// commented Debug.Log("nmouse:"+GetGadgetName);
            return;
        }


        if (GadgetNeedsAdvice())           // if we've equippedd a gadget capable of loading a number ..
        {
            if (adviceTimer < 0)
            {
                CheckAdviceNeeded();
            }
//			Debug.Log("advict:"+adviceTimer+",cht:"+chooseTimer);
            // count down until next text will be displayed.
            adviceTimer -= Time.deltaTime;
            chooseTimer -= Time.deltaTime;
            if ((state == GadgetLoadingState.Hinting || state == GadgetLoadingState.Ready) && Input.GetKeyDown(KeyCode.L) && GadgetNeedsAdvice())
            {
                chooseTimer = 5f;
                adviceTimer = 0;
                state       = GadgetLoadingState.Loading;
                for (int i = 0; i < 9; i++)
                {
                    GameObject highlightCopy = (GameObject)Instantiate(Inventory.inst.highlight.gameObject, Inventory.inst.beltSlots[i].transform.position, Inventory.inst.highlight.rotation);
                    highlightCopy.transform.SetParent(Inventory.inst.beltSlots[i].transform.parent);
                    highlightCopies.Add(highlightCopy);
                    highlightCopy.GetComponent <RectTransform>().sizeDelta = new Vector2(120, 120);

                    highlightCopy.GetComponent <Image>().color = new Color(1, 1, 1, 0.2f);
                    if (highlightCopy.GetComponent <Outline>())
                    {
                        Destroy(highlightCopy.GetComponent <Outline>());
                    }
                    SinPulsate sp = highlightCopy.AddComponent <SinPulsate>();
                    sp.amplitude    = 0.1f;
                    sp.pulsateSpeed = 3.5f;
                }
                state = GadgetLoadingState.Loading;
            }

            // If we're in loading state,
            if (state == GadgetLoadingState.Loading)
            {
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[0];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[1];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[2];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha4))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[3];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha5))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[4];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha6))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[5];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha7))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[6];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha8))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[7];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha9))
                {
                    Slot beltSlot = Inventory.inst.beltSlots[8];
                    AttemptToLoadItemIntoGadgetFromBeltSlot(beltSlot);
                }
                else if (Input.anyKeyDown && chooseTimer < 0)
                {
//					Debug.Log("anykey");
                    StopLoadingGadget();
                }
            }
        }
        else
        {
//			if (Input.GetKeyDown(KeyCode.L)){
//				if (
//					this.GetType() == typeof(GadgetMultiblaster) ||
//					this.GetType() == typeof(GadgetZooka) ||
//					this.GetType() == typeof(GadgetWave) ||
//					this.GetType() == typeof(GadgetBow)
//				)	{

//				}
//			}
        }


        if (Input.GetMouseButtonDown(0) && Time.timeScale != 0)
        {
//			// commented Debug.Log ("click gadget"+this.name+" Time:"+Time.realtimeSinceStartup);
            MouseButtonDown();
        }
        if (Input.GetMouseButtonUp(0))
        {
            MouseButtonUp();
        }
    }