コード例 #1
0
ファイル: FurnaceUI.cs プロジェクト: wetstreet/Theircraft
    protected override void OnLeftMouseClick()
    {
        base.OnLeftMouseClick();

        if (highlightIndex == resultIndex)
        {
            if (InventorySystem.grabItem.id == null ||
                (InventorySystem.grabItem.id == InventorySystem.items[resultIndex].id &&
                 InventorySystem.grabItem.damage == InventorySystem.items[resultIndex].damage))
            {
                CraftingSystem.CraftItems();
                RefreshGrabItem();
                RefreshUI();
            }
        }
        if (indexList.Contains(highlightIndex))
        {
            if (InventorySystem.grabItem.id != null &&
                InventorySystem.items[highlightIndex].id != null &&
                InventorySystem.grabItem.id == InventorySystem.items[highlightIndex].id &&
                InventorySystem.grabItem.damage == InventorySystem.items[highlightIndex].damage)
            {
                InventorySystem.PutItems(highlightIndex);
            }
            else
            {
                InventorySystem.MouseGrabItem(highlightIndex);
            }
            RefreshGrabItem();
            RefreshUI();
            ItemSelectPanel.instance.RefreshUI();
        }
    }
コード例 #2
0
    public void SetCraftingSystem(CraftingSystem craftingSystem)
    {
        this.craftingSystem           = craftingSystem;
        craftingSystem.OnGridChanged += CraftingSystem_OnGridChanged;

        UpdateVisual();
    }
コード例 #3
0
ファイル: ItemData.cs プロジェクト: IgorCarvai/GameDev2
    void Start()
    {
        inv   = GameObject.Find("Inventory").GetComponent <Inventory>();
        craft = GameObject.Find("CraftSystem").GetComponent <CraftingSystem>();

        tooltip = inv.GetComponent <Tooltip>();
    }
コード例 #4
0
ファイル: Main.cs プロジェクト: wetstreet/Theircraft
    // Use this for initialization
    void Start()
    {
        SoundManager.Init();
        LocalizationManager.Init();
        NBTGeneratorManager.Init();
        TextureArrayManager.Init();
        CraftingSystem.Init();

        SceneManager.LoadScene("LoginScene");
    }
コード例 #5
0
ファイル: ClickCraft.cs プロジェクト: IgorCarvai/GameDev2
    void Start()
    {
        database  = GetComponent <ItemDatabase>();
        inv       = GameObject.Find("Inventory").GetComponent <Inventory>();
        craftS    = GameObject.Find("Inventory").GetComponent <CraftingSystem>();
        craftSlot = GameObject.Find("FinishedItem");
        craftArea = GameObject.Find("Craftable Area");

        craftItemIng = GameObject.Find("Inventory").GetComponent <CraftingSystem>().craftItemIng;
    }
コード例 #6
0
        private void DeleteCraftingQueueItemHandler(CraftingQueueItem craftingQueueItem)
        {
            if (!craftingQueueItem.Recipe.IsCancellable)
            {
                NotificationSystem.ClientShowNotification(
                    NotificationCannotDegradeableCraftItem_Title,
                    NotificationCannotDegradeableCraftItem_Message,
                    icon: craftingQueueItem.Recipe.Icon);
                return;
            }

            CraftingSystem.ClientDeleteQueueItem(craftingQueueItem);
        }
コード例 #7
0
    private void Start()
    {
        uiInventory.SetPlayer(player);
        uiInventory.SetInventory(player.GetInventory());

        uiCharacterEquipment.SetCharacterEquipment(characterEquipment);

        CraftingSystem craftingSystem = new CraftingSystem();

        //Item item = new Item { itemType = Item.ItemType.Diamond, amount = 1 };
        //craftingSystem.SetItem(item, 0, 0);
        //Debug.Log(craftingSystem.GetItem(0, 0));

        uiCraftingSystem.SetCraftingSystem(craftingSystem);
    }
コード例 #8
0
 void Start()
 {
     parentTransform = this.gameObject.GetComponentInChildren <Button>().transform;
     inventoryUI     = FindObjectOfType <InventoryUI>();
     craftingSystem  = GameObject.FindObjectOfType <CraftingSystem>();
     Image[] images = GetComponentsInChildren <Image>();
     foreach (Image child in images)
     {
         if (child.CompareTag("Icon"))
         {
             icon = child;
         }
     }
     slot = this.gameObject.GetComponent <InventorySlot>();
 }
