Ejemplo n.º 1
0
    internal CollectableType NextTailPartsPop()
    {
        CollectableType nextTail = _nextTailParts.Last();

        _nextTailParts.Remove(nextTail);
        return(nextTail);
    }
Ejemplo n.º 2
0
 public void ToolTP()
 {
     if (toolType == ToolType.Machado)
     {
         Debug.Log("É um Machado");
         collectableType = CollectableType.Madeira;
         Debug.Log(collectableType);
     }
     else if (toolType == ToolType.Foice)
     {
         Debug.Log("É uma Foice");
         collectableType = CollectableType.Grama;
         Debug.Log(collectableType);
     }
     else if (toolType == ToolType.Picartea)
     {
         Debug.Log("É uma Picareta");
         collectableType = CollectableType.Pedra;
         Debug.Log(collectableType);
     }
     else if (toolType == ToolType.Enxada)
     {
         Debug.Log("É uma Enxada");
         collectableType = CollectableType.Terreno;
         Debug.Log(collectableType);
     }
 }
Ejemplo n.º 3
0
    public void placeStopDown()
    {
        if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Stops)
        {
            TaskObject.GetComponent <Construction_Script>().Contained_Stops++;

            System_Script.CollectableStops.Remove(Items[0]);
            var index = TaskObject.GetComponent <Construction_Script>().Workerlist_Stops.IndexOf(this.gameObject);
            Items[0].transform.rotation     = TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints[index].transform.rotation;
            Items[0].transform.eulerAngles += new Vector3(0, 180, 0);
            Items[0].transform.position     = new Vector3(Items[0].transform.position.x, 0.1f, Items[0].transform.position.z);

            TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints.RemoveAt(index);

            TaskObject.GetComponent <Construction_Script>().aquiredObj.Add(Items[0]);
            Items[0].GetComponent <Collectable>().MakeStatic();
            Items[0].GetComponent <Animation>().Play("Open");
        }

        Items.Clear();

        CurrentTask = CurrentJob.Nothing;
        TaskChassis = TaskChassis.Nothing;
        ItemType    = CollectableType.Nothing;
    }
Ejemplo n.º 4
0
        public Collectable GetRandom(CollectableType type)
        {
            if (!RuntimeCollectableGroups.ContainsKey(type))
            {
                return(null);
            }

            CollectableGroup group = RuntimeCollectableGroups[type];

            CollectableSpawnProbability[] possibleCollectables = group.PossibleCollectables;
            Collectable result = null;

            uint randomBucket = (uint)Random.Range(0, group.TotalFrequency);

            uint curBucketMin = 0;

            for (int i = 0, end = possibleCollectables.Length; i < end; i++)
            {
                if (curBucketMin <= randomBucket &&
                    randomBucket < curBucketMin + possibleCollectables[i].Frequency)
                {
                    result = possibleCollectables[i].CollectablePrefab;
                }

                curBucketMin += possibleCollectables[i].Frequency;
            }

            return(result);
        }
Ejemplo n.º 5
0
    // add a transformation to spawn manager, retrieve the id where the spawn location was inserted
    // call before everything
    public int RegisterSpawnItemLocation(Transform mySpawnLocation, CollectableType myItemType, bool needSpawn = false, bool forceSpawn = false, Shapes shapes = Shapes.None, int nbItems = 1, float circleRadius = 1.0f)
    {
        dicSpawnItemsLocations.Add(lastInsertedKeySpawnItems, mySpawnLocation);

        if (needSpawn)
        {
            switch (shapes)
            {
            case Shapes.None:
                SpawnItem(lastInsertedKeySpawnItems, myItemType, forceSpawn);
                break;

            case Shapes.Circle:
                SpawnCircleShapedItems(lastInsertedKeySpawnItems, nbItems, myItemType, forceSpawn, circleRadius);
                break;

            case Shapes.Line:
                SpawnLineShapedItems(lastInsertedKeySpawnItems, nbItems, myItemType, forceSpawn);
                break;

            case Shapes.Grid:
                SpawnGridShapedItems(lastInsertedKeySpawnItems, nbItems, myItemType, forceSpawn);
                break;
            }
        }

        return(lastInsertedKeySpawnItems++);
    }
