コード例 #1
0
ファイル: MapManager.cs プロジェクト: Owlies/Coop_Next
    private void LoadLevel()
    {
        if (levelConfig != null)
        {
            mapSize   = levelConfig.mapSize;
            mapOrigin = new Vector3(-mapSize.x / 2.0f * MAP_SIZE_UNIT, 0, -mapSize.y / 2.0f * MAP_SIZE_UNIT);
            mapNodes  = new MapNode[levelConfig.mapSize.x, levelConfig.mapSize.y];
            gameObjectOnMapDictionary.Clear();
            for (int i = 0; i < levelConfig.objectInstances.Length; i++)
            {
                ObjectInstance instance = levelConfig.objectInstances[i];
                if (!metadataManager.objectsDictionary.ContainsKey(instance.objectId))
                {
                    Debug.Log("No " + instance.objectId + " in config!!!");
                    continue;
                }
                ObjectMetadata objectData = metadataManager.objectsDictionary[instance.objectId];
                if (objectData == null)
                {
                    Debug.Log("No " + instance.objectId + "'s gameobject in config!!!");
                    continue;
                }
                GameObject obj = objectData.GetGameObjectFromPool(sceneRoot.transform);

                Item item = obj.GetComponent <Item>();
                if (item != null)
                {
                    ItemManager.InitItem(obj, (ItemMetadata)objectData);
                }

                obj.transform.localPosition = MapIndexToWorldPos(instance.position + new Vector2(1 / 2.0f, 1 / 2.0f));
                if (instance.dir == ObjectDir.Vertical)
                {
                    obj.transform.localEulerAngles = new Vector3(0, 90, 0);
                    obj.transform.localPosition    = MapIndexToWorldPos(instance.position + new Vector2(1 / 2.0f, 1 / 2.0f));
                }

                Vector2Int index = instance.position;

                if (instance.dir == ObjectDir.Vertical)
                {
                    index = instance.position;
                }
                if (index.x >= 0 && index.y >= 0 &&
                    index.x < levelConfig.mapSize.x && index.y < levelConfig.mapSize.y)
                {
                    mapNodes[index.x, index.y].isBlocked  = true;
                    mapNodes[index.x, index.y].gameObject = obj;
                }

                gameObjectOnMapDictionary[obj] = true;
            }
        }
    }
コード例 #2
0
ファイル: MapManager.cs プロジェクト: Owlies/Coop_Next
    public bool CreateItemOnMap(ObjectMetadata objData, Vector2Int mapIndex)
    {
        GameObject obj = objData.GetGameObjectFromPool(sceneRoot.transform);

        InteractiveObject item = obj.GetComponent <InteractiveObject>();

        if (item == null)
        {
            return(false);
        }

        return(PlaceItemOnMap(item, mapIndex));
    }
コード例 #3
0
    private bool HandleDropBehaviour(Player actor)
    {
        GameObject obj = lootItemData.GetGameObjectFromPool();

        if (obj != null)
        {
            actor.SetCarryingItem(obj.GetComponent <InteractiveObject>());
        }

        GameObject.Destroy(gameObject);

        return(true);
    }
コード例 #4
0
ファイル: Forge.cs プロジェクト: Owlies/Coop_Next
    private void ForgingComplete()
    {
        recipeCanvas.enabled = false;
        ObjectMetadata forgedPrefabMetadata = FindMatchingRecipeObject();

        forgedGameObject = forgedPrefabMetadata.GetGameObjectFromPool(transform);
        MapManager.Instance.OnItemCreated(forgedGameObject);
        forgedGameObject.SetActive(false);

        InteractiveObject item = forgedGameObject.GetComponent <InteractiveObject>();

        if (resourceList.Count == 4 && resourceList[3].isRareResource())
        {
            (resourceList[3] as Orb).applyOrbEffect(item);
        }

        forgeState = ForgeState.READY_TO_COLLECT;
        ResetForgingProgressBar();

        //TODO(Huayu):Ready to collect UI
    }