private void setItemsImageList()
    {
        itemSprites.Clear();
        FurnaceController.SequenceOfColor sequenceOfColor = FurnaceController.GetCurrentSequence();

        for (int i = 0; i < FurnaceController.GetCurrentSequenceLenght(); i++)
        {
            PickableType currentType = sequenceOfColor.types[i];
            GameObject   itemImage   = new GameObject();
            itemImage.AddComponent <Image>();

            switch (currentType)
            {
            case PickableType.RobotHead: itemSprites.Add(RobotHeadImage);
                break;

            case PickableType.Crate: itemSprites.Add(CrateImage);
                break;

            case PickableType.Gear: itemSprites.Add(GearImage);
                break;

            case PickableType.Battery: itemSprites.Add(BatteryImage);
                break;

            case PickableType.Pipe: itemSprites.Add(PipeImage);
                break;
            }
        }
        imageList.CreateLayout(itemSprites, sequenceOfColor.ColorsSequence);
    }
Пример #2
0
    /// <summary>
    /// Get a pickable based on its type and network id.
    /// </summary>
    /// <param name="type">The type of the pickable.</param>
    /// <param name="id">The network id of the pickable.</param>
    /// <returns>The pickable.</returns>
    public Pickable Get(PickableType type, int id)
    {
        if (id == 0)
        {
            return(null);
        }
        switch (type)
        {
        case PickableType.Consumable:
            return(consumableDict[id]);

        case PickableType.Item:
            return(itemDict[id]);

        case PickableType.Weapon:
            return(weaponDict[id]);

        case PickableType.StatusEffect:
            return(statusEffectDict[id]);

        case PickableType.WorldEffect:
            return(worldEffectDict[id]);
        }
        throw new Exception("Could not find " + type);
    }
Пример #3
0
    /// <summary>
    /// Loads all pickables of a type into a list.
    /// </summary>
    /// <param name="pickable">The type of pickable.</param>
    public static List <Pickable> LoadPickables(PickableType pickable)
    {
        string[]        guids     = AssetDatabase.FindAssets(GetSearchString(pickable));
        List <Pickable> pickables = new List <Pickable>();

        for (int i = 0; i < guids.Length; i++)
        {
            pickables.Add(AssetDatabase.LoadAssetAtPath <Pickable>(AssetDatabase.GUIDToAssetPath(guids[i])));
        }
        return(pickables);
    }
        public static List <Pickable> GetItems(PickableType type, int quantity)
        {
            List <Pickable> list = new List <Pickable>();

            for (int i = 0; i < quantity; i++)
            {
                list.Add(items[(int)type].Dequeue());
            }

            return(list);
        }
    private void ValidateConsumed(PickableType type, Color color)
    {
        SequenceOfColor currentSequence = SequencesOfColor[SucceedSequences];

        Color        currentSequenceColor = currentSequence.ColorsSequence[currentSequence.SucceedColors];
        PickableType currentType          = currentSequence.types[currentSequence.SucceedColors];

        if (_finishAfterOnce)
        {
            WhenFurnaceConsumedAll?.Invoke();
        }
        else
        {
            if (Math.Abs(currentSequenceColor.r - (color).r) < 0.01f &&
                Math.Abs(currentSequenceColor.g - (color).g) < 0.01f &&
                Math.Abs(currentSequenceColor.b - (color).b) < 0.01f && currentType == type)
            {
                CheckItemOffList?.Invoke();
                WhenFurnaceConsumeRight?.Invoke();
                if (!_firstSuccessPlayed)
                {
                    OnFirstSuccessfulItemDropped?.Invoke();
                    _firstSuccessPlayed = true;
                }

                currentSequence.SucceedColors++;
                if (currentSequence.SucceedColors == currentSequence.ColorsSequence.Length)
                {
                    SucceedSequences++;
                    if (SucceedSequences == SequencesOfColor.Length)
                    {
                        WhenFurnaceConsumedAll?.Invoke();
                    }
                    else
                    {
                        WhenFurnaceConsumeAWholeSequenceWithoutFinishing?.Invoke();
                    }
                }
            }
            else
            {
                if (!_firstFailPlayed)
                {
                    _firstFailPlayed = true;
                    OnFirstWrongItemDropped?.Invoke();
                }
                WhenFurnaceConsumeWrong?.Invoke();
            }
        }
    }
Пример #6
0
    private void Attack(PickableType pickableType)
    {
        switch (pickableType)
        {
        case PickableType.Hope:
            animator.SetTrigger("Net");
            break;

        case PickableType.Trauma:
            animator.SetTrigger("Bottle");
            break;

        default:
            break;
        }
    }