Ejemplo n.º 6
0
    private void LocalPlayer_InventoryChange(Operation op, CollectableType key, int newAmount)
    {
        this.Delayed(0, () => // Need to delay to make sure the changes have been applied.
        {
            resourceText.text = localPlayer.GetInventoryCount(CollectableType.TowerResource).ToString();
            UpdatePowerupButton(CollectableType.PowerupFreeze, freezeButton, freezeAmountText);
            UpdatePowerupButton(CollectableType.PowerupJamTowers, jamButton, jamAmountText);
            UpdatePowerupButton(CollectableType.PowerupGrapplingHook, grappleButton, grappleAmountText);
        });

        if (op == Operation.OP_SET)
        {
            int oldAmount = localPlayer.GetInventoryCount(key);
            Debug.Log(key + " from " + oldAmount + " to " + newAmount);
            Transform target;
            switch (key)
            {
            case CollectableType.PowerupFreeze: target = freezeAmountText.transform; break;

            case CollectableType.PowerupJamTowers: target = jamAmountText.transform; break;

            case CollectableType.TowerResource: target = resourceText.transform; break;

            default: return;
            }
            this.AnimateVector(0.3f, Vector3.one, valueUpdatePopSize * Vector3.one, valueUpdatePopCurve, v => target.localScale = v);
        }
    }
Ejemplo n.º 7
0
    private void UpdatePowerupButton(CollectableType type, Button button, TMPro.TextMeshProUGUI amountText)
    {
        int amount = localPlayer.GetInventoryCount(type);

        amountText.text     = amount.ToString();
        button.interactable = amount > 0;
    }
Ejemplo n.º 8
0
    private void Start()
    {
        this.maxCount = GameProgress.MaxSkullCount();
        this.m_skull  = base.transform.Find("Skull");
        this.m_skull.localPosition = -Vector3.up * 17f;
        this.m_bgColor             = base.transform.Find("BackgroundBox").GetComponent <Renderer>().material;
        int             num             = 0;
        CollectableType collectableType = this.type;

        if (collectableType != CollectableType.Skull)
        {
            if (collectableType == CollectableType.Statue)
            {
                num = GameProgress.SecretStatueCount();
            }
        }
        else
        {
            num = GameProgress.SecretSkullCount();
        }
        base.transform.Find("Skull/SkullText").GetComponent <TextMesh>().text = ((num >= 10) ? (num + "/" + this.maxCount) : string.Concat(new object[]
        {
            "0",
            num,
            "/",
            this.maxCount
        }));
        base.StartCoroutine(this.PlayAnimation());
    }
Ejemplo n.º 9
0
 public Collectable(string _CollectableID, CollectableType _CollectableType, bool _CollectableCollected)
 {
     CollectableID        = _CollectableID;
     CollectableType      = _CollectableType;
     CollectableCollected = _CollectableCollected;
     GFXParent            = null;
 }
        internal void AddCollectable(CollectableType value)
        {
            Collectables[value]++;
            string message = "You collected a " + CollectableNames[(int)value] + " powerup!";

            SetEventText(message, TimeSpan.FromSeconds(5));
        }
Ejemplo n.º 11
0
        public ICollectable build(CollectableType type, Vector2 location)
        {
            factory = new SpriteFactory();
            if (type == CollectableType.coin)
            {
                product = new Coin(location);
            }
            if (type == CollectableType.star)
            {
                product = new Star(location);
            }
            if (type == CollectableType.oneUp)
            {
                product = new OneUpMushroom(location);
            }
            if (type == CollectableType.fireFlower)
            {
                product = new FireFlower(location);
            }
            if (type == CollectableType.superMushroom)
            {
                product = new SuperMushroom(location);
            }
            if (type == CollectableType.ninja)
            {
                product = new Ninja(location);
            }

            return(product);
        }
Ejemplo n.º 12
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag.Equals(Tags.ENEMY))
        {
            mAudioSource.Stop();
            mAudioSource.Play();
            isStunned = true;
            StartCoroutine(resetStun());
            return;
        }

        ICollectable collectable = other.GetComponent <ICollectable>();

        // we only care if we collid with an collectable
        if (collectable != null)
        {
            CollectableType type = collectable.Collect();
            if (type == CollectableType.NONE)
            {
                return;
            }

            if (type == CollectableType.HP_BOBBLE)
            {
                mHealthManager.GainHealth(HP_GAIN_VALUE);
                HighscoreManager.Instance.AddToScore(HighscoreManager.GET_HEALTH);
                return;
            }

            mInventory.AddInventoryItem(type);
            HighscoreManager.Instance.AddToScore(HighscoreManager.FIND_CORE);
        }
    }
Ejemplo n.º 13
0
    public void Feed(Entity collector, CollectableType collectedType)
    {
        _snakeEater._nextTailParts.Add(collectedType);
        SnakeBlock collectorSnakeBlock = (SnakeBlock)collector;

        collectorSnakeBlock.HasFood = true;
    }