コード例 #9
0
    private void Start()
    {
        currentHealth = maxHealth;

        if (!isCheckComplete)
        {
            if (IsOverlapping())
            {
                Destroy(gameObject);
            }
            isCheckComplete = true;
        }

        int state = Random.Range(1, 100);

        if (!gameObject.name.Contains("Special Chest"))
        {
            if (state < 15)
            {
                gameObject.name = "Special Chest";
                GetComponent <SpriteRenderer>().sprite = specialChestSprite;
            }
            else
            {
                gameObject.name = "Chest";
            }
        }
        else
        {
            gameObject.name = "Special Chest";
            GetComponent <SpriteRenderer>().sprite = specialChestSprite;
        }

        c      = GameObject.Find("Canvas/Inventory").GetComponent <CraftingSystem>();
        player = GameObject.Find("Player").transform;

        if (chestSlotsParent != null)
        {
            chestSlots = chestSlotsParent.GetComponentsInChildren <ItemSlot>();
        }

        foreach (GameObject g in chestObjects)
        {
            g.transform.localScale = Vector3.zero;
        }
    }
コード例 #10
0
 void Awake()
 {
     //playerBehavior = GameObject.FindGameObjectWithTag("player").GetComponent<PlayerBehavior>();
     craftingSystem   = GetComponent <CraftingSystem>();
     buildingCatalog  = GetComponent <BuildingsCatalog>();
     itemCatalog      = GetComponent <ItemCatalog>();
     inventoryCatalog = GetComponent <InventoryCatalog>();
     citizenCatalog   = GetComponent <CitizenCatalog>();
     townCatalog      = GetComponent <TownCatalog>();
     enemyCatalog     = GetComponent <EnemyCatalog>();
     abilityCatalog   = GetComponent <AbilityCatalog>();
     perkCatalog      = GetComponent <PerkCatalog>();
     skillCatalog     = GetComponent <SkillCatalog>();
     UI             = GetComponent <UI>();
     messageLogText = GameObject.FindGameObjectWithTag("MessageLogBarUI").GetComponentInChildren <MessageLogText>();
     clock          = GetComponent <Clock>();
     world          = GameObject.FindGameObjectWithTag("World").GetComponent <World>();
 }
コード例 #11
0
    private void Awake()
    {
        if (Instance == null)
        {
            Debug.Log("Creating instance");
            Instance = this;
        }
        else if (Instance != this)
        {
            Debug.Log("instance already exists.");
            Destroy(this);
        }

        CraftingScore      = 0;
        CurrentLevel       = 0;
        unlockedBlueprints = new Dictionary <Blueprint, bool>();
        foreach (Blueprint bp in blueprints)
        {
            unlockedBlueprints.Add(bp, false);
        }
    }
コード例 #12
0
    private void Awake()
    {
        #region Make Singleton
        //Check if instance already exists
        if (_instance == null)
        {
            //if not, set instance to this
            _instance = this;
        }

        //If instance already exists and it's not this:
        else if (_instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);
        #endregion
    }
コード例 #13
0
 private void MakeFirstInQueueHandler(CraftingQueueItem craftingQueueItem)
 {
     CraftingSystem.ClientMakeItemFirstInQueue(craftingQueueItem);
 }
コード例 #14
0
 void Awake()
 {
     Instance = this;
 }
