コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (Player.Instance.areaText.text.ToLower() == area.ToLower())
     {
         item = this.gameObject.GetComponent <GameItem>();
         if (item.GetProperty("ison") != null && item.GetProperty("ison").value == "True")
         {
             if (!music.isPlaying && muted == false)
             {
                 music.Play();
                 TurnOnVolume();
             }
         }
         if (music.isPlaying && muted == false)
         {
             if (_volumeDown)
             {
                 TurnOnVolume();
             }
             Player.Instance.gameObject.GetComponent <AudioSource>().volume = 0.05f;
         }
         else
         {
             Player.Instance.gameObject.GetComponent <AudioSource>().volume = 1f;
         }
     }
     else
     {
         TurnDownVolume();
     }
 }
コード例 #2
0
    public static SelectedItemButton CreateComponent(GameObject where, GameItem gameItem)
    {
        SelectedItemButton actionBtn    = where.AddComponent <SelectedItemButton>();
        Property           containsProp = gameItem.GetProperty("contains");

        if (containsProp != null)
        {
            where.GetComponentInChildren <Text>().text = gameItem.dbItem.description + "[" + containsProp.value + "]";
        }
        else
        {
            where.GetComponentInChildren <Text>().text = gameItem.dbItem.description;
        }
        actionBtn._gameItem = gameItem;
        return(actionBtn);
    }
コード例 #3
0
ファイル: GameItem.cs プロジェクト: limorgan/honey-im-home1
    public void OnGameItemClicked(GameObject actionMenu, GameObject buttonPrefab, Text ActionHeader)
    {
        ActionHeader.text = this.dbItem.description;
        bool noAction = true;   //keep track of whether or not there are any actions

        if (GetProperty("inInventory") != null && GetProperty("inInventory").value == "True")
        {
            noAction = false;
        }
        foreach (Rule puzzleRule in PuzzleManager.Instance.RulesFor(this, PuzzleManager.Instance.GetCurrentArea()))
        {         //not necessarily accurate (nested areas) previous version: GetComponentInParent<GameArea>().area)
            Debug.Log("Checking rule " + puzzleRule.ToString() + " fulfilled by " + this.name + " ? " + RuleFulFilled(puzzleRule));
            if (RuleFulFilled(puzzleRule))
            {
                noAction = false;
                GameObject action = GameObject.Instantiate(buttonPrefab);
                ActionBtn.CreateComponent(action, this, puzzleRule);
                action.transform.SetParent(actionMenu.transform);
            }
        }
        if (dbItem.IsCarryable() && !selected && (GetProperty("inInventory") == null || GetProperty("inInventory").value == "False"))
        {
            noAction = false;
            GameObject action = GameObject.Instantiate(buttonPrefab);
            ActionBtn.CreateComponent(action, this, new Rule("PickUp"));
            action.transform.SetParent(actionMenu.transform);
        }
        if (dbItem.IsInspectable())
        {
            noAction = false;
            GameObject action = GameObject.Instantiate(buttonPrefab);
            ActionBtn.CreateComponent(action, this, new Rule("Inspect"));
            action.transform.SetParent(actionMenu.transform);
        }
        if (containedValue && containedValue.GetProperty("carryable") != null)
        {
            if (containedValue.GetProperty("carryable").value == "True")
            {
                noAction = false;
                GameObject action = GameObject.Instantiate(buttonPrefab);
                ActionBtn.CreateComponent(action, this, new Rule("TakeOut"));
                action.transform.SetParent(actionMenu.transform);
            }
        }
        if (selected)
        {
            noAction = false;
            GameObject action = GameObject.Instantiate(buttonPrefab);
            ActionBtn.CreateComponent(action, this, new Rule("Deselect"));
            action.transform.SetParent(actionMenu.transform);
        }

        if (GetProperty("inInventory") != null && GetProperty("inInventory").value == "True")
        {
            noAction = false;
            GameObject action = GameObject.Instantiate(buttonPrefab);
            ActionBtn.CreateComponent(action, this, new Rule("Drop"));
            action.transform.SetParent(actionMenu.transform);
        }
        Player.Instance._noAction = noAction;

        if (GetProperty("ison") != null && GetProperty("ison").value == "True" && this.gameObject.GetComponent <MusicControl>() != null)
        {
            noAction = false;
            GameObject action = GameObject.Instantiate(buttonPrefab);
            if (this.gameObject.GetComponent <MusicControl>().IsMuted())
            {
                ActionBtn.CreateComponent(action, this, new Rule("Unmute"));
            }
            else
            {
                ActionBtn.CreateComponent(action, this, new Rule("Mute"));
            }
            action.transform.SetParent(actionMenu.transform);
        }
    }