Ejemplo n.º 14
0
 public static bool CheckEvolutionAndCollectableTypeCompatibility(CollectableType _collectableType, EvolutionComponent _currentComponent)
 {
     return((_collectableType == CollectableType.AgileEvolution1 && _currentComponent is EvolutionAgile) ||
            (_collectableType == CollectableType.PlatformistEvolution1 && _currentComponent is EvolutionPlatformist) ||
            (_collectableType == CollectableType.GhostEvolution1 && _currentComponent is EvolutionGhost) ||
            (_collectableType == CollectableType.StrengthEvolution1 && _currentComponent is EvolutionStrength));
 }
Ejemplo n.º 15
0
 /*
  * Returns true if collectableType is linked to an evolution
  */
 public static bool IsAnEvolutionCollectable(CollectableType collectableType)
 {
     return(collectableType == CollectableType.StrengthEvolution1 ||
            collectableType == CollectableType.PlatformistEvolution1 ||
            collectableType == CollectableType.AgileEvolution1 ||
            collectableType == CollectableType.GhostEvolution1);
 }
Ejemplo n.º 16
0
    public static Collectable newRandomCollectable()
    {
        float           rand = Random.value;
        CollectableType type = CollectableType.Empty;

        if (rand < 0.4f)
        {
            type = CollectableType.SpeedUp;
        }
        else if (rand < 0.8f)
        {
            type = CollectableType.Weapon;
        }
        else
        {
            type = CollectableType.Enlarge;
        }
        WeaponType weapon = WeaponType.None;

        if (type == CollectableType.Weapon)
        {
            //TODO add new types of weapons
            weapon = WeaponType.Projectile;
        }
        return(new Collectable(type, weapon));
    }
Ejemplo n.º 17
0
    public Collectable GetCollectable(CollectableType _type)
    {
        Collectable collectable = null;

        switch (_type)
        {
        case CollectableType.Gold:
            collectable = goldCoins.GetPooledCollectable();
            break;

        case CollectableType.Stamina:
            collectable = staminaBars.GetPooledCollectable();
            break;

        case CollectableType.Charge:
            collectable = charges.GetPooledCollectable();
            break;

        case CollectableType.Shield:
            collectable = shields.GetPooledCollectable();
            break;

        case CollectableType.MegaCoin:
            collectable = megaCoins.GetPooledCollectable();
            break;

        default:
            Debug.LogError("Invalid Request to Collectable Pooler");
            break;
        }
        return(collectable);
    }
Ejemplo n.º 18
0
    private void SpawnGridShapedItems(int idLocation, int nbItems, CollectableType myItemType, bool forceSpawn = false)
    {
        if (dicSpawnItemsLocations.ContainsKey(idLocation) == false)
        {
            Debug.Log("Error  : invalid location");
            return;
        }

        if (!forceSpawn && SpawnedItemsCount == MAXSPAWNITEMSCOUNTATTHESAMETIME)
        {
            Debug.Log("Error  : max item reach");
            return;
        }

        // TMP heuristic
        int ligne   = Mathf.RoundToInt(Mathf.Sqrt(nbItems));
        int colonne = Mathf.FloorToInt(nbItems / ligne);

        for (int i = 0; i < colonne; i++)
        {
            for (int j = 0; j < ligne; j++)
            {
                SpawnedItemsCount++;
                ResourceUtils.Instance.refPrefabLoot.SpawnCollectableInstance(
                    GetVector3ArrayOnAGrid(dicSpawnItemsLocations[idLocation].transform.position, dicSpawnItemsLocations[idLocation].transform.forward, ligne, colonne)[i, j],
                    dicSpawnItemsLocations[idLocation].transform.rotation,
                    dicSpawnItemsLocations[idLocation].transform,
                    myItemType
                    ).GetComponent <Collectable>().Init();
            }
        }
    }
Ejemplo n.º 19
0
 public Collectable(Vector2 currentPosition, Vector2 velocity, World world, CollectableType t)
     : base(currentPosition, velocity, world)
 {
     isPickedUp = false;
     size       = new Vector2(16, 16);
     hitBox     = new Rectangle((int)currentPosition.X, (int)currentPosition.Y, (int)size.X, (int)size.Y);
     this.type  = t;
 }
