Exemplo n.º 1
0
    private float lastCheckpoint = 0; // used for notching up the difficulty

    // Use this for initialization
    void Start()
    {
        hero               = GameObject.Find("hero");
        dirt_container     = GameObject.Find("dirt_container");
        backpackController = GameObject.Find("Backpack").GetComponent <BackpackController>();
        music              = GameObject.Find("Music");
    }
 // to be called whenever the contents of the backpack change
 public void UpdateMeters()
 {
     if (backpackController == null)
     {
         backpackController = FindObjectOfType <BackpackController>();
     }
     UpdateMeter(healthBar, backpackController.TotalHealth());
     UpdateMeter(manaBar, backpackController.TotalMana());
     UpdateMeter(staminaBar, backpackController.TotalStamina());
 }
Exemplo n.º 3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     //Debug.Log("Triggered chest");
     if (other.name == "hero")
     {
         BackpackController backpack = FindObjectOfType <BackpackController>();
         backpack.ReceiveItemFromHero(Instantiate(this.ContainedItemPrefab, backpack.transform));
         this.GetComponent <SpriteRenderer>().sprite = this.openedSprite;
     }
 }
Exemplo n.º 4
0
    public void beginCooking()
    {
        BackpackController backpackController = backpack.GetComponent <BackpackController>();
        BackpackController recipeController   = GameController.instance.recipes.GetComponent <BackpackController>();

        GameItemController[] backPackItems = backpackController.items;
        GameItemController[] recipeItems   = recipeController.items;


        if (getItemsLength(recipeItems) != getItemsLength(backPackItems))
        {
            return;
        }


        bool hasItem = false;


        for (int i = 0; i < recipeItems.Length; ++i)
        {
            if (recipeItems[i] != null && backPackItems[i] != null)
            {
                hasItem = true;
                if (recipeItems[i].itemName != backPackItems[i].itemName)
                {
                    print("Comparing " + recipeItems[i].itemName + " and " + backPackItems[i].itemName + " but not equal");
                    return;
                }
            }


            if (hasItem == false)
            {
                return;
            }
        }



        SoundManager.instance.PlayPickUp();
        spriteRenderer.sprite = potSprite;

        pickedUpItem = false;
        startTimer   = true;
        backpackController.ClearBackpack();
        recipeController.ClearBackpack();


        GameController.instance.createNewRecipe(GameController.instance.numItemsInRecipe);


        //doneCooking = false;
    }
Exemplo n.º 5
0
    void OnMouseUp()
    {
        isBeingDragged = false;

        BackpackController theBackpackController = backpackController; // @hack to robustify against DestroyImmediate destroying me in the middle of my OnMouseUp event

        if (!backpackController.ReceiveItemFromMouse(gameObject))
        {
            if (this != null)   // @hack to robustify against DestroyImmediate destroying me in the middle of my OnMouseUp event
            {
                transform.position = originalItemPosition;
            }
        }
        theBackpackController.ReleaseGridSlot();
    }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     this.scrollManager      = FindObjectOfType <ScrollManager>();
     this.backpackController = FindObjectOfType <BackpackController>();
 }
Exemplo n.º 7
0
        public MapUserControl(  GameForm gameForm, 
                                BackpackController backpackController,
                                SpellbookController spellbookController,
                                IAtomListener selectorMsgListener)
        {
            InitializeComponent();

            this.Size = new Size();

            this.DoubleBuffered = true;
            this.BackColor = Color.Black;
            this.Font = new Font(FontFamily.GenericMonospace, charSize + charFontPadding);

            this.aiCharacters = new List<AICharacter>();
            this.backpackController = backpackController;
            this.spellbookController = spellbookController;
            this.gameForm = gameForm;

            this.MinimumSize = new Size((int)charSize, this.FontHeight);
            
            this.selectorCursor.RegisterView(selectorMsgListener);

            TransparentPanelCreation();
        }
Exemplo n.º 8
0
 // Use this for initialization that depends on other objects
 void Start()
 {
     //sprite = gameObject.GetComponent<SpriteRenderer>();
     backpack           = GameObject.Find("Backpack");
     backpackController = backpack.GetComponent <BackpackController>();
 }
Exemplo n.º 9
0
 private void Awake()
 {
     _Instance = this;
     getItemUIObjects();
 }
    private void addItemtoBackpack()
    {
        BackpackController backpack = mainCharacter.GetComponent <Character>().backpack.GetComponent <BackpackController>();

        backpack.AddItemToBackpack(this);
    }