Пример #7
0
    public void Impact(PickableType pickableType)
    {
        switch (pickableType)
        {
        case PickableType.Hope:
            //No change in score. Hope oversteps you.
            break;

        case PickableType.Trauma:
            effectsSource.PlayOneShot(impactTraumaClip);
            animator.SetTrigger("Damaged");
            score.Increase(-1);
            break;

        default:
            Debug.LogError("Unknown type.");
            break;
        }
    }
Пример #8
0
 internal void Impact(PickableType pickableType, PickableType weaponType)
 {
     if (pickableType == PickableType.Hope && weaponType == PickableType.Hope)
     {
         HuntHope();
     }
     if (pickableType == PickableType.Trauma && weaponType == PickableType.Trauma)
     {
         DestroyTrauma();
     }
     if (pickableType == PickableType.Hope && weaponType == PickableType.Trauma)
     {
         DestroyHope();
     }
     if (pickableType == PickableType.Trauma && weaponType == PickableType.Hope)
     {
         HuntTrauma();
     }
 }
Пример #9
0
    public static string GetSearchString(PickableType pickable)
    {
        switch (pickable)
        {
        case PickableType.Consumable:
            return("t:Consumable");

        case PickableType.Item:
            return("t:Item");

        case PickableType.Weapon:
            return("t:Weapon");

        case PickableType.StatusEffect:
            return("t:StatusEffect");

        case PickableType.WorldEffect:
            return("t:WorldEffect");
        }
        throw new System.Exception("Could not find that type" + pickable);
    }
Пример #10
0
    public static GameObject Create(PickableType _Type)
    {
        switch (_Type)
        {
        case PickableType.ammoPack:
            return(GameRules.m_refStockage.m_AmmoPack_Prefab);

        case PickableType.healPack:
            return(GameRules.m_refStockage.m_MedPack_Prefab);

        case PickableType.reinforcement:
            return(GameRules.m_refStockage.m_WoodBoard_Prefab);

        case PickableType.barbele:
            return(GameRules.m_refStockage.m_Barbele_Prefab);

        default:
            break;
        }

        return(null);
    }
Пример #11
0
        private static void InstantiatePickable(XmlNode objectNode, Dictionary <int, XmlNode> dictProperties, ref List <ICheckpointLoadable> objectsLoadable)
        {
            string xString = objectNode.Attributes["x"].Value;
            float  xPos    = float.Parse(xString, System.Globalization.CultureInfo.InvariantCulture);

            string yString = objectNode.Attributes["y"].Value;
            float  yPos    = float.Parse(yString, System.Globalization.CultureInfo.InvariantCulture);

            Vector2 pos           = new Vector2(xPos + (int.Parse(objectNode.Attributes["width"].Value) / 2), yPos - (int.Parse(objectNode.Attributes["height"].Value) / 2));
            int     globalIdCrate = int.Parse(objectNode.Attributes["gid"].Value) - 1;

            XmlNode properties = dictProperties[globalIdCrate];

            PickableType type = (PickableType)int.Parse(properties.FirstChild.Attributes["value"].Value);
            Pickable     p    = null;

            switch (type)
            {
            case PickableType.Apple:
                p = new Apple(pos);
                break;

            case PickableType.ExtraLife:
                p = new ExtraLife(pos);
                break;

            case PickableType.Crystal:
                p = new CrystalPickable(pos);
                break;
            }

            if (p != null)
            {
                objectsLoadable.Add(p);
            }
        }
Пример #12
0
 public Pickable Init(PickableType type)
 {
     Type = type;
     GetComponent <Collider>().isTrigger = true;
     return(this);
 }
Пример #13
0
 private void SpawnPickable(Vector3 position, PickableType type)
 {
     Instantiate(pickablePrefab, position, Quaternion.identity).GetComponent <PickableController>().Configure(type, this);
 }
 public static Pickable GetItem(PickableType type)
 {
     return(items[(int)type].Dequeue());
 }
Пример #15
0
 /// <summary>
 /// Fixes ids of a particular pickable type.
 /// </summary>
 /// <param name="pickableType">The type to be fixed.s</param>
 public static void FixIDsOfType(PickableType pickableType) => FixIDs(LoadPickables(pickableType));
Пример #16
0
 public void Configure(PickableType type, PickableSpawner pickableSpawner)
 {
     this.pickableSpawner = pickableSpawner;
     this.type            = type;
     ConfigureSprite();
 }
Пример #17
0
    public static Pickable ReadPickable(this NetworkReader reader)
    {
        PickableType type = (PickableType)reader.ReadByte();

        return(PickableDict.Instance.Get(type, reader.ReadUInt16()));
    }
Пример #18
0
 public void Hunt(PickableType pickableType)
 {
     player.Impact(pickableType, type);
 }