Ejemplo n.º 20
0
 public Evolution(Powers _powerName, float _duration, CollectableType _associatedCollectable, int _cost, BodyPart _bodyPart)
 {
     id       = (int)_powerName;
     duration = _duration;
     associatedCollectable = _associatedCollectable;
     cost     = _cost;
     bodyPart = _bodyPart;
 }
Ejemplo n.º 21
0
        public void SetValues(CollectableType collectableType, Vector3 position, Material material)
        {
            var meshRenderer = GetComponent <MeshRenderer>();

            CollectableType       = collectableType;
            transform.position    = position;
            meshRenderer.material = material;
        }
Ejemplo n.º 22
0
 public void PickUpCollectable()
 {
     CurrentTask = CurrentJob.CarringCollectable;
     TaskObject.GetComponent <Collectable>().CollectedCart = CollectionSpace;
     Items.Add(TaskObject);
     ItemType = TaskObject.GetComponent <Collectable>().CollectableType;
     FindNearestCollectableDropOff();
 }
Ejemplo n.º 23
0
 public void AddInventoryItem(CollectableType type)
 {
     if (type == CollectableType.NONE)
     {
         return;
     }
     AddInventoryItem(CollectableFactory.Instance.CreateCollectable(type));
 }
Ejemplo n.º 24
0
 public bool Contains(CollectableType itemType)
 {
     if (items.TryGetValue(itemType, out uint count))
     {
         return(count > 0);
     }
     return(false);
 }
Ejemplo n.º 25
0
    private void HandleCollection(CollectableType _collectableType, ushort _score, int _ID)
    {
        if (collectableList.Count <= 0)
        {
            return;
        }

        collectableList[_ID].gameObject.SetActive(false);
    }
Ejemplo n.º 26
0
    public int NumberOfCollectables(CollectableType _CollectableType, bool _countAllCollectables = false)
    {
        if (_countAllCollectables == true)
        {
            return(LoadSaveController.LoadedCollectables.Count);
        }

        return(LoadSaveController.LoadedCollectables.Where(a => a.CollectableType == _CollectableType).Count());
    }
Ejemplo n.º 27
0
 /// <summary>Returns how many items of the given type the player has in their inventory.</summary>
 public int GetInventoryCount(CollectableType type)
 {
     if (type == CollectableType.None)
     {
         throw new ArgumentException("cannot lookup invalid type");
     }
     inventory.TryGetValue(type, out int value);
     return(value);
 }
Ejemplo n.º 28
0
 public void AddToInventory(CollectableType type, int amount)
 {
     if (type == CollectableType.None)
     {
         throw new ArgumentException("cannot add invalid type");
     }
     inventory.TryGetValue(type, out int value);
     inventory[type] = value + amount;
 }
Ejemplo n.º 29
0
    public void AddScore(CollectableType ct)
    {
        int intCt = (int)ct;

        Assert.IsTrue(intCt < collectableValues.Length);
        score += collectableValues[intCt];
        SetScoreText();
        playerProgress.SetHiScore(score);
        //Debug.Log("score: " + score);
    }
Ejemplo n.º 30
0
    public void RemoveItem(CollectableType itemType)
    {
        if (!items.ContainsKey(itemType) || items[itemType] == 0)
        {
            Debug.LogError("Trying to remove an item not contained in the inventory.");
            return;
        }

        items[itemType] -= 1;
    }
Ejemplo n.º 31
0
    public void placeItem(GameObject item, CollectableType type)
    {
        // based on the type of collectable (Collectable.TYPE)
        // put in the correct place
        if (type == CollectableType.HAND) {
            item.transform.parent = handCollectable;
        }
        else {
            item.transform.parent = headCollectable;
        }

        // make sure the local position and rotation of the item is reset
        // so that it's location on the character is defined by the
        // orientation of the transform
        item.transform.localPosition = Vector3.zero;
        item.transform.localRotation = Quaternion.identity;

        // Add a Direct Connection to the item collected
        // - the player will trust items that they pick up that they can
        //   carry in hand, but distrust items that have to be carried overhead (for safety)
        if (type == CollectableType.HAND)
        {
            // player HAS this other actor (which is an item)
            _graph.AddDirectConnection(new Connection(gameObject, item, RelationshipType.HAS));
            // make the player dangerous after picking up a weapon
            _player.actorType = ActorType.DANGEROUS;
        }
        else
        {
            // player HAS this other actor (which is an item)
            _graph.AddDirectConnection(new Connection(gameObject, item, RelationshipType.HAS));
            // animals make us all nicer people
            _player.actorType = ActorType.ANIMAL;
        }

        // increase the number of items collected
        _gc.Items++;
    }