Esempio n. 1
0
    private void OnTryWearShell()
    {
        if (_shell != null)
        {
            shell = null;
            Debug.Log("Had a shell, dropped");
            return;
        }

        List <ShellParent> shells = FindObjectsOfType <ShellParent>().ToList();

        shells = shells.OrderBy(
            x => Vector3.Distance(this.transform.position, x.transform.position)
            ).ToList();


        foreach (ShellParent currentShell in shells)
        {
            float distance = (transform.position - currentShell.transform.position).magnitude;
            Debug.Log("Shell at " + distance);
            if (distance <= SHELL_GRAB_RANGE)
            {
                shell = currentShell;
            }
            return;
        }
    }
Esempio n. 2
0
    void Start()
    {
        shell     = shell; //lol
        main      = this;
        healthBar = GameObject.Find("HealthBar").GetComponent <Image>();

        //crabAnimations = GetComponent<Animator>();

        _rb = GetComponent <Rigidbody>();

        restartButton = GameObject.Find("Restart").GetComponent <UnityEngine.UI.Button>();
        restartButton.gameObject.SetActive(false);
    }
Esempio n. 3
0
    private void OnWearShell(ShellParent newShell)
    {
        if (newShell != null)
        {
            newShell.Attach(transform);
        }
        if (_shell != null)
        {
            _shell.Drop();
        }

        _shell = newShell;
        UpdateShellGraphic();
    }
Esempio n. 4
0
 private void DropShell()
 {
     shell = null;
 }
Esempio n. 5
0
    public Sprite GetShellSprite(ShellParent shellObj)
    {
        int shellIndex = (shellObj == null) ? 0 : ((int)shellObj.type + 1);

        return(shellSprites[shellIndex]);
    }