private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #2
0
 //public Transform content;//鼠标抬起之后返回到原来的位置
 void Start()
 {
     initalPos    = gameObject.transform.position;
     item_manager = FindObjectOfType <Item_Manager>();
     Item_parent  = GameObject.Find("Area").transform;
     content      = item_manager.transform.Find("Canvas/Scroll View/Viewport/Content");
     SeTriggerListener(gameObject).onDrag    += OnDrag;
     SeTriggerListener(gameObject).onPointUp += OnPointerUp;
 }
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (GUILayout.Button("Spawn Debug Item"))
     {
         Item_Manager manager = (Item_Manager)target;
         manager.DebugSpawnItem();
     }
     if (GUILayout.Button("Add Item to Player"))
     {
         Item_Manager manager = (Item_Manager)target;
         manager.DebugAddItemToPlayer();
     }
 }
    public void Init(Item producerAsItem, Producer _producer, Tile_Data _baseTile)
    {
        producer = _producer;
        if (_baseTile.AddProducer(producer) == false)
        {
            return;
        }

        base.InitMachine(producerAsItem, producer, _baseTile, ShipManager.instance);

        // The machine controller sets the list of Neighbor tiles,
        // then we Add the producers on neighbor tiles as well
        foreach (Tile_Data tile in neighborTiles)
        {
            tile.AddProducer(producer);
        }
        item_Manager = Item_Manager.instance;
        timer        = new CountdownHelper(0);
        //storage_inventory = new Inventory(1);
        inventory_Controller = GetComponentInChildren <Inventory_Controller>();
        inventory_Controller.Initialize(ID_Generator.instance.GetMachineID(this), 1);

        // Position the growth visuals X correctly according to the machine's tile width
        if (growth_visuals != null)
        {
            growth_visuals.transform.localPosition = new Vector2(producer.tileWidth > 1 ? 0.5f : 0, 0.5f);
        }
        Debug.Log("Initialized a producer with a blueprint for " + producer.current_Blueprint.itemProduced.itemName);
        // This runs when a producer has already started producing before
        if (producer.current_Blueprint.itemProduced.count > 0 && producer.productionStage >= 0)
        {
            if (producer.productionStage >= 3)
            {
                itemInProduction = item_Manager.CreateInstance(item_Manager.GetPrototype(producer.current_Blueprint.itemProduced.itemName));
                SetGrowthVisuals();
                CompleteProduction();
                return;
            }
            StartProduction(true);
            return;
        }
        SetProductionStage(0);
        //	Debug.Log("Producer INITIALIZED: " + " key ingredient = " + producer.productionBlueprints[0].keyIngredient.count + " " + producer.productionBlueprints[0].keyIngredient.itemName +
        //		 " secondary ingredient " + producer.productionBlueprints[0].secondaryIngredients[0].count + " " + producer.productionBlueprints[0].secondaryIngredients[0].itemName);
    }
Beispiel #5
0
    public void LoadSavedTiles()
    {
        buildable_Manager = Buildable_Manager.instance;
        Item_Manager item_Manager = Item_Manager.instance;

        if (savedAreaTiles.savedTiles == null)
        {
            return;
        }
        if (savedAreaTiles.savedTiles.Length <= 0)
        {
            return;
        }

        SetCurrentArea((AreaID)savedAreaTiles.areaID);
        SetupGrid();
        SetGridFromTileMap();
        foreach (STile sTile in savedAreaTiles.savedTiles)
        {
            if (sTile.hasMachine == true)
            {
                MachinePrototype proto = buildable_Manager.GetMachinePrototype(sTile.machineName);
                proto.machineCondition = sTile.machineCondition;
                Item machineItem = item_Manager.CreateInstance(item_Manager.GetPrototype(proto.name));
                ShipManager.instance.PlaceMachine(machineItem, proto, new Vector2(sTile.world_x, sTile.world_y));
            }
            else if (sTile.hasProducer == true)
            {
                ProducerPrototype proto = buildable_Manager.GetProducerPrototype(sTile.producerName);
                proto.machineCondition  = sTile.machineCondition;
                proto.curProductionName = sTile.itemProduced;
                proto.productionStage   = sTile.productionStage;
                Item       prodItem = item_Manager.CreateInstance(item_Manager.GetPrototype(proto.name));
                Producer   producer = buildable_Manager.CreateProducerInstance(proto);
                GameObject prodGObj = buildable_Manager.SpawnProducer(producer, new Vector2(sTile.world_x, sTile.world_y));
                if (prodGObj == null)
                {
                    return;
                }
                prodGObj.GetComponent <Producer_Controller>().Init(prodItem, producer, grid_data[sTile.grid_x, sTile.grid_y]);
            }
        }
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        soundsManager = GameObject.Find("ScriptManager").GetComponent <SoundsManager>();

        //アイテムが生成されると同時に矢印を生成
        arrowInstantPos = GameObject.Find("ArrowInstantPos").transform;
        arrow           = Instantiate(arrowPrefab, arrowInstantPos);
        //アイテムマネージャーを取得
        item_manger = GameObject.Find("ItemManager").GetComponent <Item_Manager>();
        //アイテムと矢印をアイテム削除時間後で削除
        Destroy(this.gameObject, itemDestroyTime);
        Destroy(arrow, itemDestroyTime);
        //マスクオブジェクトの取得
        maskObj = arrow.transform.Find("Mask_Base").gameObject;
        //マスクの位置をアイテム削除時間に合わせてずらしていく
        LeanTween.scaleZ(maskObj, 0, itemDestroyTime);
        //プレイヤーアビリティの取得
        playerAbility = GameObject.Find("PlayerAbility").GetComponent <PlayerAbility>();
    }