コード例 #15
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = Util.ScreenWidth;
            graphics.PreferredBackBufferHeight = Util.ScreenHeight;
            graphics.ApplyChanges();

            Util.ContentPath = Content.RootDirectory;

            Log.Init(AppDomain.CurrentDomain.BaseDirectory);
            Log.Message("Seed: " + Seed);

            var gameData = GameData.Instance = new GameData();

            var dataPath = Util.ContentPath + "/GameData/";

            gameData.LoadEntities(EntityType.Terrain, dataPath + "Entities/Terrains");
            gameData.LoadEntities(EntityType.Structure, dataPath + "Entities/Structures");
            gameData.LoadEntities(EntityType.Character, dataPath + "Entities/Characters");
            gameData.LoadEntities(EntityType.Item, dataPath + "Entities/Items");

            var herb          = gameData.CreateItem("randomHerb");
            var herbSubstance = EntityManager.GetComponent <SubstanceComponent>(herb);

            gameData.LoadTilesets(dataPath + "tilesets.json");
            gameData.LoadRoomTemplates(dataPath);

            //Floor test = new Floor(Content.RootDirectory + "/map.txt");
            Floor testFloor = new Floor(500, 500);

            //testFloor.GenerateSimple();
            testFloor.GenerateGraphBased();

            //EntityManager.Dump();

            Util.CurrentFloor = testFloor;
            Util.CurrentFloor.CalculateTileVisibility();

            // Delete entities that were removed during generation
            EntityManager.CleanUpEntities();

            //Log.Data(DescriptionSystem.GetDebugInfoEntity(Util.PlayerID));

            InputManager input = InputManager.Instance;

            // instantiate all the systems
            Log.Message("Loading Systems...");
            inputSystem        = new InputSystem();
            movementSystem     = new MovementSystem();
            renderSystem       = new RenderSystem(GraphicsDevice);
            collisionSystem    = new CollisionSystem();
            healthSystem       = new HealthSystem();
            combatSystem       = new CombatSystem();
            npcBehaviourSystem = new NPCBehaviourSystem();
            interactionSystem  = new InteractionSystem();
            itemSystem         = new ItemSystem();
            uiSystem           = new UISystem();
            statSystem         = new StatSystem();
            craftingSystem     = new CraftingSystem();

            // toggle FOW
            renderSystem.FogOfWarEnabled = true;

            // hook up all events with their handlers
            Log.Message("Registering Event Handlers...");

            input.MovementEvent             += movementSystem.HandleMovementEvent;
            input.InventoryToggledEvent     += uiSystem.HandleInventoryToggled;
            input.InventoryCursorMovedEvent += uiSystem.HandleInventoryCursorMoved;
            input.PickupItemEvent           += itemSystem.PickUpItem;
            input.InteractionEvent          += interactionSystem.HandleInteraction;
            input.ItemUsedEvent             += itemSystem.UseItem;
            input.ItemConsumedEvent         += itemSystem.ConsumeItem;

            // crafting
            input.AddItemAsIngredientEvent += craftingSystem.AddIngredient;
            input.CraftItemEvent           += craftingSystem.CraftItem;
            input.ResetCraftingEvent       += craftingSystem.ResetCrafting;

            interactionSystem.ItemAddedEvent += itemSystem.AddItem;

            itemSystem.HealthGainedEvent += healthSystem.HandleGainedHealth;
            itemSystem.HealthLostEvent   += healthSystem.HandleLostHealth;
            itemSystem.StatChangedEvent  += statSystem.ChangeStat;

            npcBehaviourSystem.EnemyMovedEvent += movementSystem.HandleMovementEvent;

            movementSystem.CollisionEvent   += collisionSystem.HandleCollision;
            movementSystem.BasicAttackEvent += combatSystem.HandleBasicAttack;
            movementSystem.InteractionEvent += interactionSystem.HandleInteraction;

            craftingSystem.ItemAddedEvent += itemSystem.AddItem;

            Util.TurnOverEvent += healthSystem.RegenerateEntity;
            Util.TurnOverEvent += statSystem.TurnOver;

            combatSystem.HealthLostEvent += healthSystem.HandleLostHealth;

            Log.Message("Loading Keybindings...");
            string keybindings = File.ReadAllText(Util.ContentPath + "/GameData/keybindings.json");

            input.LoadKeyBindings(keybindings);
            input.EnterDomain(InputManager.CommandDomain.Exploring); // start out with exploring as bottom level command domain
            input.ControlledEntity = Util.PlayerID;

            base.Initialize();
            Log.Message("Initialization completed!");

            //CraftableComponent.foo();

            int testRock = EntityManager.CreateEntity(new List <IComponent>()
            {
                new DescriptionComponent()
                {
                    Name = "Rock", Description = "You can't stop the rock!"
                },
                new ItemComponent()
                {
                    MaxCount = 5, Count = 3, Value = 1, Weight = 10
                }
            }, EntityType.Item);

            // fill inventory with test items
            itemSystem.AddItems(Util.PlayerID, new int[]
            {
                //testRock,
                GameData.Instance.CreateItem("healthPotion"),
                GameData.Instance.CreateItem("healthPotion"),
                GameData.Instance.CreateItem("healthPotion"),
                GameData.Instance.CreateItem("poisonPotion"),
                GameData.Instance.CreateItem("poisonPotion"),
                GameData.Instance.CreateItem("elementalPotion")
            });


            //EntityManager.Dump();
            //EntityManager.RemoveEntity(testBush);
            //EntityManager.CleanUpEntities();
            //EntityManager.Dump();

            //Log.Data(DescriptionSystem.GetDebugInfoEntity(Util.GetPlayerInventory().Items[0]));

            LocationSystem.UpdateDistanceMap(Util.PlayerID);
        }
