Example #1
0
 void Awake()
 {
     Instance = gameObject;
     PlayerTransform = Instance.transform;
     PlayerHealth = Instance.GetComponent<PlayerHealth>();
     PlayerExperience = Instance.GetComponent<PlayerExperience>();
     PlayerEnergy = Instance.GetComponent<PlayerEnergy>();
     PlayerWeaponControl = Instance.GetComponent<PlayerWeaponControl>();
 }
Example #2
0
    public void init()
    {
        pos = Map.grid.grid_to_world(Map.grid.world_to_grid(transform.position));
        current_node = Map.grid.get_node(Map.grid.world_to_grid(pos));

        controller = GetComponent<Controller2D>();
        controller.init();
        player_movement = GetComponent<PlayerMovement>();
        player_movement.init();

        Transform weapon_obj = transform.parent.FindChild("weapon_base");
        if (weapon_obj == null) Debug.LogError("'weapon_base' object cannot be found in player parent's children");
        inventory = weapon_obj.GetComponent<WeaponInventory>();
        inventory.init(this);
        weapon_control = weapon_obj.GetComponent<PlayerWeaponControl>();
        weapon_control.init();

        grappling_hook = GetComponent<GrapplingHook>();
        grappling_hook.init();
        health = GetComponent<GenericHealth>();
        health.init(this);
    }