Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        this.transform.position = GlobalVariables.spawnPos;

        GlobalVariables.globalObjects["player"] = this.gameObject;
        controller  = this.gameObject.GetComponent <CharacterMoverComponent>();
        meleeAttack = this.gameObject.GetComponent <CharacterMeleeComponent>();
        hud         = this.gameObject.GetComponent <PlayerHUDComponent>();
        vfx         = this.gameObject.GetComponent <PlayerVFXComponent>();
        level       = this.gameObject.GetComponent <CharacterLevelComponent>();
        animator    = this.gameObject.GetComponent <Animator>();
        animator.SetFloat("AnimSpeed", 1.0f);
        rangedAttack = GetComponent <CharacterRangedComponent>();
        health       = GetComponent <CharacterHealthComponent>();

        health.health    = PlayerStats.Health;
        health.maxHealth = PlayerStats.Maxhealth;
        hud.hasKey       = PlayerStats.HasKey;
        hud.hasNecklace  = PlayerStats.HasNecklace;
        level.XP         = PlayerStats.Xp;
        level.level      = PlayerStats.Level;
        level.levelUp    = PlayerStats.Levelup;

        hud.hasSword = PlayerStats.HasSword;
    }
Exemple #2
0
    private Animator animator;          //animator component


    // Start is called before the first frame update
    void Start()
    {
        controller    = GetComponent <CharacterMoverComponent>();
        melee         = GetComponent <CharacterMeleeComponent>();
        ranged        = GetComponent <CharacterRangedComponent>();
        level         = GetComponent <CharacterLevelComponent>();
        renderer      = GetComponent <SpriteRenderer>();
        patrolPoint   = transform.position;
        following     = false;
        moveDirection = RandomDirection();
        animator      = this.gameObject.GetComponent <Animator>();

        if (player == null)
        {
            Object cache;
            if (GlobalVariables.globalObjects.TryGetValue("player", out cache))
            {
                player = (GameObject)cache;
            }
            else
            {
                Debug.Log("player null");
            }
        }
    }