コード例 #16
0
 static void CheckCanCraft()
 {
     CraftingSystem.CheckCanCraft();
 }
コード例 #17
0
 private void Awake()
 {
     player         = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     craftingSystem = player.GetComponent <CraftingSystem>();
 }
コード例 #18
0
 void Start()
 {
     inv    = GetComponent <Inventory>();
     craftS = GameObject.Find("Inventory").GetComponent <CraftingSystem>();
 }
コード例 #19
0
        static int Main(string[] args)
        {
            stopwatch.Restart();

            if (args.Length != 4)
            {
                PrintUsage();
                return(1);
            }

            // Avoid missing component errors because no components are directly used in this project
            // and the GeneratedCode assembly is not loaded but it should be
            Assembly.Load("GeneratedCode");

            using (var connection = ConnectWithReceptionist(args[1], Convert.ToUInt16(args[2]), args[3]))
            {
                SpatialOSConnectionSystem.connection = connection;
                Connected = true;

                var channel = new Channel(FirestoreClient.DefaultEndpoint.Host, GoogleCredential.FromFile(Path.Combine(Directory.GetCurrentDirectory(), CloudFirestoreInfo.GoogleCredentialFile)).ToChannelCredentials());
                CloudFirestoreInfo.Database = FirestoreDb.Create(CloudFirestoreInfo.FirebaseProjectId, FirestoreClient.Create(channel));

                var tasks = new Task[15];

                tasks[1] = TriggerControllersSystem.UpdateLoop();

                tasks[2] = DamageablesSystem.UpdateLoop();
                tasks[3] = RechargeablesSystem.UpdateLoop();

                tasks[4] = SensorsSystem.UpdateLoop();
                tasks[5] = ScannersSystem.UpdateLoop();
                tasks[6] = SamplersSystem.UpdateLoop();

                tasks[7] = PingsSenderSystem.UpdateLoop();
                tasks[8] = PositionsSystem.UpdateLoop();

                tasks[9]  = CraftingSystem.UpdateLoop();
                tasks[10] = MapItemsSystem.UpdateLoop();
                tasks[11] = ModularsSystem.UpdateLoop();
                tasks[12] = ModulesInventorySystem.UpdateLoop();
                tasks[13] = ResourcesInventorySystem.UpdateLoop();

                tasks[14] = CommunicationSystem.UpdateLoop();

                var dispatcher = new Dispatcher();

                dispatcher.OnDisconnect(op =>
                {
                    connection.SendLogMessage(LogLevel.Info, "Disconnect", string.Format("Reason for diconnect {0}", op.Reason));
                    Connected = false;
                });

                stopwatch.Stop();

                for (int i = 1; i < tasks.Length; i++)
                {
                    tasks[i].Start();
                }

                connection.SendLogMessage(LogLevel.Info, "Initialization", string.Format("Init Time {0}ms", stopwatch.Elapsed.TotalMilliseconds.ToString("N0")));

                while (Connected)
                {
                    using (var opList = connection.GetOpList(100))
                    {
                        stopwatch.Restart();

                        Parallel.Invoke(
                            () => dispatcher.Process(opList),
                            () => PingsSenderSystem.dispatcher.Process(opList),
                            () => PositionsSystem.dispatcher.Process(opList),
                            () => IdentificationsSystem.dispatcher.Process(opList),
                            () => ExplorationHacksSystem.dispatcher.Process(opList),
                            () => DamageablesSystem.dispatcher.Process(opList),
                            () => RechargeablesSystem.dispatcher.Process(opList),
                            () => SamplersSystem.dispatcher.Process(opList),
                            () => ScannersSystem.dispatcher.Process(opList),
                            () => SensorsSystem.dispatcher.Process(opList),
                            () => TriggerControllersSystem.dispatcher.Process(opList),
                            () => ModularsSystem.dispatcher.Process(opList),
                            () => ModulesInventorySystem.dispatcher.Process(opList),
                            () => ResourcesInventorySystem.dispatcher.Process(opList),
                            () => MapItemsSystem.dispatcher.Process(opList),
                            () => CraftingSystem.dispatcher.Process(opList),
                            () => CommunicationSystem.dispatcher.Process(opList)
                            );

                        stopwatch.Stop();

                        connection.SendLogMessage(LogLevel.Info, "Process OpList", string.Format("Time {0}ms", stopwatch.ElapsedMilliseconds.ToString("N0")));
                    }

                    stopwatch.Restart();
                    SpatialOSConnectionSystem.Update();
                    stopwatch.Stop();

                    connection.SendLogMessage(LogLevel.Info, "SpatialOSConnectionSystem.Update", string.Format("Time {0}ms", stopwatch.ElapsedMilliseconds.ToString("N0")));
                }

                tasks[0] = channel.ShutdownAsync();
                tasks[0].Start();

                Task.WaitAll(tasks);
            }

            return(1);
        }
