Пример #1
0
 void Update()
 {
     if (!isDestroyed)
     {
         if (isFacingRight)
         {
             transform.position = new Vector3(transform.position.x + (shotSpeed * Time.deltaTime), transform.position.y, transform.position.z);
         }
         else
         {
             transform.position = new Vector3(transform.position.x - (shotSpeed * Time.deltaTime), transform.position.y, transform.position.z);
         }
         if (Math.Abs(lastSplatterLocation.x - transform.position.x) >= 1)
         {
             newSplatterObj = Instantiate(splatter, new Vector3(transform.position.x + (isFacingRight ? .5f : -.5f), transform.position.y - 1f, transform.position.z), Quaternion.identity) as Splatter;
             //newSplatterObj.transform.localScale = new Vector3(.6f, .6f, .6f);
             lastSplatterLocation = transform.position;
             newSplatterObj.ApplyStyle();
         }
         Collider2D[] wallColliders = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), detectWallRadius);
         foreach (Collider2D coll in wallColliders)
         {
             if (coll.gameObject.CompareTag("PaintableSurfaceTag"))
             {
                 isDestroyed = true;
             }
         }
         if (isDestroyed)
         {
             SplatToWall();
         }
     }
 }
Пример #2
0
    void SplatToWall()
    {
        Splatter splatterToObj =
            (Splatter)Instantiate(splatter,
                                  new Vector3(transform.position.x + (isFacingRight ? .5f : -.5f),
                                              transform.position.y, transform.position.z), Quaternion.identity);

        //splatterToObj.transform.localScale = new Vector3(.6f, .6f, .6f);
        splatterToObj.ApplyStyle();
        splatterObj.gameObject.SetActive(false);
        gameObject.SetActive(false);
        Destroy(splatterObj.gameObject.GetComponent <GameObject>());
        Destroy(gameObject.GetComponent <GameObject>());
    }