Exemple #1
0
        public void PushShell(ShellController shellController)
        {
            shellController.transform.parent = transform;
            Vector3 newShellPosition = transform.position;

            newShellPosition.z  = shellController.transform.position.z;
            newShellPosition.y -= GetComponent <SpriteRenderer>().bounds.size.y;
            newShellPosition.y += shellController.GetComponent <SpriteRenderer>().bounds.size.y / 2;

            int   pushNumber       = GetComponentsInChildren <ShellController>().Length;
            float horizontalOffset = 0;

            switch (pushNumber)
            {
            case 2:
                horizontalOffset = -shellController.GetComponent <SpriteRenderer>().bounds.size.x / 2;
                break;

            case 3:
                horizontalOffset = shellController.GetComponent <SpriteRenderer>().bounds.size.x / 2;
                break;

            case 4:
                horizontalOffset = shellController.GetComponent <SpriteRenderer>().bounds.size.x / 4;
                break;
            }
            newShellPosition.x += horizontalOffset;

            shellController.transform.position = newShellPosition;
        }
Exemple #2
0
        public void OnShellDrop(ShellController shellController)
        {
            bool shellPushed = false;

            foreach (var tray in trays)
            {
                if (tray.GetComponent <Collider2D>().bounds.Intersects(shellController.GetComponent <Collider2D>().bounds))
                {
                    tray.PushShell(shellController);
                    shellPushed = true;
                }
            }

            if (!shellPushed)
            {
                shellController.PushTable();
            }
        }
Exemple #3
0
 public void OnShellDrag(ShellController shellController)
 {
 }