コード例 #20
0
ファイル: Trader.cs プロジェクト: AtharvaTawde/sourceheadz
    private void Start()
    {
        traderType    = traderTypes[Random.Range(0, traderTypes.Length)];
        spriteMatcher = new Dictionary <string, Sprite> {
            { "Tungsten Carbide Boots", forgerItems[0] },
            { "Tungsten Carbide Leggings", forgerItems[1] },
            { "Tungsten Carbide Chestplate", forgerItems[2] },
            { "Titanium Nugget", forgerItems[3] },
            { "Titanium Bar", forgerItems[4] },
            { "Titanium Boots", forgerItems[5] },
            { "Titanium Leggings", forgerItems[6] },
            { "Titanium Sword", forgerItems[7] },
            { "Titanium Chestplate", forgerItems[8] },
            { "Diamond", forgerItems[9] },
            { "Diamond Boots", forgerItems[10] },
            { "Diamond Leggings", forgerItems[11] },
            { "Diamond Sword", forgerItems[12] },
            { "Diamond Chestplate", forgerItems[13] },
            { "Varium", forgerItems[14] },
            { "Varium Boots", forgerItems[15] },
            { "Varium Leggings", forgerItems[16] },
            { "Varium Sword", forgerItems[17] },
            { "Varium Chestplate", forgerItems[18] },
            { "Gold Bar", forgerItems[19] },
            { "Zombie Spleen", forgerItems[20] },
            { "Nyert Meat", forgerItems[21] },
            { "Chicken", forgerItems[22] },
            { "Goblin Meat", forgerItems[23] },
            { "Bread Scrap", forgerItems[24] },
            { "Apple", forgerItems[25] },
            { "Wood Shard", forgerItems[26] },
            { "Stick", forgerItems[27] },
            { "Stripped Log", forgerItems[28] },
            { "Tree Trunk", forgerItems[29] },
        };

        inventory = GameObject.FindObjectOfType <Inventory>();
        c         = GameObject.FindObjectOfType <CraftingSystem>();

        foreach (GameObject g in tradingWindowObjects)
        {
            g.transform.localScale = Vector3.zero;
        }

        if (traderType == "Forger")
        {
            pickItemsFromHere = allForgerTradesPossible.Keys.ToList();
        }
        else if (traderType == "Rancher")
        {
            pickItemsFromHere = allRancherTradesPossible.Keys.ToList();
        }
        else if (traderType == "Lumberjack")
        {
            pickItemsFromHere = allLumberJackTradesPossible.Keys.ToList();
        }

        for (int i = 0; i < Random.Range(4, 6); i++)
        {
            int    r          = Random.Range(0, pickItemsFromHere.Count);
            string pickedItem = pickItemsFromHere[r];
            pickItemsFromHere.Remove(pickedItem);
            currentItemsSelling.Add(pickedItem);
        }
    }