示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        hitDetect          = GetComponentInChildren <HitDetection>();
        attackAnimator     = GetComponentInChildren <Animator>();
        shootingProjectile = GetComponent <ShootingProjectiles>();
        stats         = GetComponent <PlayerStats>();
        body          = GetComponent <Rigidbody2D>();
        currentHealth = stats.getHealth();
        resources     = GetComponent <ResourceBag>();
        resources.initEmpty();

        abovePlayerUI = (Instantiate(Resources.Load("UI/Healthbar")) as GameObject);
        healthbar     = abovePlayerUI.GetComponentInChildren <Slider>();
        nameUI        = abovePlayerUI.GetComponentInChildren <TMPro.TextMeshProUGUI>();

        spawn           = new Vector2(transform.position.x, transform.position.y);
        timeOfLastClick = Time.time;

        if (isLocalPlayer)
        {
            hitDetect.isTheLocalPlayer = true;
            uiControl        = GameObject.FindObjectOfType <UI_Control>();
            uiControl.player = this;
            UI_Camera uiCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <UI_Camera>();
            mnmenu = GameObject.FindObjectOfType <MonumentalNetworkMenu>();
            uiCamera.followTarget = this.gameObject;
            currentHealth         = stats.getHealth();
            spriteRender          = this.GetComponent <SpriteRenderer>();
            spriteRender.sprite   = classSprites[stats.Class];
        }
    }
示例#2
0
 void Start()
 {
     me       = this.GetComponentInParent <Player>();
     shooting = this.GetComponentInParent <ShootingProjectiles>();
 }