Exemplo n.º 1
0
    public bool AddMeatPart(MeatPartController meatPart)
    {
        if (meatPartsInScene.Count == 0)
        {
            meatPartsInScene.Add(meatPart);
            meatSucces(true);
            return(true);
        }


        MeatPartController topMeatPart = meatPartsInScene[meatPartsInScene.Count - 1];
        bool isOnTop = GetMaxMeatHeight() < meatPart.GetTopPointOfMeat() + bufferOffset;

        if (isOnTop)
        {
            meatPartsInScene.Add(meatPart);
            meatSucces(true);
            return(true);
        }
        else
        {
            meatPartsInScene.Remove(meatPart);
            Destroy(meatPart.gameObject);
            meatSucces(false);
            return(false);
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         MeatPartController meatPart = Instantiate(meatPartPrefab, Vector3.zero, Quaternion.identity, transform);
     }
 }
Exemplo n.º 3
0
    public MeatPartController GetBlock()
    {
        MeatPartController ret = next;

        if (lastSuccess)
        {
            next = Instantiate(normalBlocks[Random.Range(0, normalBlocks.Count)], gameParent);
            maxNormalParts--;
        }
        else
        {
            next = SelectHumanBodyPart();
            screamAudioController.PlayScream();
        }

        PrepareNextMeatPart();

        if (maxHumanParts < 0 || maxNormalParts < 0)
        {
            gameController.PlayerLost();
        }
        ret.GetRigidbody().isKinematic = false;

        uiController.UpdateMeatLeftText(maxNormalParts);

        return(ret);
    }
Exemplo n.º 4
0
 void Start()
 {
     next = Instantiate(normalBlocks[Random.Range(0, normalBlocks.Count)], gameParent);
     maxNormalParts--;
     PrepareNextMeatPart();
     lastSuccess           = true;
     lastSelectedHumanPart = 0;
 }
Exemplo n.º 5
0
 public void SetLastSuccess(bool success)
 {
     if (lastSuccess != success && success)
     {
         Destroy(next.gameObject);
         maxHumanParts++;
         next = Instantiate(normalBlocks[Random.Range(0, normalBlocks.Count)], gameParent);
         uiController.EnableSprite(lastSelectedHumanPart, false);
         maxNormalParts--;
     }
     else if (lastSuccess != success && !success)
     {
         Destroy(next.gameObject);
         maxNormalParts++;
         next = SelectHumanBodyPart();
     }
     lastSuccess = success;
     PrepareNextMeatPart();
 }
Exemplo n.º 6
0
    // Update is called once per frame
    private void Update()
    {
        timeFromLastDrop += Time.deltaTime;
        if ((Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) && timeFromLastDrop > gameController.GetRateOfDroping())
        {
            MeatPartController meatPart = GenerateBlock.GetBlock();
            meatPart.transform.SetParent(transform);
            meatPart.transform.localPosition = Vector3.zero;
            meatPart.transform.SetParent(gameTransform);
            meatPart.Setup(movingDir, meatPartsManager, audioSplatterController);
            meatPart.GetCollider().enabled = true;
            //meatPart.transform.localScale = meatPart.GetOriginalScale();
            timeFromLastDrop = 0;
        }

        transform.position += movingDir * movingSpeed * Time.deltaTime;
        if (Mathf.Abs(transform.position.x) > movingBound)
        {
            movingDir.x        *= -1;
            transform.position += movingDir * Time.deltaTime;
        }
    }