Beispiel #7
0
    public Inventory LoadInventory(string owner_id)
    {
        Item_Manager item_Manager = Item_Manager.instance;
        // Try to load and return
        SavedInventory savedInventory = JsonLoader.instance.LoadSavedInventory(owner_id);

        if (savedInventory.maxSpace > 0 && savedInventory.items != null && savedInventory.items.Length > 0)
        {
            Inventory loadedInventory = new Inventory(savedInventory.maxSpace);
            foreach (ItemReference itemRef in savedInventory.items)
            {
                // TODO : Load the updated stats by updating the item prototype
                //      To do this we might have to store Item stats in saved inventory with each item reference
                Item newItem = item_Manager.CreateInstance(item_Manager.GetPrototype(itemRef.itemName));
                loadedInventory.AddItem(newItem, itemRef.count);
            }
            return(loadedInventory);
        }
        // if none found...
        return(null);
    }
Beispiel #8
0
    public bool InsertItem(Item_Manager value)
    {
        if (!SetGrid)
        {
            return(false);
        }

        int EmptyNum = -1;
        int x = 0, y = 0;

        for (y = 0; y < Inven_Grid.GetLength(0); y++)
        {
            for (x = 0; x < Inven_Grid.GetLength(1); x++)
            {
                if (Inven_Grid[y, x] == 0)
                {
                    EmptyNum = x + (y * Inven_Grid.GetLength(1));
                    break;
                }
            }

            if (EmptyNum != -1)
            {
                break;
            }
        }

        if (EmptyNum == -1)
        {
            return(false);
        }


        HaveItems[y, x]  = value;
        Inven_Grid[y, x] = 1;
        UpdateGridUI();

        return(true);
    }
Beispiel #9
0
 void Awake()
 {
     instance = this;
 }
Beispiel #10
0
    void ReadItemInfo(string path, string name)
    {
        StreamReader sr = null;

        try {
            sr = File.OpenText(path + "//" + name);
        } catch (Exception e) {
            return;
        }
        string line;

        while ((line = sr.ReadLine()) != null)
        {
            string[]         attr = line.Split(',');
            Item_Attribution temp = new Item_Attribution();
            temp.id    = int.Parse(attr[0]);
            temp.price = int.Parse(attr[1]);
            temp.name  = attr[2];
            switch (attr[3])
            {
            case "onetime":
                temp.type = Item_Attribution.Item_Type.One_Time;
                break;

            case "righthand":
                temp.type = Item_Attribution.Item_Type.Right_Hand;
                break;

            case "lefthand":
                temp.type = Item_Attribution.Item_Type.left_Hand;
                break;

            case "armor":
                temp.type = Item_Attribution.Item_Type.Armor;
                break;

            case "headgear":
                temp.type = Item_Attribution.Item_Type.Headgear;
                break;

            case "shoe":
                temp.type = Item_Attribution.Item_Type.Shoe;
                break;

            case "accessory":
                temp.type = Item_Attribution.Item_Type.Accessory;
                break;
            }
            temp.num   = 0;
            temp.armed = false;
            if (temp.type == Item_Attribution.Item_Type.One_Time)
            {
                temp.add_hp = int.Parse(attr[4]);
                temp.add_mp = int.Parse(attr[5]);
            }
            else
            {
                temp.add_ad = int.Parse(attr[4]);
                temp.add_ap = int.Parse(attr[5]);
                temp.add_df = int.Parse(attr[6]);
            }
            Item_Manager.AddItem(temp.id, temp);
        }
        sr.Close();
        sr.Dispose();
    }
Beispiel #11
0
    public bool Equip(int x, int y)
    {
        Item_Manager value = HaveItems[y, x];

        if (value.equipable[0])
        {
            if (LeftH == null)
            {
                LeftH            = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
            }

            else
            {
                Item_Manager temp = LeftH;
                LeftH            = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
                InsertItem(temp);
            }
            EquipItems[0] = value.ItemCode;
        }

        else if (value.equipable[1])
        {
            if (RightH == null)
            {
                RightH           = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
            }

            else
            {
                Item_Manager temp = RightH;
                RightH           = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
                InsertItem(temp);
            }
            EquipItems[1] = value.ItemCode;
        }

        else if (value.equipable[2])
        {
            if (Head == null)
            {
                Head             = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
            }

            else
            {
                Item_Manager temp = Head;
                Head             = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
                InsertItem(temp);
            }
            EquipItems[2] = value.ItemCode;
        }

        else if (value.equipable[3])
        {
            if (Body == null)
            {
                Body             = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
            }

            else
            {
                Item_Manager temp = Body;
                Body             = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
                InsertItem(temp);
            }
            EquipItems[3] = value.ItemCode;
        }

        else if (value.equipable[4])
        {
            if (Foot == null)
            {
                Foot             = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
            }

            else
            {
                Item_Manager temp = Foot;
                Foot             = value;
                HaveItems[y, x]  = null;
                Inven_Grid[y, x] = 0;
                InsertItem(temp);
            }
            EquipItems[4] = value.ItemCode;
        }

        else
        {
            return(false);
        }

        UpdateGridUI();

        return(true);
    }
Beispiel #12
0
 void Start()
 {
     initalPos    = gameObject.transform.position;
     item_manager = FindObjectOfType <Item_Manager>();
 }
 public static News_Sentence_Manager news;       // ニュース文章データ
 //--------------------------------------------------------------------
 // ● 初期化(早)
 //--------------------------------------------------------------------
 void Awake()
 {
     game = new Item_Manager();
     news = new News_Sentence_Manager();
 }
Beispiel #14
0
 void Start()
 {
     item_manager   = FindObjectOfType <Item_Manager>();
     targetPosition = FindObjectOfType <Collider2D>();
 }